From 24fbf6685ddd05682f73bcea3d85477c696a56a2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 5 Jan 2018 16:18:59 -0800 Subject: [PATCH] spec_helper: Adjust to new 'licenses' key in the FSF API The old root object has been moved under 'licenses' with wking/fsf-api@8398a357 (pull: Add JSON-LD markup, 2018-01-04, wking/fsf-api#12) for better forward/backward compatibility. Unfortunately, this results in another one-time incompatible change, which this commit accommodates. The protection from future changes (which should be rare) isn't great, because we're still parsing the document as JSON. There is at least one JSON-LD parser for Ruby [1], but I've stuck with vanilla JSON to avoid pullling in an external dependency just for this rather peripheral functionality. [1]: https://github.com/ruby-rdf/json-ld/ --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1c309b1..4275e00 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -104,7 +104,7 @@ def fsf_approved_licenses url = 'https://wking.github.io/fsf-api/licenses-full.json' object = JSON.parse(OpenURI.open_uri(url).read) licenses = {} - object.each_value do |meta| + object['licenses'].each_value do |meta| next unless (meta.include? 'identifiers') && (meta['identifiers'].include? 'spdx') && (meta.include? 'tags') && (meta['tags'].include? 'libre') meta['identifiers']['spdx'].each do |identifier| licenses[identifier.downcase] = meta['name']