Class: ForgeCLI::EcommercePostHooks
- Inherits:
-
PostHooks
- Object
- PostHooks
- ForgeCLI::EcommercePostHooks
show all
- Defined in:
- lib/forge-cli/modules/ecommerce/post_hooks.rb
Instance Method Summary
collapse
Methods inherited from PostHooks
#initialize, run!
Instance Method Details
#app_controller_content ⇒ Object
31
32
33
|
# File 'lib/forge-cli/modules/ecommerce/post_hooks.rb', line 31
def app_controller_content
@app_controller_content ||= File.read(app_controller_path)
end
|
#app_controller_path ⇒ Object
27
28
29
|
# File 'lib/forge-cli/modules/ecommerce/post_hooks.rb', line 27
def app_controller_path
File.join(@app, 'app', 'controllers', 'application_controller.rb')
end
|
#module_path ⇒ Object
23
24
25
|
# File 'lib/forge-cli/modules/ecommerce/post_hooks.rb', line 23
def module_path
File.dirname(__FILE__)
end
|
#run! ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/forge-cli/modules/ecommerce/post_hooks.rb', line 2
def run!
STDOUT.puts "Adding Routes..."
ri = ForgeCLI::RouteInstaller.new(@app, module_path)
ri.install_routes
ri.install_routes(:forge)
STDOUT.puts "Adding eCommerce controller methods..."
content = app_controller_content.gsub(
'class ApplicationController < ActionController::Base',
"class ApplicationController < ActionController::Base\n include Forge::Controllers::ECommerce\n"
)
content = "require 'forge/shared_controller_methods/ecommerce.rb'\n" + content
File.open(app_controller_path, 'w') do |f|
f.puts content
end
STDOUT.puts "Adding config requires..."
require_addon(:ecommerce)
end
|