Class: Sunzi::Dependency
Class Attribute Summary collapse
-
.list ⇒ Object
Returns the value of attribute list.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Dependency
constructor
A new instance of Dependency.
Constructor Details
#initialize(*args) ⇒ Dependency
Returns a new instance of Dependency.
6 7 8 9 |
# File 'lib/sunzi/dependency.rb', line 6 def initialize(*args) super self.class.list[name] = self end |
Class Attribute Details
.list ⇒ Object
Returns the value of attribute list.
12 13 14 |
# File 'lib/sunzi/dependency.rb', line 12 def list @list end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/sunzi/dependency.rb', line 2 def name @name end |
#version ⇒ Object
Returns the value of attribute version
2 3 4 |
# File 'lib/sunzi/dependency.rb', line 2 def version @version end |
Class Method Details
.load(key) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |