Skip to content

Commit

Permalink
Use source in gemlist
Browse files Browse the repository at this point in the history
When `ensure => latest`, `gemlist` is called to determine the latest
available version of a gem.

If the `source` parameter is a remote gem repository, this needs to be
part of the `gem list` command run.

Fixes voxpupuli#128

Signed-off-by: Alexander Fisher <[email protected]>
  • Loading branch information
alexjfisher committed Sep 29, 2016
1 parent b0a5a0c commit 8bbe0cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions lib/puppet/provider/rvm_gem/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def gemlist(hash)
command << "--local"
else
command << "--remote"
if resource[:source] && source_uri(resource[:source]).scheme =~ /^http/
command << '--source' << resource[:source].to_s
end
end

if name = hash[:justme]
Expand Down Expand Up @@ -76,7 +79,6 @@ def self.gemsplit(desc)
end
end


def install(useversion = true)
command = gembinary + ['install']
command << "-v" << resource[:ensure] if (! resource[:ensure].is_a? Symbol) and useversion
Expand All @@ -89,12 +91,7 @@ def install(useversion = true)
end

if source = resource[:source]
begin
uri = URI.parse(source)
rescue => detail
fail "Invalid source '#{uri}': #{detail}"
end

uri = source_uri(source)
case uri.scheme
when nil
# no URI scheme => interpret the source as a local file
Expand Down Expand Up @@ -123,6 +120,15 @@ def install(useversion = true)
self.fail "Could not install: #{output.chomp}" if output.include?("ERROR")
end

def source_uri(source)
begin
uri = URI.parse(source)
rescue => detail
fail "Invalid source '#{uri}': #{detail}"
end
uri
end

def latest
# This always gets the latest version available.
hash = gemlist(:justme => resource[:name])
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
:kernel => 'Linux',
:osfamily => 'RedHat',
:architecture => 'x86_64',
:clientcert => 'puppet.acme.com'
:clientcert => 'puppet.acme.com',
:gnupg_installed => false
}.merge({})

c.before do
Expand All @@ -30,4 +31,3 @@
shared_examples :compile, :compile => true do
it { should compile.with_all_deps }
end

0 comments on commit 8bbe0cf

Please sign in to comment.