24 lines
601 B
Ruby
Raw Normal View History

2020-08-04 10:07:57 -07:00
# frozen_string_literal: true
require "utils/github"
module SPDX
module_function
JSON_PATH = (HOMEBREW_LIBRARY_PATH/"data/spdx.json").freeze
API_URL = "https://api.github.com/repos/spdx/license-list-data/releases/latest"
def spdx_data
@spdx_data ||= JSON.parse(JSON_PATH.read)
end
def latest_tag
@latest_tag ||= GitHub.open_api(API_URL)["tag_name"]
end
2020-08-06 11:12:43 -07:00
def download_latest_license_data!(to: JSON_PATH)
2020-08-04 10:07:57 -07:00
data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json"
2020-08-06 11:12:43 -07:00
curl_download(data_url, to: to, partial: false)
2020-08-04 10:07:57 -07:00
end
end