summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-07 17:11:59 -0500
committerLuke Kanies <luke@madstop.com>2008-07-07 17:11:59 -0500
commit667fac18cc3682374de991bb740ae834d8c17bee (patch)
treeff6f50b14c92fb856095c8e87bdb8ebc9080dbc8 /lib/puppet
parent21d49578376b4adcf29e08b50cc14457bc4dcb26 (diff)
downloadpuppet-667fac18cc3682374de991bb740ae834d8c17bee.tar.gz
puppet-667fac18cc3682374de991bb740ae834d8c17bee.tar.xz
puppet-667fac18cc3682374de991bb740ae834d8c17bee.zip
Fixed #1226 - Gems can now specify source repositories.
Added tests for the bit that's changed here (and caught a couple of bugs in the original patch). This is all a modification of Sam Quigley's work. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/provider/package/gem.rb35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb
index 373af431e..133243c86 100755
--- a/lib/puppet/provider/package/gem.rb
+++ b/lib/puppet/provider/package/gem.rb
@@ -69,29 +69,34 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
def install(useversion = true)
command = [command(:gemcmd), "install"]
- if (! @resource.should(:ensure).is_a? Symbol) and useversion
- command << "-v" << @resource.should(:ensure)
+ if (! resource[:ensure].is_a? Symbol) and useversion
+ command << "-v" << resource[:ensure]
end
# Always include dependencies
command << "--include-dependencies"
- if source = @resource[:source]
- scheme = URI.parse(blah).scheme rescue nil # the URI scheme if there is one, nil otherwise
-
- if scheme.nil?
+ if source = resource[:source]
+ begin
+ uri = URI.parse(source)
+ rescue => detail
+ fail "Invalid source '%s': %s" % [uri, detail]
+ end
+
+ case uri.scheme
+ when nil:
# no URI scheme => interpret the source as a local file
command << source
- elsif scheme.downcase == "file"
- command << source.path
- elsif scheme.downcase == "puppet"
+ when /file/i
+ command << uri.path
+ when 'puppet'
# we don't support puppet:// URLs (yet)
raise Puppet::Error.new("puppet:// URLs are not supported as gem sources")
- else
+ else
# interpret it as a gem repository
- command << "--source" << "#{source}" << @resource[:name]
+ command << "--source" << "#{source}" << resource[:name]
end
else
- command << @resource[:name]
+ command << resource[:name]
end
output = execute(command)
@@ -103,17 +108,17 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
def latest
# This always gets the latest version available.
- hash = self.class.gemlist(:justme => @resource[:name])
+ hash = self.class.gemlist(:justme => resource[:name])
return hash[:ensure]
end
def query
- self.class.gemlist(:justme => @resource[:name], :local => true)
+ self.class.gemlist(:justme => resource[:name], :local => true)
end
def uninstall
- gemcmd "uninstall", "-x", "-a", @resource[:name]
+ gemcmd "uninstall", "-x", "-a", resource[:name]
end
def update