Class: Ecart::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Ecart::Generators::InstallGenerator
- Defined in:
- lib/generators/ecart/install/install_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_ecart ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/ecart/install/install_generator.rb', line 10 def add_ecart copy_file 'cart.rb', 'lib/cart.rb' copy_file 'cart_item.rb', 'lib/cart_item.rb' copy_file 'generators/templates/cart_helper.rb', 'app/helpers/cart_helper.rb' copy_file 'generators/templates/cart_controller.rb', 'app/controllers/cart_controller.rb' copy_file 'generators/templates/paypal_express_controller.rb', 'app/controllers/paypal_express_controller.rb' copy_file 'generators/templates/pay_pal_helper.rb', 'app/helpers/pay_pal_helper.rb' directory 'generators/templates/cart', 'app/views/cart' directory 'generators/templates/paypal_express', 'app/views/paypal_express' end |
#add_ecart_routes ⇒ Object
21 22 23 24 25 26 |
# File 'lib/generators/ecart/install/install_generator.rb', line 21 def add_ecart_routes app = ::Rails.application @app_name = app.class.to_s.split("::").first insert_into_file 'config/routes.rb', routes, :after => "#{@app_name}::Application.routes.draw do" insert_into_file 'app/controllers/application_controller.rb', "\n\tinclude CartHelper", :after => 'protect_from_forgery' end |
#add_paypal_configuration ⇒ Object
41 42 43 44 |
# File 'lib/generators/ecart/install/install_generator.rb', line 41 def add_paypal_configuration copy_file 'config/paypal_config.yml', 'config/paypal_config.yml' copy_file 'generators/templates/paypal_express_checkout.rb', 'config/initializers/paypal_express_checkout.rb' end |
#routes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/ecart/install/install_generator.rb', line 28 def routes <<CONTENT match 'add_to_cart/:id' => 'cart#add_to_cart', :as => :add_to_cart match 'remove_from_cart/:id' => 'cart#remove_from_cart', :as => :remove_from_cart match 'empty_cart' => 'cart#empty', :as => :empty_cart match 'cart' => 'cart#show', :as => :cart get 'paypal_express/checkout' get 'paypal_express/purchase' get 'paypal_express/review' CONTENT end |