File: Rakefile

package info (click to toggle)
ruby-spdx-licenses 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 268 kB
  • sloc: ruby: 87; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 777 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'json'
require 'net/https'
require 'rake/testtask'

task :download do
  LICENSES_URI = URI.parse('https://spdx.org/licenses/licenses.json')

  http = Net::HTTP.new(LICENSES_URI.host, LICENSES_URI.port)
  if LICENSES_URI.scheme == 'https'
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end

  response = http.request_get(LICENSES_URI.path)
  raise "Downloading the licenses file failed: #{response.message}." unless response.is_a?(Net::HTTPOK)

  string = response.body.force_encoding('UTF-8')
  File.open('licenses.json', 'w') do |file|
    file.puts(JSON.pretty_generate(JSON.parse(string)))
  end
end

Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['test/*test.rb']
  t.verbose = true
end

task :default => [:test]