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
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/pliny/commands/generator/endpoint.rb', line 8
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
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/pliny/commands/generator/endpoint.rb', line 30
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
21
22
23
24
25
26
27
28
|
# File 'lib/pliny/commands/generator/endpoint.rb', line 21
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
41
42
43
|
# File 'lib/pliny/commands/generator/endpoint.rb', line 41
def url_path
"/" + name.pluralize.tr("_", "-")
end
|