Class: SpreeInvoice::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SpreeInvoice::Generators::InstallGenerator
- Defined in:
- lib/generators/spree_invoice/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_migrations ⇒ Object
- #copy_initializer_file ⇒ Object
- #copy_templates_file ⇒ Object
- #generate_missing_records ⇒ Object
- #run_migrations ⇒ Object
Class Method Details
.source_root ⇒ Object
5 6 7 |
# File 'lib/generators/spree_invoice/install/install_generator.rb', line 5 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#add_migrations ⇒ Object
9 10 11 |
# File 'lib/generators/spree_invoice/install/install_generator.rb', line 9 def add_migrations run 'bundle exec rake railties:install:migrations FROM=spree_invoice' end |
#copy_initializer_file ⇒ Object
27 28 29 30 31 |
# File 'lib/generators/spree_invoice/install/install_generator.rb', line 27 def copy_initializer_file puts ">> Copy config file" copy_file "initializer.rb", "config/initializers/spree_invoice.rb" puts "\n>>> Don't forget to check your config file! <<<" end |
#copy_templates_file ⇒ Object
22 23 24 25 |
# File 'lib/generators/spree_invoice/install/install_generator.rb', line 22 def copy_templates_file puts ">> Copy invoice template" copy_file "invoice_template.html.erb", "app/views/spree/invoices/invoice_template.html.erb" end |
#generate_missing_records ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/spree_invoice/install/install_generator.rb', line 33 def generate_missing_records res = ask ">> Would you like to run the generating missing orders now? [Y/n]" if res == "" || res.downcase == "y" puts ">> Generating missing records..." run 'bundle exec rake spree_invoice:generate' else puts ">> Skiping rake spree_invoice:generate, don't forget to run it!" end end |
#run_migrations ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/generators/spree_invoice/install/install_generator.rb', line 13 def run_migrations res = ask ">> Would you like to run the migrations now? [Y/n]" if res == "" || res.downcase == "y" run 'bundle exec rake db:migrate' else puts ">> Skiping rake db:migrate, don't forget to run it!" end end |