Sha256: 53551245196038e43862a12277007342e66e99cd85d8546da7d656f895879d89

Contents?: true

Size: 454 Bytes

Versions: 4

Compression:

Stored size: 454 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Gateways
    class Spdx
      URL = 'https://spdx.org/licenses/licenses.json'

      def fetch(url: URL, http: Spandx.http, default: Catalogue.empty)
        response = http.get(url, default: default)
        http.ok?(response) ? parse(response.body) : default
      end

      private

      def parse(json)
        Catalogue.new(JSON.parse(json, symbolize_names: true))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spandx-0.1.5 lib/spandx/gateways/spdx.rb
spandx-0.1.4 lib/spandx/gateways/spdx.rb
spandx-0.1.3 lib/spandx/gateways/spdx.rb
spandx-0.1.2 lib/spandx/gateways/spdx.rb