lib/librarian/puppet/source/forge.rb in librarian-puppet-0.9.0 vs lib/librarian/puppet/source/forge.rb in librarian-puppet-0.9.1

- old
+ new

@@ -19,10 +19,14 @@ self.name = name end def versions data = api_call("#{name}.json") + if data.nil? + raise Error, "Unable to find module '#{name}' on #{source}" + end + data['releases'].map { |r| r['version'] }.sort.reverse end def dependencies(version) data = api_call("api/v1/releases.json?module=#{name}&version=#{version}") @@ -77,12 +81,15 @@ private def api_call(path) base_url = source.to_s resp = Net::HTTP.get_response(URI.parse("#{base_url}/#{path}")) - data = resp.body - - JSON.parse(data) + if resp.code.to_i != 200 + nil + else + data = resp.body + JSON.parse(data) + end end end class << self LOCK_NAME = 'FORGE'