Skip to content

Commit

Permalink
make basic gem installation work. closes #88
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmuhl committed Jun 18, 2010
1 parent 38d49d0 commit 7b0c3ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/radiant/extension/script.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -182,20 +182,25 @@ def checkout_command
end end


class Gem < Download class Gem < Download
def gem_name(name)
name.gsub(/-\d+\.\d+\.\d+(.+)?\.gem/, '')
end

def download def download
# Don't download the gem if it's already installed # Don't download the gem if it's already installed
extension = gem_name(filename)
begin begin
gem filename.split('-').first gem extension
rescue ::Gem::LoadError rescue ::Gem::LoadError
super super
`gem install #{filename}` `gem install #{extension}`
end end
end end


def unpack def unpack
output = nil output = nil
cd(Dir.tmpdir) do cd(Dir.tmpdir) do
output = `gem unpack #{filename.split('-').first}` output = `gem unpack #{gem_name(filename)}`
end end
self.path = output.match(/'(.*)'/)[1] self.path = output.match(/'(.*)'/)[1]
end end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/radiant/extension/script_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
File.should_receive(:open).with(/example-1.0.0\.gem/, 'w').and_yield(@file) File.should_receive(:open).with(/example-1.0.0\.gem/, 'w').and_yield(@file)
@gem.should_receive(:open).and_return(StringIO.new('test')) @gem.should_receive(:open).and_return(StringIO.new('test'))
@file.should_receive(:write).with('test') @file.should_receive(:write).with('test')
@gem.should_receive(:`).with("gem install example-1.0.0.gem") @gem.should_receive(:`).with("gem install example")
@gem.download @gem.download
end end


Expand Down

0 comments on commit 7b0c3ae

Please sign in to comment.