mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 12:50:24 +01:00
23 lines
679 B
Ruby
Executable File
23 lines
679 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
require 'jekyll'
|
|
require 'open-uri'
|
|
|
|
site_path = File.expand_path("../", File.dirname(__FILE__))
|
|
config = Jekyll.configuration("source" => site_path)
|
|
site = Jekyll::Site.new(config)
|
|
site.read
|
|
site.collections['licenses'].docs.each do |license|
|
|
puts "Updating the #{license.data["title"]}..."
|
|
uri = "https://spdx.org/licenses/#{license.data["spdx-id"]}.json"
|
|
data = JSON.parse open(uri).read
|
|
|
|
raw_content = File.read(license.path)
|
|
matches = raw_content.match Jekyll::Document::YAML_FRONT_MATTER_REGEXP
|
|
|
|
output = matches[1]
|
|
output << "---\n\n"
|
|
output << data["standardLicenseTemplate"].gsub(/ +\n/, "\n")
|
|
|
|
File.write(license.path, output)
|
|
end
|