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