Class: Comable::InstallGenerator
- Inherits:
- 
      Rails::Generators::Base
      
        - Object
- Rails::Generators::Base
- Comable::InstallGenerator
 
- Defined in:
- lib/generators/comable/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_files ⇒ Object
- #append_seeds ⇒ Object
- #complete ⇒ Object
- #configure_application ⇒ Object
- #create_database ⇒ Object
- #insert_routes ⇒ Object
- #install_migrations ⇒ Object
- #load_seed_data ⇒ Object
- #prepare_options ⇒ Object
- #run_migrations ⇒ Object
Class Method Details
.source_paths ⇒ Object
| 13 14 15 16 17 | # File 'lib/generators/comable/install/install_generator.rb', line 13 def source_paths paths = superclass.source_paths paths << File.('../templates', __FILE__) paths.flatten end | 
Instance Method Details
#add_files ⇒ Object
| 25 26 27 | # File 'lib/generators/comable/install/install_generator.rb', line 25 def add_files template 'config/initializers/comable.rb', 'config/initializers/comable.rb' end | 
#append_seeds ⇒ Object
| 41 42 43 44 45 46 | # File 'lib/generators/comable/install/install_generator.rb', line 41 def append_seeds append_file 'db/seeds.rb', <<-SEEDS # Seed data for Comable Comable::Core::Engine.load_seed if defined?(Comable::Core) SEEDS end | 
#complete ⇒ Object
| 91 92 93 | # File 'lib/generators/comable/install/install_generator.rb', line 91 def complete unless [:quiet] end | 
#configure_application ⇒ Object
| 29 30 31 32 33 34 35 36 37 38 39 | # File 'lib/generators/comable/install/install_generator.rb', line 29 def configure_application application <<-APP config.to_prepare do # Overriding Models and Controllers # refs: http://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers Dir.glob(Rails.root.join('app/**/*_decorator*.rb')).each do |c| Rails.configuration.cache_classes ? require_dependency(c) : load(c) end end APP end | 
#create_database ⇒ Object
| 53 54 55 56 | # File 'lib/generators/comable/install/install_generator.rb', line 53 def create_database say_status :creating, 'database' quietly { rake 'db:create' } end | 
#insert_routes ⇒ Object
| 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # File 'lib/generators/comable/install/install_generator.rb', line 76 def insert_routes insert_into_file File.join('config', 'routes.rb'), after: "Rails.application.routes.draw do\n" do <<-ROUTES # This line mounts Comable's routes at the root of your application. # This means, any requests to URLs such as /products, will go to Comable::ProductsController. # If you would like to change where this engine is mounted, simply change the :at option to something different. # # We ask that you don't use the :as option here, as Comable relies on it being the default of "comable" mount Comable::Core::Engine, at: '/' ROUTES end unless [:quiet] end | 
#install_migrations ⇒ Object
| 48 49 50 51 | # File 'lib/generators/comable/install/install_generator.rb', line 48 def install_migrations say_status :copying, 'migrations' quietly { rake 'comable:install:migrations' } end | 
#load_seed_data ⇒ Object
| 67 68 69 70 71 72 73 74 | # File 'lib/generators/comable/install/install_generator.rb', line 67 def load_seed_data if @seed_flag say_status :loading, 'seed data' rake_seed else say_status :skipping, 'seed data (you can always run rake db:seed)' end end | 
#prepare_options ⇒ Object
| 20 21 22 23 | # File 'lib/generators/comable/install/install_generator.rb', line 20 def @migrate_flag = [:migrate] @seed_flag = @migrate_flag ? [:seed] : false end | 
#run_migrations ⇒ Object
| 58 59 60 61 62 63 64 65 | # File 'lib/generators/comable/install/install_generator.rb', line 58 def run_migrations if @migrate_flag say_status :running, 'migrations' quietly { rake 'db:migrate' } else say_status :skipping, "migrations (don't forget to run rake db:migrate)" end end |