Class: Sunshine::Gem

Inherits:
Dependency show all
Defined in:
lib/sunshine/package_managers/gem.rb

Overview

The Gem dependency class supports most of rubygem’s installation features:

dependency_lib.instance_eval do
  gem "rdoc", :version => '~>0.8',
              :source  => 'http://gemcutter.org',
              :opts    => '--use-lib blah' # Anything after --
end

See the Dependency class for more info.

Instance Attribute Summary

Attributes inherited from Dependency

#children, #name, #parents, #pkg

Instance Method Summary collapse

Methods inherited from Dependency

#add_child, #check, #check_test, #child_dependencies, #install, #install!, #install_parents!, #installed?, #missing_parents?, #parent_dependencies, #requires, sudo, sudo=, system_manager?, #to_s, #uninstall, #uninstall!, #uninstall_children!

Constructor Details

#initialize(name, options = {}, &block) ⇒ Gem

Returns a new instance of Gem.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sunshine/package_managers/gem.rb', line 19

def initialize(name, options={}, &block)
  super(name, options) do
    version = options[:version] ? " --version '#{options[:version]}'" : ""

    source = if options[:source]
      " --source #{options[:source]} --source http://gemcutter.org"
    end

    install_opts = " --no-ri --no-rdoc"
    if options[:opts]
      install_opts = "#{install_opts} -- #{options[:opts]}"
    end

    install   "gem install #{@pkg}#{version}#{source}#{install_opts}"
    uninstall "gem uninstall #{@pkg}#{version}"
    check     "gem list #{@pkg} -i#{version}"

    requires(*options[:require].to_a) if options[:require]

    instance_eval(&block) if block_given?
  end
end