Class: CurationConcerns::Models::InstallGenerator
- Inherits:
-
AbstractMigrationGenerator
- Object
- Rails::Generators::Base
- AbstractMigrationGenerator
- CurationConcerns::Models::InstallGenerator
- Defined in:
- lib/generators/curation_concerns/models/install_generator.rb
Instance Method Summary collapse
- #banner ⇒ Object
-
#clamav ⇒ Object
Adds clamav initializtion.
-
#copy_migrations ⇒ Object
Setup the database migrations.
- #create_collection ⇒ Object
- #create_configuration_files ⇒ Object
- #create_file_set ⇒ Object
-
#inject_curation_concerns_user_behavior ⇒ Object
Add behaviors to the user model.
Methods inherited from AbstractMigrationGenerator
Instance Method Details
#banner ⇒ Object
12 13 14 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 12 def say_status('warning', 'GENERATING CURATION_CONCERNS MODELS', :yellow) end |
#clamav ⇒ Object
Adds clamav initializtion
59 60 61 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 59 def clamav generate 'curation_concerns:models:clamav' end |
#copy_migrations ⇒ Object
Setup the database migrations
17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 17 def copy_migrations [ 'create_version_committers.rb', 'create_checksum_audit_logs.rb', 'create_single_use_links.rb' # , ].each do |file| better_migration_template file end end |
#create_collection ⇒ Object
50 51 52 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 50 def create_collection copy_file 'app/models/collection.rb', 'app/models/collection.rb' end |
#create_configuration_files ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 40 def create_configuration_files append_file 'config/initializers/mime_types.rb', "\nMime::Type.register 'application/x-endnote-refer', :endnote", verbose: false copy_file 'config/curation_concerns.rb', 'config/initializers/curation_concerns.rb' copy_file 'config/redis.yml', 'config/redis.yml' copy_file 'config/resque-pool.yml', 'config/resque-pool.yml' copy_file 'config/redis_config.rb', 'config/initializers/redis_config.rb' copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb' end |
#create_file_set ⇒ Object
54 55 56 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 54 def create_file_set copy_file 'app/models/file_set.rb', 'app/models/file_set.rb' end |
#inject_curation_concerns_user_behavior ⇒ Object
Add behaviors to the user model
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/curation_concerns/models/install_generator.rb', line 28 def inject_curation_concerns_user_behavior file_path = "app/models/#{model_name.underscore}.rb" if File.exist?(file_path) inject_into_file file_path, after: /include Hydra\:\:User.*$/ do "\n # Connects this user object to Curation Concerns behaviors." \ "\n include CurationConcerns::User\n" end else puts " \e[31mFailure\e[0m CurationConcerns requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g curation_concerns client" end end |