diff options
Diffstat (limited to 'lib/license/management/repository.rb')
| -rw-r--r-- | lib/license/management/repository.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/license/management/repository.rb b/lib/license/management/repository.rb index 164653c..0c428dd 100644 --- a/lib/license/management/repository.rb +++ b/lib/license/management/repository.rb @@ -14,24 +14,18 @@ module License @spdx_data = load_spdx_data_from(spdx_path) end - def item_for(license, spdx: true) - if spdx - item = spdx_data_for(license) - return item if item - end - - id = id_for(license) - item = id ? compatibility_data['licenses'][id] : nil - item ? { 'id' => id }.merge(item) : generate_item_for(license) + def item_for(license) + spdx_data_for(id_for(license)) || + spdx_data_for(license.send(:short_name)) || + generate_item_for(license) end private attr_reader :spdx_data, :compatibility_data - def spdx_data_for(license) - id = id_for(license) - data = id ? spdx_data[id] : spdx_data[license.send(:short_name)] + def spdx_data_for(id) + data = spdx_data[id] if data { 'id' => data['licenseId'], @@ -39,7 +33,7 @@ module License 'url' => data['seeAlso'][-1] } else - log_info("could not find license named `#{license.send(:short_name)}` in SPDX index") + log_info("Could not find license `#{id}` in SPDX") nil end end |
