class Sunzi::Dependency

Attributes

list[RW]

Public Class Methods

load(key) click to toggle source
# File lib/sunzi/dependency.rb, line 14
def load(key)
  unless dependency = @list[key]
    fail "#{key} is not initialized. Run Sunzi::Dependency.new('#{key}', '~> ...')"
  end

  name, version = dependency.name, dependency.version

  begin
    gem(name, version)
    require(name)
  rescue LoadError
    base = GemRoot.join('templates/dependency')
    which = if $!.to_s =~ /Gemfile/
      'gemfile'
    else
      'install'
    end
    text = ERB.new(base.join("#{which}.erb").read).result(binding)
    abort_with text
  end
end
new(*args) click to toggle source
Calls superclass method
# File lib/sunzi/dependency.rb, line 6
def initialize(*args)
  super
  self.class.list[name] = self
end