Class: Ramaze::Gems::GemStone

Inherits:
Object
  • Object
show all
Defined in:
lib/ramaze/contrib/gems.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ GemStone

Returns a new instance of GemStone.



25
26
27
# File 'lib/ramaze/contrib/gems.rb', line 25

def initialize(name, options = {})
  @name, @options = name, options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/ramaze/contrib/gems.rb', line 23

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



23
24
25
# File 'lib/ramaze/contrib/gems.rb', line 23

def options
  @options
end

Instance Method Details

#installObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ramaze/contrib/gems.rb', line 40

def install
  require 'rubygems/gem_runner'
  version, source = options.values_at(:version, :source)

  cmd = %w[install] << name
  cmd << "--version" << version if version
  cmd << "--source" << source if source

  print cmd * ' '
  Gem::GemRunner.new.run(cmd)
end

#setup(ran = false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/ramaze/contrib/gems.rb', line 29

def setup(ran = false)
  Gem.activate(name, *[@options[:version]].compact)
  require options[:lib] || name
rescue LoadError => error
  puts error
  return if ran
  puts "attempting install"
  install
  setup(ran = true)
end