Class: Worthwhile::WorkGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Worthwhile::WorkGenerator
- Defined in:
- lib/generators/worthwhile/work/work_generator.rb
Instance Method Summary collapse
- #create_actor ⇒ Object
- #create_actor_spec ⇒ Object
- #create_controller ⇒ Object
- #create_controller_spec ⇒ Object
- #create_model ⇒ Object
-
#create_model_spec ⇒ Object
Why all of these antics with defining individual methods? Because I want the output of Worthwhile::WorkGenerator to include all the processed files.
- #create_readme ⇒ Object
- #create_views ⇒ Object
- #register_work ⇒ Object
Instance Method Details
#create_actor ⇒ Object
46 47 48 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 46 def create_actor template("actor.rb.erb", "app/actors/curation_concern/#{file_name}_actor.rb") end |
#create_actor_spec ⇒ Object
37 38 39 40 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 37 def create_actor_spec return unless rspec_installed? template("actor_spec.rb.erb", "spec/actors/curation_concern/#{file_name}_actor_spec.rb") end |
#create_controller ⇒ Object
42 43 44 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 42 def create_controller template("controller.rb.erb", "app/controllers/curation_concern/#{plural_file_name}_controller.rb") end |
#create_controller_spec ⇒ Object
32 33 34 35 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 32 def create_controller_spec return unless rspec_installed? template("controller_spec.rb.erb", "spec/controllers/curation_concern/#{plural_file_name}_controller_spec.rb") end |
#create_model ⇒ Object
29 30 31 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 29 def create_model template("model.rb.erb", "app/repository_models/#{file_name}.rb") end |
#create_model_spec ⇒ Object
Why all of these antics with defining individual methods? Because I want the output of Worthwhile::WorkGenerator to include all the processed files.
24 25 26 27 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 24 def create_model_spec return unless rspec_installed? template "model_spec.rb.erb", "spec/repository_models/#{file_name}_spec.rb" end |
#create_readme ⇒ Object
67 68 69 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 67 def create_readme readme 'README' end |
#create_views ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 59 def create_views create_file "app/views/curation_concern/#{plural_file_name}/_#{file_name}.html.erb" do data = "<%# This is a search result view %>\n" data << "<%= render 'catalog/document', document: #{file_name}, document_counter: #{file_name}_counter %>\n" data end end |
#register_work ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/generators/worthwhile/work/work_generator.rb', line 50 def register_work inject_into_file 'config/initializers/worthwhile_config.rb', after: "Worthwhile.configure do |config|\n" do data = "" data << " # Injected via `rails g worthwhile:work #{class_name}`\n" data << " config.register_curation_concern :#{file_name}\n" data end end |