70: def install(useversion = true)
71: command = [command(:gemcmd), "install"]
72: command << "-v" << resource[:ensure] if (! resource[:ensure].is_a? Symbol) and useversion
73:
74: command << "--include-dependencies"
75:
76: if source = resource[:source]
77: begin
78: uri = URI.parse(source)
79: rescue => detail
80: fail "Invalid source '#{uri}': #{detail}"
81: end
82:
83: case uri.scheme
84: when nil
85:
86: command << source
87: when /file/i
88: command << uri.path
89: when 'puppet'
90:
91: raise Puppet::Error.new("puppet:// URLs are not supported as gem sources")
92: else
93:
94: command << "--source" << "#{source}" << resource[:name]
95: end
96: else
97: command << resource[:name]
98: end
99:
100: output = execute(command)
101:
102: self.fail "Could not install: #{output.chomp}" if output.include?("ERROR")
103: end