Class: TradoPaypalModule::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- TradoPaypalModule::Generators::InstallGenerator
- Defined in:
- lib/generators/trado_paypal_module/install_generator.rb
Instance Method Summary collapse
- #assign_model_concerns ⇒ Object
- #copy_controller ⇒ Object
- #copy_helper ⇒ Object
- #copy_migration ⇒ Object
- #setup_env_configs ⇒ Object
- #setup_routes ⇒ Object
Instance Method Details
#assign_model_concerns ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/trado_paypal_module/install_generator.rb', line 29 def assign_model_concerns order_content = "\n has_order_paypal\n CONTENT\n transaction_content = <<-CONTENT\n\n has_transaction_paypal\n CONTENT\n\n inject_into_file \"app/models/order.rb\", order_content, after: \"class Order < ActiveRecord::Base\"\n inject_into_file \"app/models/transaction.rb\", transaction_content, after: \"class Transaction < ActiveRecord::Base\"\nend\n" |
#copy_controller ⇒ Object
17 18 19 |
# File 'lib/generators/trado_paypal_module/install_generator.rb', line 17 def copy_controller template "controller.rb", "app/controllers/carts/paypal_controller.rb" end |
#copy_helper ⇒ Object
13 14 15 |
# File 'lib/generators/trado_paypal_module/install_generator.rb', line 13 def copy_helper template "helper.rb", "app/helpers/paypal_helper.rb" end |
#copy_migration ⇒ Object
6 7 8 9 10 11 |
# File 'lib/generators/trado_paypal_module/install_generator.rb', line 6 def copy_migration unless paypal_migration_already_exists? = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i copy_file "migration.rb", "db/migrate/#{timestamp_number}_add_paypal_attributes.rb" end end |
#setup_env_configs ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/generators/trado_paypal_module/install_generator.rb', line 43 def setup_env_configs development_content = "\n # PayPal settings\n config.after_initialize do\n ActiveMerchant::Billing::Base.mode = :test\n paypal_options = {\n login: Rails.application.secrets.paypal_login,\n password: Rails.application.secrets.paypal_password,\n signature: Rails.application.secrets.paypal_signature\n }\n ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)\n end\n CONTENT\n\n test_content = <<-CONTENT\n\n # PayPal settings\n config.after_initialize do\n ActiveMerchant::Billing::Base.mode = :test\n ::EXPRESS_GATEWAY = ActiveMerchant::Billing::BogusGateway.new\n end\n CONTENT\n\n production_content = <<-CONTENT\n\n # PayPal settings\n config.after_initialize do\n paypal_options = {\n login: Rails.application.secrets.paypal_login,\n password: Rails.application.secrets.paypal_password,\n signature: Rails.application.secrets.paypal_signature\n }\n ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)\n end\n CONTENT\n inject_into_file \"config/environments/development.rb\", development_content, after: \"Trado::Application.configure do\"\n inject_into_file \"config/environments/test.rb\", test_content, after: \"Trado::Application.configure do\"\n inject_into_file \"config/environments/production.rb\", production_content, after: \"Trado::Application.configure do\"\nend\n" |
#setup_routes ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/generators/trado_paypal_module/install_generator.rb', line 21 def setup_routes route_content = "\n mount TradoPaypalModule::Engine => '/paypal'\n CONTENT\n inject_into_file \"config/routes.rb\", route_content, after: \"Trado::Application.routes.draw do\"\nend\n" |