Class: SuperGood::SolidusTaxjar::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SuperGood::SolidusTaxjar::Generators::InstallGenerator
- Defined in:
- lib/generators/super_good/solidus_taxjar/install/install_generator.rb
Instance Method Summary collapse
- #add_migrations ⇒ Object
- #create_initializer_file ⇒ Object
- #create_legacy_events_initializer_file ⇒ Object
- #create_omes_initializer_file ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#add_migrations ⇒ Object
53 54 55 |
# File 'lib/generators/super_good/solidus_taxjar/install/install_generator.rb', line 53 def add_migrations run 'bin/rails railties:install:migrations FROM=super_good_solidus_taxjar' end |
#create_initializer_file ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/super_good/solidus_taxjar/install/install_generator.rb', line 7 def create_initializer_file solidus_initializer_path = "config/initializers/solidus.rb" create_file(solidus_initializer_path) unless File.exist?(solidus_initializer_path) append_to_file(solidus_initializer_path, <<~INIT) Spree.config do |config| config.tax_calculator_class = SuperGood::SolidusTaxjar::TaxCalculator end INIT end |
#create_legacy_events_initializer_file ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/super_good/solidus_taxjar/install/install_generator.rb', line 38 def create_legacy_events_initializer_file return unless Gem::Requirement.new('< 3.2') .satisfied_by?(::Spree.solidus_gem_version) initializer_path = "config/initializers/solidus_taxjar_legacy_events.rb" create_file(initializer_path) unless File.exist?(initializer_path) append_to_file(initializer_path, <<~INIT) Rails.application.config.to_prepare do require 'super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb' SuperGood::SolidusTaxjar::Spree::LegacyReportingSubscriber.activate end INIT end |
#create_omes_initializer_file ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/super_good/solidus_taxjar/install/install_generator.rb', line 18 def create_omes_initializer_file return unless Gem::Requirement.new('>= 3.2.0.alpha') .satisfied_by?(::Spree.solidus_gem_version) omnes_initializer_path = "config/initializers/omnes.rb" create_file(omnes_initializer_path) unless File.exist?(omnes_initializer_path) append_to_file(omnes_initializer_path, <<~INIT) Rails.application.config.to_prepare do if SolidusSupport::LegacyEventCompat.using_legacy? require 'super_good/solidus_taxjar/spree/legacy_reporting_subscriber.rb' SuperGood::SolidusTaxjar::Spree::LegacyReportingSubscriber.omnes_subscriber.subscribe_to(Spree::Bus) else require 'super_good/solidus_taxjar/spree/reporting_subscriber.rb' SuperGood::SolidusTaxjar::Spree::ReportingSubscriber.new.subscribe_to(Spree::Bus) end end INIT end |
#run_migrations ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/generators/super_good/solidus_taxjar/install/install_generator.rb', line 57 def run_migrations run_migrations = [:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) if run_migrations run 'bin/rails db:migrate' else puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' end end |