inspec/tasks/spdx.rb
pete higgins 89e30f8d31 Reduce warnings (#1917)
* Remove some apparently unused test setup to remove some warnings.
* Initialize some instance variables before use to silence warnings.
* Remove an unused variable to remove a warning.
* Remove some indirection.
* Silence logger during tests.
* Check if an instance variable was defined before referencing to remove a warning.
* Define duplicated constant once in root rakefile.
* Initialize an instance variable to remove a warning.
* Remove PROJECT_DIR to reduce coupling.

Signed-off-by: Pete Higgins <pete@peterhiggins.org>
2017-06-15 12:10:47 -04:00

32 lines
1.4 KiB
Ruby

# encoding: utf-8
# Copyright:: Copyright (c) 2017 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
UTILS_DIR = File.expand_path(File.join(__dir__, '..', 'lib/utils')).freeze
desc 'Updates the list of the spdx valid licenses'
task :spdx do
# Kudos to Foodcritic for providing that idea
# @see https://github.com/Foodcritic/foodcritic/pull/530/files
# list of valid SPDX.org license strings. To build an array run this:
require 'json'
require 'net/http'
json_data = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json')))
licenses = json_data['licenses'].map { |l| l['licenseId'] }
# "All Rights Reserved" is non-standard extra value to cover proriatary license
licenses.push('All Rights Reserved')
File.write(File.join(UTILS_DIR, 'spdx.txt'), licenses.join("\n"))
end