Seeker f345f554c8 update-license-data: fix latest_tag error
Add latest_tag method to utils/spdx
2020-08-10 11:32:07 -07:00

24 lines
601 B
Ruby

# 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
def download_latest_license_data!(to: JSON_PATH)
data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json"
curl_download(data_url, to: to, partial: false)
end
end