Class: Pliny::Commands::Generator::Endpoint
- Inherits:
-
Base
- Object
- Base
- Pliny::Commands::Generator::Endpoint
show all
- Defined in:
- lib/pliny/commands/generator/endpoint.rb
Instance Attribute Summary
Attributes inherited from Base
#name, #options, #stream
Instance Method Summary
collapse
Methods inherited from Base
#display, #field_name, #initialize, #plural_class_name, #pluralized_file_name, #render_template, #singular_class_name, #table_name, #write_file, #write_template
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# 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 ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# 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 ⇒ Object
19
20
21
22
23
24
25
26
|
# 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 ⇒ Object
39
40
41
|
# File 'lib/pliny/commands/generator/endpoint.rb', line 39
def url_path
'/' + name.pluralize.tr('_', '-')
end
|