Class: Mack::Utils::GemManager

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/utils/gem_manager.rb

Overview

This class is used to add gems to your application in an easy to use way.

require_gems do |gem|
  gem.add :redgreen, :version => "1.2.2", :libs => :redgreen
  gem.add :termios
  gem.add "rubyzip", :source => "http:// gems.rubyforge.org"
end

Defined Under Namespace

Classes: GemObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGemManager

:nodoc:



15
16
17
# File 'lib/utils/gem_manager.rb', line 15

def initialize # :nodoc:
  @required_gem_list = []
end

Instance Attribute Details

#required_gem_listObject

Returns the value of attribute required_gem_list.



13
14
15
# File 'lib/utils/gem_manager.rb', line 13

def required_gem_list
  @required_gem_list
end

Instance Method Details

#add(name, options = {}) ⇒ Object

Adds a new gem to the system. This does NOT actually require the gem or any of it’s ‘libs’. You need to call the do_requires method to actually require any of the ‘libs’ defined for this gem.

Options:

  • :source => "http:// gems.rubyforge.org"

  • :version => "1.2.3"

  • :libs => "file" or :libs => ["file1", "file2"]



27
28
29
# File 'lib/utils/gem_manager.rb', line 27

def add(name, options = {})
  @required_gem_list << Mack::Utils::GemManager::GemObject.new(name, options)
end

#do_requiresObject

Requires the gem and any libs that you’ve specified.



32
33
34
35
36
37
38
39
40
41
# File 'lib/utils/gem_manager.rb', line 32

def do_requires
  @required_gem_list.each do |g|
    if g.version?
      gem(g.name, g.version)
    else
      gem(g.name)
    end
    g.libs.each {|l| require l.to_s} if g.libs?
  end
end