Class: Gemsconfig::Entry
- Inherits:
-
Object
- Object
- Gemsconfig::Entry
- Defined in:
- lib/gemsconfig/entry.rb
Instance Attribute Summary collapse
-
#lib ⇒ Object
readonly
Returns the value of attribute lib.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name, attrs) ⇒ Entry
constructor
A new instance of Entry.
- #install ⇒ Object
- #load ⇒ Object
- #loaded? ⇒ Boolean
Constructor Details
#initialize(name, attrs) ⇒ Entry
Returns a new instance of Entry.
7 8 9 10 11 12 13 14 |
# File 'lib/gemsconfig/entry.rb', line 7 def initialize(name, attrs) attrs ||= {} @name = name @lib = attrs[:lib] @lib = attrs['lib'] if @lib.nil? @version = attrs[:version] || attrs['version'] @source = attrs[:source] || attrs['source'] end |
Instance Attribute Details
#lib ⇒ Object (readonly)
Returns the value of attribute lib.
5 6 7 |
# File 'lib/gemsconfig/entry.rb', line 5 def lib @lib end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/gemsconfig/entry.rb', line 5 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/gemsconfig/entry.rb', line 5 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/gemsconfig/entry.rb', line 5 def version @version end |
Instance Method Details
#install ⇒ Object
31 32 33 34 35 |
# File 'lib/gemsconfig/entry.rb', line 31 def install cmd = install_gem_command puts cmd puts %x(#{cmd}) end |
#load ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gemsconfig/entry.rb', line 16 def load begin unless @lib == false gem name, version_spec if @version require (@lib || @name) end rescue LoadError => err raise LoadError, "\nGemsconfig: could not load configured gem '#{@name}'#{" (#{@lib})" if @lib} - #{err.}\n\nTry:\nrake gemsconfig:install\n--or--\n#{install_gem_command}\n\n" end end |
#loaded? ⇒ Boolean
27 28 29 |
# File 'lib/gemsconfig/entry.rb', line 27 def loaded? %x(#{gem_command} #{list_command.join(' ')}).split("\n").detect{|listing| listing =~ Regexp.new("#{name}\s+.+#{Regexp.escape(@version) if @version}.+")} end |