Class: Dunlop::TargetFileGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Dunlop::TargetFileGenerator
- Includes:
- Generators::GeneratorHelpers
- Defined in:
- lib/generators/dunlop/target_file/target_file_generator.rb
Instance Method Summary collapse
Methods included from Generators::GeneratorHelpers
Instance Method Details
#add_factory ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/dunlop/target_file/target_file_generator.rb', line 16 def add_factory if behavior == :revoke gsub_file "spec/factories/target_files.rb", /^s+factory 'target_file/#{file_name}'.*$/, '' else gsub_file "spec/factories/target_files.rb", /end\s*\z/m do |match_data| " factory 'target_file/#{file_name}', class: 'TargetFile::#{class_name}', parent: :target_file\nend" end end end |
#add_translations ⇒ Object
26 27 28 29 |
# File 'lib/generators/dunlop/target_file/target_file_generator.rb', line 26 def add_translations gsub_file "config/locales/target_files.yml", /^ plural:\s*$/, " target_file/#{file_name}: #{file_name.humanize}\n plural:" gsub_file "config/locales/target_files.yml", /^ attributes:\s*$/, " target_file/#{file_name}: #{file_name.humanize.pluralize}\n attributes:" end |
#create_target_file ⇒ Object
9 10 11 12 13 14 |
# File 'lib/generators/dunlop/target_file/target_file_generator.rb', line 9 def create_target_file add_to_symbol_list "app/models/target_file.rb", 'setup_target_files', file_name template "model.rb.erb", "app/models/target_file/#{file_name}.rb" template "model_spec.rb.erb", "spec/models/target_file/#{file_name}_spec.rb" end |