Class: ForgeCLI::ForgeAddonRequirer

Inherits:
Object
  • Object
show all
Defined in:
lib/forge-cli/forge_addon_requirer.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ForgeAddonRequirer

Returns a new instance of ForgeAddonRequirer.



2
3
4
# File 'lib/forge-cli/forge_addon_requirer.rb', line 2

def initialize(app)
  @app = app
end

Instance Method Details

#require_addon(addon) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/forge-cli/forge_addon_requirer.rb', line 6

def require_addon(addon)
  file = File.join(@app, 'config', 'initializers', 'forge.rb')
  content = File.read(file)
  new_content = content.gsub("require 'forge.rb'", "require 'forge.rb'\nrequire 'forge/config/#{addon}.rb'")
  File.open(file, 'w') do |f|
    f.puts new_content
  end
end