8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/generators/command/command_generator.rb', line 8
def create_command_file
template "env.rb", "features/support/env.rb"
template "faker.rb", "features/steps/common/faker.rb"
template "helper.rb", "features/steps/common/helper.rb"
template "command.rb", "app/commands/api/#{options[:version]}/#{file_name}_command.rb"
template "command_spec.rb", "spec/commands/api/#{options[:version]}/#{file_name}_command_spec.rb"
inject_into_file "config/routes.rb", routes_temp, before: /^end/
template "command.feature", "features/api/#{options[:version]}/#{file_name}.feature"
template "application_controller.rb", "app/controllers/api/#{options[:version]}/application_controller.rb"
template "authentication.rb", "app/controllers/concerns/authentication.rb"
template "serializer.rb", "app/controllers/concerns/serializer.rb"
template "application_serializer.rb", "app/serializers/application_serializer.rb"
template "resource_serializer.rb", "app/serializers/api/#{options[:version]}/#{file_name}_serializer.rb"
template "command_handler.rb", "app/controllers/concerns/command_handler.rb"
template "resources_controller.rb", "app/controllers/api/#{options[:version]}/#{resources}_controller.rb"
inject_into_file "app/controllers/api/#{options[:version]}/#{resources}_controller.rb", inject_action_controller, before: /private/
inject_into_file "app/controllers/api/#{options[:version]}/#{resources}_controller.rb", inject_params_controller, after: /private/
if options[:collection]
inject_into_file "config/routes.rb", inject_route_temp_collection, after: /namespace :#{options[:version]} do/
else
inject_into_file "config/routes.rb", inject_route_temp_member, after: /namespace :#{options[:version]} do/
end
end
|