licensee 5.0.0b1 → 5.0.0b2
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 +2 -2
- data/lib/licensee/license.rb +10 -3
- data/lib/licensee/matchers/exact_matcher.rb +1 -1
- data/lib/licensee/matchers/git_matcher.rb +1 -1
- data/lib/licensee/matchers/levenshtein_matcher.rb +1 -1
- data/lib/licensee/matchers/package_matcher.rb +1 -1
- data/lib/licensee/project.rb +2 -1
- data/lib/licensee/version.rb +1 -1
- data/test/test_licensee.rb +2 -1
- data/test/test_licensee_license.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9275866e83088fd301ad334a09190133d210c398
|
4
|
+
data.tar.gz: d679bb4b0813cbd065b49abd05fe5256f2a551af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff54bc4e9472afd1230c41119ce5c450a1a63e43b49c7312e610bee3b0aaadb2b3aa2e426339d8238f7b02a4d14f43dc392d414c7432d4a665dbc260332aee4
|
7
|
+
data.tar.gz: ca076a720d1e9962df28e24641ce7f7337fee22ac838da9f5b66cda1fa440d1e8224b9e3804530e5a0dafd8ed399dc69143c251bf664c7751408b005c9a4d591
|
data/lib/licensee.rb
CHANGED
@@ -30,8 +30,8 @@ class Licensee
|
|
30
30
|
attr_writer :confidence_threshold, :package_manager_files
|
31
31
|
|
32
32
|
# Returns an array of Licensee::License instances
|
33
|
-
def licenses
|
34
|
-
|
33
|
+
def licenses(options={})
|
34
|
+
Licensee::License.all(options)
|
35
35
|
end
|
36
36
|
|
37
37
|
# Returns the license for a given git repo
|
data/lib/licensee/license.rb
CHANGED
@@ -3,19 +3,22 @@ class Licensee
|
|
3
3
|
class License
|
4
4
|
|
5
5
|
class << self
|
6
|
-
def all
|
6
|
+
def all(options={})
|
7
7
|
@all ||= keys.map { |key| self.new(key) }
|
8
|
+
options[:hidden] ? @all : @all.reject { |l| l.hidden? }
|
8
9
|
end
|
9
10
|
|
10
11
|
def keys
|
11
12
|
@keys ||= license_files.map { |l| File.basename(l, ".txt").downcase }
|
12
13
|
end
|
13
14
|
|
14
|
-
def find(key)
|
15
|
+
def find(key, options={})
|
16
|
+
options = {:hidden => true}.merge(options)
|
15
17
|
key = key.downcase
|
16
|
-
all.find { |
|
18
|
+
all(options).find { |license| license.key == key }
|
17
19
|
end
|
18
20
|
alias_method :[], :find
|
21
|
+
alias_method :find_by_key, :find
|
19
22
|
|
20
23
|
def license_dir
|
21
24
|
File.expand_path "../../vendor/choosealicense.com/_licenses", File.dirname(__FILE__)
|
@@ -111,6 +114,10 @@ class Licensee
|
|
111
114
|
URI.join(Licensee::DOMAIN, "/licenses/#{key}/").to_s
|
112
115
|
end
|
113
116
|
|
117
|
+
def ==(other)
|
118
|
+
key == other.key
|
119
|
+
end
|
120
|
+
|
114
121
|
private
|
115
122
|
|
116
123
|
def parts
|
@@ -12,7 +12,7 @@ class Licensee
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def matches
|
15
|
-
@matches ||= Licensee.licenses.map { |l| [l, file.similarity(l)] }.select { |l,sim| sim > 0 }
|
15
|
+
@matches ||= Licensee.licenses(:hidden => true).map { |l| [l, file.similarity(l)] }.select { |l,sim| sim > 0 }
|
16
16
|
end
|
17
17
|
|
18
18
|
# Pulled out for easier testing
|
@@ -12,7 +12,7 @@ class Licensee
|
|
12
12
|
# Difference in lengths cannot exceed the file's length * the confidence threshold / 100
|
13
13
|
def potential_licenses
|
14
14
|
@potential_licenses ||= begin
|
15
|
-
Licensee.licenses.select { |license| length_delta(license) <= max_delta }.sort_by { |l| length_delta(l) }
|
15
|
+
Licensee.licenses(:hidden => true).select { |license| length_delta(license) <= max_delta }.sort_by { |l| length_delta(l) }
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/lib/licensee/project.rb
CHANGED
data/lib/licensee/version.rb
CHANGED
data/test/test_licensee.rb
CHANGED
@@ -3,7 +3,8 @@ require 'helper'
|
|
3
3
|
class TestLicensee < Minitest::Test
|
4
4
|
should "know the licenses" do
|
5
5
|
assert_equal Array, Licensee.licenses.class
|
6
|
-
assert_equal
|
6
|
+
assert_equal 15, Licensee.licenses.size
|
7
|
+
assert_equal 19, Licensee.licenses(:hidden => true).size
|
7
8
|
assert_equal Licensee::License, Licensee.licenses.first.class
|
8
9
|
end
|
9
10
|
|
@@ -34,6 +34,11 @@ class TestLicenseeLicense < Minitest::Test
|
|
34
34
|
assert_equal "mit", @license.key
|
35
35
|
end
|
36
36
|
|
37
|
+
should "know license equality" do
|
38
|
+
assert @license == Licensee::License.new("MIT")
|
39
|
+
refute @license == Licensee::License.new("ISC")
|
40
|
+
end
|
41
|
+
|
37
42
|
should "know if the license is featured" do
|
38
43
|
assert @license.featured?
|
39
44
|
assert_equal TrueClass, @license.featured?.class
|
@@ -58,7 +63,6 @@ class TestLicenseeLicense < Minitest::Test
|
|
58
63
|
refute @license.hidden?
|
59
64
|
assert Licensee::License.new("ofl-1.1").hidden?
|
60
65
|
assert Licensee::License.new("no-license").hidden?
|
61
|
-
|
62
66
|
end
|
63
67
|
|
64
68
|
should "parse the license parts" do
|
@@ -97,7 +101,8 @@ class TestLicenseeLicense < Minitest::Test
|
|
97
101
|
|
98
102
|
should "load the licenses" do
|
99
103
|
assert_equal Array, Licensee::License.all.class
|
100
|
-
assert_equal
|
104
|
+
assert_equal 15, Licensee::License.all.size
|
105
|
+
assert_equal 19, Licensee::License.all(:hidden => true).size
|
101
106
|
assert_equal Licensee::License, Licensee::License.all.first.class
|
102
107
|
end
|
103
108
|
|
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: 5.0.
|
4
|
+
version: 5.0.0b2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|