Sha256: 4472b168c6841c000e2772e4108bd6d89bc91639e54dc07b7fd4d7900e136e7c
Contents?: true
Size: 763 Bytes
Versions: 2
Compression:
Stored size: 763 Bytes
Contents
# frozen_string_literal: true module Spandx class CatalogueGateway URL = 'https://spdx.org/licenses/licenses.json' def initialize(http: default_client) @http = http end def fetch(url: URL) response = http.get(url) if response.code == '200' parse(response.body) else empty_catalogue end rescue *::Net::Hippie::CONNECTION_ERRORS empty_catalogue end private attr_reader :http def parse(json) build_catalogue(JSON.parse(json, symbolize_names: true)) end def empty_catalogue build_catalogue(licenses: []) end def build_catalogue(hash) Catalogue.new(hash) end def default_client Net::Hippie::Client.new end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spandx-0.1.1 | lib/spandx/catalogue_gateway.rb |
spandx-0.1.0 | lib/spandx/catalogue_gateway.rb |