mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 12:50:24 +01:00
add script/check-approval
This commit is contained in:
parent
7a32aad01b
commit
8e56bb8315
5
Gemfile
5
Gemfile
@ -3,6 +3,11 @@ source "https://rubygems.org"
|
|||||||
gem "github-pages"
|
gem "github-pages"
|
||||||
gem "jekyll-seo-tag"
|
gem "jekyll-seo-tag"
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
gem 'colored'
|
||||||
|
gem 'terminal-table'
|
||||||
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'html-proofer', '2.5.2'
|
gem 'html-proofer', '2.5.2'
|
||||||
gem "rake"
|
gem "rake"
|
||||||
|
@ -166,12 +166,14 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
colored
|
||||||
github-pages
|
github-pages
|
||||||
html-proofer (= 2.5.2)
|
html-proofer (= 2.5.2)
|
||||||
jekyll-seo-tag
|
jekyll-seo-tag
|
||||||
nokogiri
|
nokogiri
|
||||||
rake
|
rake
|
||||||
rspec
|
rspec
|
||||||
|
terminal-table
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.11.2
|
1.11.2
|
||||||
|
56
script/check-approval
Executable file
56
script/check-approval
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# Checks if a given license meets the approval criteria to be added to choosealicense.com
|
||||||
|
# See https://github.com/github/choosealicense.com/blob/gh-pages/CONTRIBUTING.md#adding-a-license
|
||||||
|
# Usage: script/check-approval [SPDX LICENSE ID]
|
||||||
|
|
||||||
|
require_relative '../spec/spec_helper'
|
||||||
|
require 'terminal-table'
|
||||||
|
require 'colored'
|
||||||
|
|
||||||
|
# Display usage instructions
|
||||||
|
if ARGV.count != 1
|
||||||
|
puts File.open(__FILE__).read.scan(/^# .*/)[0...3].join("\n").gsub(/^# /,"")
|
||||||
|
end
|
||||||
|
|
||||||
|
class TrueClass
|
||||||
|
def to_s
|
||||||
|
"Yes".green
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class FalseClass
|
||||||
|
def to_s
|
||||||
|
"No".red
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
license = ARGV[0].downcase.strip
|
||||||
|
approvals = {
|
||||||
|
"OSI": osi_approved_licenses,
|
||||||
|
"FSF": fsf_approved_licenses,
|
||||||
|
"OD": od_approved_licenses
|
||||||
|
}
|
||||||
|
|
||||||
|
id, spdx = find_spdx(license)
|
||||||
|
rows = []
|
||||||
|
|
||||||
|
if spdx.nil?
|
||||||
|
id = "Invalid".red
|
||||||
|
name = "None".red
|
||||||
|
else
|
||||||
|
id = id.green
|
||||||
|
name = spdx["name"].green
|
||||||
|
end
|
||||||
|
|
||||||
|
rows << ["SPDX ID", id]
|
||||||
|
rows << ["SPDX Name", name]
|
||||||
|
|
||||||
|
approvals.each do |name, licenses|
|
||||||
|
rows << ["#{name} approved", licenses.include?(license)]
|
||||||
|
end
|
||||||
|
|
||||||
|
rows << :separator
|
||||||
|
elligible = !!(spdx && approved_licenses.include?(license))
|
||||||
|
rows << ["Elligible", elligible]
|
||||||
|
|
||||||
|
puts Terminal::Table.new title: "License: #{license}", rows: rows
|
Loading…
x
Reference in New Issue
Block a user