class Pliny::Commands::Generator::Endpoint

Public Instance Methods

create() click to toggle source
# File lib/pliny/commands/generator/endpoint.rb, line 6
def create
  endpoint = "./lib/endpoints/#{pluralized_file_name}.rb"
  template = options[:scaffold] ? 'endpoint_scaffold.erb' : 'endpoint.erb'
  write_template(template, endpoint,
                  plural_class_name: plural_class_name,
                  singular_class_name: singular_class_name,
                  field_name: field_name,
                  url_path: url_path)
  display "created endpoint file #{endpoint}"
  display 'add the following to lib/routes.rb:'
  display "  mount Endpoints::#{plural_class_name}"
end
create_acceptance_test() click to toggle source
# File lib/pliny/commands/generator/endpoint.rb, line 28
def create_acceptance_test
  test = "./spec/acceptance/#{pluralized_file_name}_spec.rb"
  template = options[:scaffold] ? 'endpoint_scaffold_acceptance_test.erb' : 'endpoint_acceptance_test.erb'
  write_template(template, test,
                  plural_class_name: plural_class_name,
                  field_name: field_name,
                  singular_class_name: singular_class_name,
                  url_path: url_path)
  display "created test #{test}"
end
create_test() click to toggle source
# File lib/pliny/commands/generator/endpoint.rb, line 19
def create_test
  test = "./spec/endpoints/#{pluralized_file_name}_spec.rb"
  write_template('endpoint_test.erb', test,
                  plural_class_name: plural_class_name,
                  singular_class_name: singular_class_name,
                  url_path: url_path)
  display "created test #{test}"
end
url_path() click to toggle source
# File lib/pliny/commands/generator/endpoint.rb, line 39
def url_path
  '/' + name.pluralize.tr('_', '-')
end