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/
Avoid:
$ ./script/check-approval MIT
./script/check-approval:55:in `<main>': undefined local variable or method `license_ids' for main:Object (NameError)
The license_ids line was added in e505eb8f (check if license is aleady
a license, 2016-01-18, #318), but license_ids was removed from the
helper in b99e7ab0 (replace 'id' variables with 'spdx_lcase' to
minimize confusion, 2016-06-01, #424). This commit restores the old
code locally, since this script is the only consumer.
Ideally the FSF would be maintaining the API (or any API), but until
someone can talk them into that I think we can save work by
collaborating on the mock API. Using a JSON API also allows us to
drop the Nokogiri dependency.
The parens feel excessive, and I'm not familiar with Ruby, so they
might be. However, removing the parens from the libre check resulted
in:
$ ./script/check-approval ISC
./script/check-approval:8:in `require_relative': /.../choosealicense.com/spec/spec_helper.rb:108: syntax error, unexpected tSTRING_BEG, expecting keyword_then or ';' or '\n' (SyntaxError)
...gs') && meta['tags'].include? 'libre'
... ^
/.../choosealicense.com/spec/spec_helper.rb:116: syntax error, unexpected keyword_end, expecting end-of-input
from ./script/check-approval:8:in `<main>'
The previous case-insensitive matching was removed in e5f46faa (test
required spdx-ids against data from spdx, 2016-05-25, #418). That
commit was designed [1] to allow case-sensitive matching as discussed
in [2]. But while I'm in favor of case-sensitive keys in spdx_list,
the case-sensitive match breaks script/check-approval which downcases
its argument since it was added in 8e56bb83 (add
script/check-approval, 2016-01-18, #318).
There are more notes on SPDX's plans for case sensitivity in [3], so
we should see a clearer policy there soon. I'm arguing for
case-sensitive *display* with optional case-insensitive matching. I
am optimistic that the SPDX will at least agree not to register short
IDs that only differ by case, which is all we need to make this
case-insensitive match safe here.
[1]: https://github.com/github/choosealicense.com/pull/418#issuecomment-221404630
[2]: https://github.com/benbalter/licensee/issues/72
[3]: https://github.com/spdx/spdx-spec/issues/63