licensee 8.6.1 → 8.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/licensee.rb +1 -0
- data/lib/licensee/license.rb +13 -0
- data/lib/licensee/project.rb +1 -1
- data/lib/licensee/project_files/readme.rb +11 -1
- data/lib/licensee/projects/fs_project.rb +10 -13
- data/lib/licensee/rule.rb +48 -0
- data/lib/licensee/version.rb +1 -1
- data/spec/licensee/license_spec.rb +6 -0
- data/spec/licensee/project_files/readme_spec.rb +24 -0
- data/spec/licensee/rule.rb +45 -0
- data/vendor/choosealicense.com/_data/fields.yml +23 -0
- data/vendor/choosealicense.com/_data/meta.yml +60 -0
- data/vendor/choosealicense.com/_data/rules.yml +44 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 409f633d4be23f1510209f7829bec582d72bf880
|
4
|
+
data.tar.gz: 9e047e3ba7a0d209653bdb0121137c825aed9b28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bc05051d0b12c781e5d3b4df6f3ab9370117eaec627a4419ac555830c36c8b9f02a0f9c5b57dbd932b561d2d30aac20fa9fade0f4e072704cf08a0a573d6d5f
|
7
|
+
data.tar.gz: a1fa2e528dde49d623c14aafa69b2ae58b44e15caba9ed98ce46115f4f8d1bdbe0ece6600fafe7cb49f413c760fed77f001c5d537e1b06824047c02fcfd1c35c
|
data/lib/licensee.rb
CHANGED
data/lib/licensee/license.rb
CHANGED
@@ -135,6 +135,19 @@ module Licensee
|
|
135
135
|
PSEUDO_LICENSES.include?(key)
|
136
136
|
end
|
137
137
|
|
138
|
+
# Returns a hash in the form of rule_group => rules describing
|
139
|
+
# what you legally can and can't do with the given license
|
140
|
+
def rules
|
141
|
+
return @rules if defined? @rules
|
142
|
+
@rules = {}
|
143
|
+
|
144
|
+
Rule.groups.each do |group|
|
145
|
+
@rules[group] = meta[group].map { |tag| Rule.find_by_tag(tag) }
|
146
|
+
end
|
147
|
+
|
148
|
+
@rules
|
149
|
+
end
|
150
|
+
|
138
151
|
def inspect
|
139
152
|
"#<Licensee::License key=#{key}>"
|
140
153
|
end
|
data/lib/licensee/project.rb
CHANGED
@@ -26,7 +26,7 @@ module Licensee
|
|
26
26
|
license_file = license_from_file { |n| LicenseFile.name_score(n) }
|
27
27
|
return license_file unless license_file && license_file.license
|
28
28
|
|
29
|
-
# Special case LGPL, which
|
29
|
+
# Special case LGPL, which actually lives in LICENSE.lesser, per the
|
30
30
|
# license instructions. See https://git.io/viwyK
|
31
31
|
lesser = if license_file.license.gpl?
|
32
32
|
license_from_file { |file| LicenseFile.lesser_gpl_score(file) }
|
@@ -6,7 +6,17 @@ module Licensee
|
|
6
6
|
/\AREADME\.(md|markdown|mdown|txt)\z/i => 0.9
|
7
7
|
}.freeze
|
8
8
|
|
9
|
-
CONTENT_REGEX =
|
9
|
+
CONTENT_REGEX = /^
|
10
|
+
(?:\#+\sLicen[sc]e # Start of hashes-based license header
|
11
|
+
|
|
12
|
+
Licen[sc]e\n[-=]+)$ # Start of underlined license header
|
13
|
+
(.*?) # License content
|
14
|
+
(?=^(?:\#+ # Next hashes-based header
|
15
|
+
|
|
16
|
+
[^\n]+\n[-=]+) # Next of underlined header
|
17
|
+
|
|
18
|
+
\z) # End of file
|
19
|
+
/mix
|
10
20
|
|
11
21
|
def self.name_score(filename)
|
12
22
|
SCORES.each do |pattern, score|
|
@@ -3,10 +3,14 @@
|
|
3
3
|
# Analyze a folder on the filesystem for license information
|
4
4
|
module Licensee
|
5
5
|
class FSProject < Project
|
6
|
-
attr_reader :path
|
7
|
-
|
8
6
|
def initialize(path, **args)
|
9
|
-
|
7
|
+
if ::File.file?(path)
|
8
|
+
@pattern = ::File.basename(path)
|
9
|
+
@dir = ::File.dirname(path)
|
10
|
+
else
|
11
|
+
@pattern = '*'
|
12
|
+
@dir = path
|
13
|
+
end
|
10
14
|
super(**args)
|
11
15
|
end
|
12
16
|
|
@@ -17,14 +21,7 @@ module Licensee
|
|
17
21
|
def files
|
18
22
|
files = []
|
19
23
|
|
20
|
-
|
21
|
-
pattern = ::File.basename(path)
|
22
|
-
@path = ::File.dirname(path)
|
23
|
-
else
|
24
|
-
pattern = '*'
|
25
|
-
end
|
26
|
-
|
27
|
-
Dir.glob(::File.join(path, pattern)) do |file|
|
24
|
+
Dir.glob(::File.join(@dir, @pattern).tr('\\', '/')) do |file|
|
28
25
|
next unless ::File.file?(file)
|
29
26
|
files.push(name: ::File.basename(file))
|
30
27
|
end
|
@@ -36,9 +33,9 @@ module Licensee
|
|
36
33
|
#
|
37
34
|
# file - the file hash, with the :name key as the file's relative path
|
38
35
|
#
|
39
|
-
# Returns the
|
36
|
+
# Returns the file contents as a string
|
40
37
|
def load_file(file)
|
41
|
-
::File.read(::File.join(
|
38
|
+
::File.read(::File.join(@dir, file[:name]))
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Licensee
|
2
|
+
class Rule
|
3
|
+
attr_reader :tag, :label, :description, :group
|
4
|
+
|
5
|
+
def initialize(tag: nil, label: nil, description: nil, group: nil)
|
6
|
+
@tag = tag
|
7
|
+
@label = label
|
8
|
+
@description = description
|
9
|
+
@group = group
|
10
|
+
end
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
"#<Licensee::Rule @tag=\"#{tag}\">"
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def all
|
18
|
+
@all ||= raw_rules.map do |group, rules|
|
19
|
+
rules.map do |rule|
|
20
|
+
Rule.new(
|
21
|
+
tag: rule['tag'],
|
22
|
+
label: rule['label'],
|
23
|
+
description: rule['description'],
|
24
|
+
group: group
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end.flatten
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_by_tag(tag)
|
31
|
+
Rule.all.find { |r| r.tag == tag }
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_path
|
35
|
+
dir = File.dirname(__FILE__)
|
36
|
+
File.expand_path '../../vendor/choosealicense.com/_data/rules.yml', dir
|
37
|
+
end
|
38
|
+
|
39
|
+
def raw_rules
|
40
|
+
YAML.load File.read(Rule.file_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
def groups
|
44
|
+
Rule.raw_rules.keys
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/licensee/version.rb
CHANGED
@@ -221,4 +221,10 @@ RSpec.describe Licensee::License do
|
|
221
221
|
described_class.new('foo').name
|
222
222
|
end.to raise_error(Licensee::InvalidLicense)
|
223
223
|
end
|
224
|
+
|
225
|
+
it 'returns the rules' do
|
226
|
+
expect(mit.rules).to have_key('permissions')
|
227
|
+
expect(mit.rules['permissions'].first).to be_a(Licensee::Rule)
|
228
|
+
expect(mit.rules.flatten.count).to eql(6)
|
229
|
+
end
|
224
230
|
end
|
@@ -50,6 +50,14 @@ RSpec.describe Licensee::Project::Readme do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
context 'after an underlined header' do
|
54
|
+
let(:content) { "License\n-------\n\nhello world" }
|
55
|
+
|
56
|
+
it 'returns the license' do
|
57
|
+
expect(license).to eql('hello world')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
53
61
|
context 'With a strangely cased heading' do
|
54
62
|
let(:content) { "## LICENSE\n\nhello world" }
|
55
63
|
|
@@ -73,5 +81,21 @@ RSpec.describe Licensee::Project::Readme do
|
|
73
81
|
expect(license).to eql('hello world')
|
74
82
|
end
|
75
83
|
end
|
84
|
+
|
85
|
+
context 'with trailing content that has an underlined header' do
|
86
|
+
let(:content) { "# License\n\nhello world\n\nContributing\n====" }
|
87
|
+
|
88
|
+
it 'returns the license' do
|
89
|
+
expect(license).to eql('hello world')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with trailing content that has a hashes-based header' do
|
94
|
+
let(:content) { "# License\n\nhello world\n\n# Contributing" }
|
95
|
+
|
96
|
+
it 'returns the license' do
|
97
|
+
expect(license).to eql('hello world')
|
98
|
+
end
|
99
|
+
end
|
76
100
|
end
|
77
101
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
RSpec.describe Licensee::Rule do
|
2
|
+
let(:groups) { %w(permissions conditions limitations) }
|
3
|
+
|
4
|
+
it 'stores the properties' do
|
5
|
+
rule = described_class.new(
|
6
|
+
tag: 'tag',
|
7
|
+
label: 'label',
|
8
|
+
description: 'description',
|
9
|
+
group: 'group'
|
10
|
+
)
|
11
|
+
|
12
|
+
expect(rule.tag).to eql('tag')
|
13
|
+
expect(rule.label).to eql('label')
|
14
|
+
expect(rule.description).to eql('description')
|
15
|
+
expect(rule.group).to eql('group')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'loads the groups' do
|
19
|
+
expect(described_class.groups).to eql(groups)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'loads the raw rules' do
|
23
|
+
groups.each do |key|
|
24
|
+
expect(described_class.raw_rules).to have_key(key)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'determines the file path' do
|
29
|
+
path = described_class.file_path
|
30
|
+
expect(File.exist?(path)).to eql(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'loads a rule by tag' do
|
34
|
+
rule = described_class.find_by_tag('commercial-use')
|
35
|
+
expect(rule).to be_a(described_class)
|
36
|
+
expect(rule.tag).to eql('commercial-use')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'loads all rules' do
|
40
|
+
expect(described_class.all.count).to eql(13)
|
41
|
+
rule = described_class.all.first
|
42
|
+
expect(rule).to be_a(described_class)
|
43
|
+
expect(rule.tag).to eql('commercial-use')
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# The licenses on choosealicense.com are regularly imported to GitHub.com to
|
2
|
+
# be used as the list of licenses available when creating a repository. When
|
3
|
+
# we create a repository, we will replace certain strings in the license with
|
4
|
+
# variables from the repository. These can be used to create accurate copyright
|
5
|
+
# notices. The available variables are:
|
6
|
+
|
7
|
+
- name: fullname
|
8
|
+
description: The full name or username of the repository owner
|
9
|
+
|
10
|
+
- name: login
|
11
|
+
description: The repository owner's username
|
12
|
+
|
13
|
+
- name: email
|
14
|
+
description: The repository owner's primary email address
|
15
|
+
|
16
|
+
- name: project
|
17
|
+
description: The repository name
|
18
|
+
|
19
|
+
- name: description
|
20
|
+
description: The description of the repository
|
21
|
+
|
22
|
+
- name: year
|
23
|
+
description: The current year
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Each license has YAML front matter describing the license's properties.
|
2
|
+
# The available fields are:
|
3
|
+
|
4
|
+
- name: title
|
5
|
+
description: The license full name specified by http://spdx.org/licenses/
|
6
|
+
required: true
|
7
|
+
|
8
|
+
- name: spdx-id
|
9
|
+
description: Short identifier specified by http://spdx.org/licenses/
|
10
|
+
required: required
|
11
|
+
|
12
|
+
- name: source
|
13
|
+
description: The URL to the license source text
|
14
|
+
required: true
|
15
|
+
|
16
|
+
- name: description
|
17
|
+
description: A human-readable description of the license
|
18
|
+
required: true
|
19
|
+
|
20
|
+
- name: how
|
21
|
+
description: Instructions on how to implement the license
|
22
|
+
required: true
|
23
|
+
|
24
|
+
- name: conditions
|
25
|
+
description: Bulleted list of required rules
|
26
|
+
required: true
|
27
|
+
|
28
|
+
- name: permissions
|
29
|
+
description: Bulleted list of permitted rules
|
30
|
+
required: true
|
31
|
+
|
32
|
+
- name: limitations
|
33
|
+
description: Bulleted list of limited rules
|
34
|
+
required: true
|
35
|
+
|
36
|
+
# Optional fields
|
37
|
+
|
38
|
+
- name: featured
|
39
|
+
description: Whether the license should be featured on the main page (defaults to false)
|
40
|
+
required: false
|
41
|
+
|
42
|
+
- name: hidden
|
43
|
+
description: Whether the license is hidden from the license list (defaults to true)
|
44
|
+
required: false
|
45
|
+
|
46
|
+
- name: nickname
|
47
|
+
description: Customary short name if applicable (e.g, GPLv3)
|
48
|
+
required: false
|
49
|
+
|
50
|
+
- name: note
|
51
|
+
description: Additional information about the licenses
|
52
|
+
required: false
|
53
|
+
|
54
|
+
- name: using
|
55
|
+
description: 'A list of up to 3 notable projects using the license with straightforward LICENSE files which serve as examples newcomers can follow and that can be detected by [licensee](https://github.com/benbalter/licensee) in the form of `project_name: license_file_url`'
|
56
|
+
required: false
|
57
|
+
|
58
|
+
- name: redirect_from
|
59
|
+
description: Relative path(s) to redirect to the license from, to prevent breaking old URLs
|
60
|
+
required: false
|
@@ -0,0 +1,44 @@
|
|
1
|
+
permissions:
|
2
|
+
- description: This software and derivatives may be used for commercial purposes.
|
3
|
+
label: Commercial Use
|
4
|
+
tag: commercial-use
|
5
|
+
- description: This software may be modified.
|
6
|
+
label: Modification
|
7
|
+
tag: modifications
|
8
|
+
- description: You may distribute this software.
|
9
|
+
label: Distribution
|
10
|
+
tag: distribution
|
11
|
+
- description: You may use and modify the software without distributing it.
|
12
|
+
label: Private Use
|
13
|
+
tag: private-use
|
14
|
+
- description: This license provides an express grant of patent rights from the contributor to the recipient.
|
15
|
+
label: Patent Use
|
16
|
+
tag: patent-use
|
17
|
+
|
18
|
+
conditions:
|
19
|
+
- description: Include a copy of the license and copyright notice with the code.
|
20
|
+
label: License and Copyright Notice
|
21
|
+
tag: include-copyright
|
22
|
+
- description: Indicate changes made to the code.
|
23
|
+
label: State Changes
|
24
|
+
tag: document-changes
|
25
|
+
- description: Source code must be made available when distributing the software.
|
26
|
+
label: Disclose Source
|
27
|
+
tag: disclose-source
|
28
|
+
- description: Users who interact with the software via network are given the right to receive a copy of the corresponding source code.
|
29
|
+
label: Network Use is Distribution
|
30
|
+
tag: network-use-disclose
|
31
|
+
- description: Modifications must be released under the same license when distributing the software. In some cases a similar or related license may be used.
|
32
|
+
label: Same License
|
33
|
+
tag: same-license
|
34
|
+
|
35
|
+
limitations:
|
36
|
+
- description: This license explicitly states that it does NOT grant you trademark rights, even though licenses without such a statement probably do not grant you any implicit trademark rights.
|
37
|
+
label: Trademark Use
|
38
|
+
tag: trademark-use
|
39
|
+
- description: Software is provided without warranty and the software author/license owner cannot be held liable for damages.
|
40
|
+
label: Hold Liable
|
41
|
+
tag: no-liability
|
42
|
+
- description: This license explicitly states that it does NOT grant you any rights in the patents of contributors.
|
43
|
+
label: Patent Use
|
44
|
+
tag: patent-use
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: licensee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/licensee/project_files/readme.rb
|
124
124
|
- lib/licensee/projects/fs_project.rb
|
125
125
|
- lib/licensee/projects/git_project.rb
|
126
|
+
- lib/licensee/rule.rb
|
126
127
|
- lib/licensee/version.rb
|
127
128
|
- spec/bin_spec.rb
|
128
129
|
- spec/fixtures/case-sensitive/LiCeNsE.TxT
|
@@ -148,10 +149,14 @@ files:
|
|
148
149
|
- spec/licensee/project_files/package_info_spec.rb
|
149
150
|
- spec/licensee/project_files/readme_spec.rb
|
150
151
|
- spec/licensee/project_spec.rb
|
152
|
+
- spec/licensee/rule.rb
|
151
153
|
- spec/licensee_spec.rb
|
152
154
|
- spec/project_file_spec.rb
|
153
155
|
- spec/spec_helper.rb
|
154
156
|
- spec/vendored_license_spec.rb
|
157
|
+
- vendor/choosealicense.com/_data/fields.yml
|
158
|
+
- vendor/choosealicense.com/_data/meta.yml
|
159
|
+
- vendor/choosealicense.com/_data/rules.yml
|
155
160
|
- vendor/choosealicense.com/_licenses/afl-3.0.txt
|
156
161
|
- vendor/choosealicense.com/_licenses/agpl-3.0.txt
|
157
162
|
- vendor/choosealicense.com/_licenses/apache-2.0.txt
|
@@ -200,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
205
|
version: '0'
|
201
206
|
requirements: []
|
202
207
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.6.
|
208
|
+
rubygems_version: 2.6.8
|
204
209
|
signing_key:
|
205
210
|
specification_version: 4
|
206
211
|
summary: A Ruby Gem to detect open source project licenses
|