Class: EffectiveCpd::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- EffectiveCpd::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/effective_cpd/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy_initializer ⇒ Object
- #copy_locale ⇒ Object
- #copy_mailer_preview ⇒ Object
- #create_migration_file ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/generators/effective_cpd/install_generator.rb', line 10 def self.next_migration_number(dirname) if not ActiveRecord::Base. Time.new.utc.strftime("%Y%m%d%H%M%S") else '%.3d' % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#copy_initializer ⇒ Object
18 19 20 |
# File 'lib/generators/effective_cpd/install_generator.rb', line 18 def copy_initializer template ('../' * 3) + 'config/effective_cpd.rb', 'config/initializers/effective_cpd.rb' end |
#copy_locale ⇒ Object
22 23 24 |
# File 'lib/generators/effective_cpd/install_generator.rb', line 22 def copy_locale template ('../' * 3) + 'config/locales/effective_cpd.en.yml', 'config/locales/effective_cpd.en.yml' end |
#copy_mailer_preview ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/generators/effective_cpd/install_generator.rb', line 56 def copy_mailer_preview mailer_preview_path = (Rails.application.config.action_mailer.preview_path rescue nil) if mailer_preview_path.present? template 'effective_cpd_mailer_preview.rb', File.join(mailer_preview_path, 'effective_cpd_mailer_preview.rb') else puts "couldn't find action_mailer.preview_path. Skipping effective_cpd_mailer_preview." end end |
#create_migration_file ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/generators/effective_cpd/install_generator.rb', line 26 def create_migration_file @cpd_categories_table_name = ':' + EffectiveCpd.cpd_categories_table_name.to_s @cpd_activities_table_name = ':' + EffectiveCpd.cpd_activities_table_name.to_s @cpd_cycles_table_name = ':' + EffectiveCpd.cpd_cycles_table_name.to_s @cpd_rules_table_name = ':' + EffectiveCpd.cpd_rules_table_name.to_s @cpd_special_rules_table_name = ':' + EffectiveCpd.cpd_special_rules_table_name.to_s @cpd_special_rule_mates_table_name = ':' + EffectiveCpd.cpd_special_rule_mates_table_name.to_s @cpd_statements_table_name = ':' + EffectiveCpd.cpd_statements_table_name.to_s @cpd_statement_activities_table_name = ':' + EffectiveCpd.cpd_statement_activities_table_name.to_s @cpd_audit_levels_table_name = ':' + EffectiveCpd.cpd_audit_levels_table_name.to_s @cpd_audit_level_sections_table_name = ':' + EffectiveCpd.cpd_audit_level_sections_table_name.to_s @cpd_audit_level_questions_table_name = ':' + EffectiveCpd.cpd_audit_level_questions_table_name.to_s @cpd_audit_level_question_options_table_name = ':' + EffectiveCpd..to_s @cpd_audits_table_name = ':' + EffectiveCpd.cpd_audits_table_name.to_s @cpd_audit_responses_table_name = ':' + EffectiveCpd.cpd_audit_responses_table_name.to_s @cpd_audit_response_options_table_name = ':' + EffectiveCpd..to_s @cpd_audit_reviews_table_name = ':' + EffectiveCpd.cpd_audit_reviews_table_name.to_s @cpd_audit_review_items_table_name = ':' + EffectiveCpd.cpd_audit_review_items_table_name.to_s @cpd_bulk_audits_table_name = ':' + EffectiveCpd.cpd_bulk_audits_table_name.to_s @cpd_targets_table_name = ':' + EffectiveCpd.cpd_targets_table_name.to_s migration_template ('../' * 3) + 'db/migrate/01_create_effective_cpd.rb.erb', 'db/migrate/create_effective_cpd.rb' end |