46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/Olib.rb', line 46
def Olib.install(g, v=nil)
if !which("gem") then
echo "Olib could not detect the `gem` executable in your $PATH"
echo "when you installed Ruby did you forget to click the `modify $PATH` box?"
raise Exception
end
begin
unless v.nil?
raise UpdateGemError if Gem.loaded_specs[g].version < Gem::Version.new(v)
gem g, v
end
Olib.reload g
rescue LoadError
echo "installing #{g}..."
version = "--version '#{v}'" unless v.nil?
worked = system("gem install #{g} #{version} --no-ri --no-rdoc")
unless worked then raise "Could not install #{g} gem" end
Olib.reload g
echo "... installed #{g}!"
rescue UpdateGemError
echo "updating #{g}@#{Gem.loaded_specs[g].version} => #{v}..."
version = "--version '#{v}'" unless v.nil?
worked = system("gem install #{g} #{version} --no-ri --no-rdoc")
unless worked then raise "Could not install #{g} gem" end
Olib.reload g
echo "... updated #{g} to #{v}!"
end
end
|