class Niman::PackageResolver
Public Class Methods
new(instructions)
click to toggle source
# File lib/niman/package_resolver.rb, line 4 def initialize(instructions) @instructions = instructions end
Public Instance Methods
by_name(name)
click to toggle source
# File lib/niman/package_resolver.rb, line 24 def by_name(name) Kernel.const_get(name) end
load(filename)
click to toggle source
# File lib/niman/package_resolver.rb, line 18 def load(filename) basename = File.basename(filename ,File.extname(filename)) require File.expand_path(File.join('packages/', basename)) titleize(basename) end
resolve()
click to toggle source
# File lib/niman/package_resolver.rb, line 8 def resolve Array(@instructions).map do |instruction| if is_file?(instruction) && !instruction.path.empty? self.by_name(self.load(instruction.path)) else instruction end end end
Private Instance Methods
is_file?(obj)
click to toggle source
# File lib/niman/package_resolver.rb, line 30 def is_file?(obj) obj.respond_to?(:path) && obj.respond_to?(:name) end
titleize(filename)
click to toggle source
# File lib/niman/package_resolver.rb, line 34 def titleize(filename) filename.split('_').map(&:capitalize).join('') end