vendored/puppet/lib/puppet/forge.rb in bolt-0.20.3 vs vendored/puppet/lib/puppet/forge.rb in bolt-0.20.5

- old
+ new

@@ -3,11 +3,11 @@ require 'net/http' require 'tempfile' require 'uri' require 'pathname' -require 'json' +require 'puppet/util/json' require 'semantic_puppet' class Puppet::Forge < SemanticPuppet::Dependency::Source require 'puppet/forge/cache' require 'puppet/forge/repository' @@ -17,14 +17,13 @@ USER_AGENT = "PMT/1.1.1 (v3; Net::HTTP)".freeze attr_reader :host, :repository - def initialize(host = Puppet[:module_repository], strict_semver = true) + def initialize(host = Puppet[:module_repository]) @host = host @repository = Puppet::Forge::Repository.new(host, USER_AGENT) - @strict_semver = strict_semver end # Return a list of module metadata hashes that match the search query. # This return value is used by the module_tool face install search, # and displayed to on the console. @@ -62,11 +61,11 @@ while uri # make_http_request URI encodes parameters response = make_http_request(uri) if response.code == '200' - result = JSON.parse(response.body) + result = Puppet::Util::Json.load(response.body) uri = decode_uri(result['pagination']['next']) matches.concat result['results'] else raise ResponseError.new(:uri => URI.parse(@host).merge(uri), :response => response) end @@ -99,11 +98,11 @@ while uri # make_http_request URI encodes parameters response = make_http_request(uri) if response.code == '200' - response = JSON.parse(response.body) + response = Puppet::Util::Json.load(response.body) else raise ResponseError.new(:uri => URI.parse(@host).merge(uri), :response => response) end releases.concat(process(response['results'])) @@ -118,11 +117,11 @@ end class ModuleRelease < SemanticPuppet::Dependency::ModuleRelease attr_reader :install_dir, :metadata - def initialize(source, data, strict_semver = true) + def initialize(source, data) @data = data @metadata = meta = data['metadata'] name = meta['name'].tr('/', '-') version = SemanticPuppet::Version.parse(meta['version']) @@ -130,11 +129,11 @@ if meta['dependencies'] dependencies = meta['dependencies'].collect do |dep| begin Puppet::ModuleTool::Metadata.new.add_dependency(dep['name'], dep['version_requirement'], dep['repository']) - Puppet::ModuleTool.parse_module_dependency(release, dep, strict_semver)[0..1] + Puppet::ModuleTool.parse_module_dependency(release, dep)[0..1] rescue ArgumentError => e raise ArgumentError, _("Malformed dependency: %{name}.") % { name: dep['name'] } + ' ' + _("Exception was: %{detail}") % { detail: e } end end @@ -222,10 +221,10 @@ def process(list) l = list.map do |release| metadata = release['metadata'] begin - ModuleRelease.new(self, release, @strict_semver) + ModuleRelease.new(self, release) rescue ArgumentError => e Puppet.warning _("Cannot consider release %{name}-%{version}: %{error}") % { name: metadata['name'], version: metadata['version'], error: e } false end end