2011-12-07 22:59:34 +00:00
|
|
|
Puppet::Type.type(:gem).provide(:install) do
|
|
|
|
desc "Install a Ruby Gem"
|
|
|
|
|
|
|
|
def create
|
2012-01-18 17:29:05 +00:00
|
|
|
system gem_command('install --no-ri --no-rdoc')
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
system gem_command('uninstall -x -I')
|
|
|
|
end
|
|
|
|
|
|
|
|
def exists?
|
|
|
|
system gem_command('list -i')
|
|
|
|
$?.exitstatus == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def version
|
|
|
|
version = ''
|
|
|
|
if @resource[:version] && !@resource[:version].empty?
|
|
|
|
version = " -v #{@resource[:version]}"
|
|
|
|
end
|
2012-02-12 23:42:29 +00:00
|
|
|
|
2011-12-07 22:59:34 +00:00
|
|
|
version
|
|
|
|
end
|
|
|
|
|
2012-02-12 23:42:29 +00:00
|
|
|
def options
|
|
|
|
options = ''
|
|
|
|
|
|
|
|
if @resource[:options] && !@resource[:options].empty?
|
|
|
|
options = " #{@resource[:options]}"
|
|
|
|
end
|
|
|
|
|
|
|
|
options
|
|
|
|
end
|
|
|
|
|
2011-12-07 22:59:34 +00:00
|
|
|
def gem_command(what)
|
2012-04-30 16:02:19 +00:00
|
|
|
%{bash -c 'PATH=#{@resource[:path]} gem #{what} #{@resource[:name]} #{options} #{version}'}
|
2011-12-07 22:59:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|