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 Original file line Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ class Shoes::Setup


def self.init def self.init
gem_reset gem_reset
install_sources if Gem.source_index.find_name('sources').empty? Gem::Specification.find_by_name('sources')
rescue Gem::LoadError
install_sources
end end


def self.gem_reset def self.gem_reset
Gem.use_paths(GEM_DIR, [GEM_DIR, GEM_CENTRAL_DIR]) Gem.use_paths(GEM_DIR, [GEM_DIR, GEM_CENTRAL_DIR])
Gem.source_index.refresh!
end end


def self.setup_app(setup) def self.setup_app(setup)
Expand Down Expand Up @@ -97,20 +98,17 @@ def no_steps?
def gem name, version = nil def gem name, version = nil
arg = "#{name} #{version}".strip arg = "#{name} #{version}".strip
name, version = arg.split(/\s+/, 2) name, version = arg.split(/\s+/, 2)
if Gem.source_index.find_name(name, version).empty? Gem::Specification.find_by_name(name, version)
@steps << [:gem, arg] rescue Gem::LoadError
else @steps << [:gem, arg]
activate_gem(name, version)
end
end end


def source uri def source uri
@steps << [:source, uri] @steps << [:source, uri]
end end


def activate_gem(name, version) def activate_gem(name, version)
gem = Gem.source_index.find_name(name, version).first Gem::Specification.find_by_name(name, version).activate
Gem.activate(gem.name, "= #{gem.version}")
end end


def start(app) def start(app)
Expand All @@ -125,7 +123,9 @@ def start(app)
name, version = arg.split(/\s+/, 2) name, version = arg.split(/\s+/, 2)
count += 1 count += 1
ui.say "Looking for #{name}" 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}" ui.title "Installing #{name}"
installer = Gem::DependencyInstaller.new installer = Gem::DependencyInstaller.new
begin begin
Expand Down

0 comments on commit 9c23f10

Please sign in to comment.