Module: UpAndRunning::FeatureResolver

Extended by:
FeatureResolver
Included in:
FeatureResolver
Defined in:
lib/up_and_running.rb

Instance Method Summary collapse

Instance Method Details

#load_pathObject



23
24
25
26
27
28
# File 'lib/up_and_running.rb', line 23

def load_path
  @load_path ||= begin
                   lp = ENV['UP_AND_RUNNING_FEATURE_LOAD_PATH'] || []
                   lp + File.expand_path('~/.up_and_running/features')
                 end
end

#resolve(name) ⇒ Object

Returns the matching compiler TODO - abstract both compiler and templates into feature



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/up_and_running.rb', line 10

def resolve(name)
  load_path.find do |dir|
    next unless Dir.exists?(dir)
    filename = File.join(dir, "#{name}.rb")
    if File.exists?(filename) 
      load filename
      const_name = File.basename(filename).sub(/\.rb$/, '').split('_').map(&:capitalize).join
      return const_get(const_name)
    end
  end
  raise "Couldn't find feature for #{name}"
end