Permalink
Browse files

upgrade rubygems/setup code

  • Loading branch information...
mpapis committed Mar 15, 2012
1 parent 58fd5b6 commit 9c23f10a5ab5d08cf3b085a927b17b317454b8a2
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/shoes/setup.rb
View
@@ -24,12 +24,13 @@ class Shoes::Setup
def self.init
gem_reset
- install_sources if Gem.source_index.find_name('sources').empty?
+ Gem::Specification.find_by_name('sources')
+ rescue Gem::LoadError
+ install_sources
end
def self.gem_reset
Gem.use_paths(GEM_DIR, [GEM_DIR, GEM_CENTRAL_DIR])
- Gem.source_index.refresh!
end
def self.setup_app(setup)
@@ -97,20 +98,17 @@ def no_steps?
def gem name, version = nil
arg = "#{name} #{version}".strip
name, version = arg.split(/\s+/, 2)
- if Gem.source_index.find_name(name, version).empty?
- @steps << [:gem, arg]
- else
- activate_gem(name, version)
- end
+ Gem::Specification.find_by_name(name, version)
+ rescue Gem::LoadError
+ @steps << [:gem, arg]
end
def source uri
@steps << [:source, uri]
end
def activate_gem(name, version)
- gem = Gem.source_index.find_name(name, version).first
- Gem.activate(gem.name, "= #{gem.version}")
+ Gem::Specification.find_by_name(name, version).activate
end
def start(app)
@@ -125,7 +123,9 @@ def start(app)
name, version = arg.split(/\s+/, 2)
count += 1
ui.say "Looking for #{name}"
- if Gem.source_index.find_name(name, version).empty?
+ begin
+ Gem::Specification.find_by_name(name, version)
+ rescue Gem::LoadError
ui.title "Installing #{name}"
installer = Gem::DependencyInstaller.new
begin

0 comments on commit 9c23f10

Please sign in to comment.