Sha256: 0746080d2578c6320def1ae35b725b3939f08fb542bd5527f3ab88f545796b44
Contents?: true
Size: 829 Bytes
Versions: 1
Compression:
Stored size: 829 Bytes
Contents
module Sunzi class Dependency < Struct.new(:name, :version) @list = {} def initialize(*args) super self.class.list[name] = self end class << self attr_accessor :list 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sunzi-2.1.0 | lib/sunzi/dependency.rb |