class Forger::Template::Context
Public Class Methods
new(options={})
click to toggle source
# File lib/forger/template/context.rb, line 9 def initialize(options={}) @options = options load_variables load_custom_helpers end
Private Instance Methods
load_custom_helpers()
click to toggle source
Load custom helper methods from project
# File lib/forger/template/context.rb, line 31 def load_custom_helpers Dir.glob("#{Forger.root}/app/helpers/**/*_helper.rb").each do |path| filename = path.sub(%r{.*/},'').sub('.rb','') module_name = filename.camelize # Prepend a period so require works FORGER_ROOT is set to a relative path # without a period. # # Example: FORGER_ROOT=tmp/project first_char = path[0..0] path = "./#{path}" unless %w[. /].include?(first_char) require path self.class.send :include, module_name.constantize end end
load_variables()
click to toggle source
Load variables from:
config/variables/development.rb config/variables/production.rb etc
# File lib/forger/template/context.rb, line 20 def load_variables load_variables_file(:base) load_variables_file(Forger.env) end
load_variables_file(type)
click to toggle source
# File lib/forger/template/context.rb, line 25 def load_variables_file(type) path = "#{Forger.root}/config/variables/#{type}.rb" instance_eval(IO.read(path), path) if File.exist?(path) end