Skip to content

Commit

Permalink
upgrade rubygems/setup code
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Mar 15, 2012
1 parent 58fd5b6 commit 9c23f10
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/shoes/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 9c23f10

Please sign in to comment.