licensee 4.2.4 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/licensee/project.rb +7 -4
- data/lib/licensee/version.rb +1 -1
- data/test/fixtures/named-license-file-prefix.git/HEAD +1 -0
- data/test/fixtures/named-license-file-prefix.git/config +6 -0
- data/test/fixtures/named-license-file-prefix.git/objects/64/3983d3f82ecc2a7d8e4227946220ebffd477d2 +4 -0
- data/test/fixtures/named-license-file-prefix.git/objects/c9/b229e500e529fdbd4f50746ba207e91d0677b6 +7 -0
- data/test/fixtures/named-license-file-prefix.git/objects/d1/9223f355283b3ce0c51a2c527f685d0f403157 +0 -0
- data/test/fixtures/named-license-file-prefix.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/named-license-file-prefix.git/refs/heads/master +1 -0
- data/test/fixtures/named-license-file-suffix.git/HEAD +1 -0
- data/test/fixtures/named-license-file-suffix.git/config +6 -0
- data/test/fixtures/named-license-file-suffix.git/objects/36/465372136f81a2089f486298ca77ef41611198 +0 -0
- data/test/fixtures/named-license-file-suffix.git/objects/4a/2a139e7fbd24eef5c5ef3d22f490e89405f6a3 +3 -0
- data/test/fixtures/named-license-file-suffix.git/objects/c9/b229e500e529fdbd4f50746ba207e91d0677b6 +7 -0
- data/test/fixtures/named-license-file-suffix.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/named-license-file-suffix.git/refs/heads/master +1 -0
- data/test/test_licensee_project.rb +10 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80220390156080250dcaea26db57f17625d8f02
|
4
|
+
data.tar.gz: 0fcafa03b8ad6a1b30c28b191f12a6224d193bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e069fd762d497e70504e3cf3dba03d0daaf3e3aa993ab26178b008901950598112d34c0da4ee638aab3ede891ab13de31c3d0089f4bd5a61d28da790a0397a02
|
7
|
+
data.tar.gz: 6ba024fc0f83f26e4773bc0fc28ffbe9c38d92638b5580000d570fe1230aae1c8f7148209161aafb54d2e9d8124321bec434d67419e27e18ebfdff74994f851b
|
data/lib/licensee/project.rb
CHANGED
@@ -32,11 +32,14 @@ class Licensee
|
|
32
32
|
return @license_file if defined? @license_file
|
33
33
|
|
34
34
|
commit = @revision ? @repository.lookup(@revision) : @repository.last_commit
|
35
|
-
license_blob = commit.tree.each_blob { |blob| break blob if LICENSE_FILENAMES.include? blob[:name].downcase }
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
# Prefer an exact match to one of our known file names
|
37
|
+
license_blob = commit.tree.find { |blob| LICENSE_FILENAMES.include? blob[:name].downcase }
|
38
|
+
|
39
|
+
# Fall back to the first file in the project root that has the word license in it
|
40
|
+
license_blob = commit.tree.find { |blob| blob[:name] =~ /license/i } unless license_blob
|
41
|
+
|
42
|
+
@license_file = LicenseFile.new(@repository.lookup(license_blob[:oid])) if license_blob
|
40
43
|
end
|
41
44
|
|
42
45
|
# Returns the matching Licensee::License instance if a license can be detected
|
data/lib/licensee/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/master
|
data/test/fixtures/named-license-file-prefix.git/objects/c9/b229e500e529fdbd4f50746ba207e91d0677b6
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
x]RK��0�Y�b�i�v�P
|
2
|
+
�)��u,#+����8V����9ɖF���5j����/�T�a��գ����GBb{~�̱���>痯�͍���z:��8����w8N��u�a��ھ��:o���'����x�Zd ��{�q��/������9ۚ��|ң�}�;�A;x�(yU�&V�I�끘�4ܯ�b|og�v~2m�����0wA��z0'sc�mGP���A���v��z�u����>���f���BqI1
|
3
|
+
>>� ��u/^��[zB>�
|
4
|
+
�$|S�a�q�Mx�
|
5
|
+
k�+>`�/A��@x���R�0g�L�<�j���"`�B��J��mN%�[Y��!}��/R�,l�
|
6
|
+
���X���2�灊�-��AĢ�K��)�D�0,�*��]��T�S�� ���I�"Ih���]�B)�Q�b�ElĢP����ct�+��
|
7
|
+
��Rl"�� DG�+�%D���l �m��]$�戅�)���'���W
|
data/test/fixtures/named-license-file-prefix.git/objects/d1/9223f355283b3ce0c51a2c527f685d0f403157
ADDED
Binary file
|
data/test/fixtures/named-license-file-prefix.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
643983d3f82ecc2a7d8e4227946220ebffd477d2
|
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/master
|
data/test/fixtures/named-license-file-suffix.git/objects/36/465372136f81a2089f486298ca77ef41611198
ADDED
Binary file
|
data/test/fixtures/named-license-file-suffix.git/objects/c9/b229e500e529fdbd4f50746ba207e91d0677b6
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
x]RK��0�Y�b�i�v�P
|
2
|
+
�)��u,#+����8V����9ɖF���5j����/�T�a��գ����GBb{~�̱���>痯�͍���z:��8����w8N��u�a��ھ��:o���'����x�Zd ��{�q��/������9ۚ��|ң�}�;�A;x�(yU�&V�I�끘�4ܯ�b|og�v~2m�����0wA��z0'sc�mGP���A���v��z�u����>���f���BqI1
|
3
|
+
>>� ��u/^��[zB>�
|
4
|
+
�$|S�a�q�Mx�
|
5
|
+
k�+>`�/A��@x���R�0g�L�<�j���"`�B��J��mN%�[Y��!}��/R�,l�
|
6
|
+
���X���2�灊�-��AĢ�K��)�D�0,�*��]��T�S�� ���I�"Ih���]�B)�Q�b�ElĢP����ct�+��
|
7
|
+
��Rl"�� DG�+�%D���l �m��]$�戅�)���'���W
|
data/test/fixtures/named-license-file-suffix.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
4a2a139e7fbd24eef5c5ef3d22f490e89405f6a3
|
@@ -18,4 +18,14 @@ class TestLicenseeProject < Minitest::Test
|
|
18
18
|
project = Licensee::Project.new fixture_path("case-sensitive.git")
|
19
19
|
assert_equal Licensee::LicenseFile, project.license_file.class
|
20
20
|
end
|
21
|
+
|
22
|
+
should "detect MIT-LICENSE licensed projects" do
|
23
|
+
project = Licensee::Project.new fixture_path("named-license-file-prefix.git")
|
24
|
+
assert_equal "mit", project.license.key
|
25
|
+
end
|
26
|
+
|
27
|
+
should "detect LICENSE-MIT licensed projects" do
|
28
|
+
project = Licensee::Project.new fixture_path("named-license-file-suffix.git")
|
29
|
+
assert_equal "mit", project.license.key
|
30
|
+
end
|
21
31
|
end
|
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: 4.
|
4
|
+
version: 4.3.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: 2015-02-
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -128,6 +128,20 @@ files:
|
|
128
128
|
- test/fixtures/licenses.git/objects/pack/pack-4a7088171ae3ca900f010a4be6f1c2c96490c338.idx
|
129
129
|
- test/fixtures/licenses.git/objects/pack/pack-4a7088171ae3ca900f010a4be6f1c2c96490c338.pack
|
130
130
|
- test/fixtures/licenses.git/packed-refs
|
131
|
+
- test/fixtures/named-license-file-prefix.git/HEAD
|
132
|
+
- test/fixtures/named-license-file-prefix.git/config
|
133
|
+
- test/fixtures/named-license-file-prefix.git/objects/64/3983d3f82ecc2a7d8e4227946220ebffd477d2
|
134
|
+
- test/fixtures/named-license-file-prefix.git/objects/c9/b229e500e529fdbd4f50746ba207e91d0677b6
|
135
|
+
- test/fixtures/named-license-file-prefix.git/objects/d1/9223f355283b3ce0c51a2c527f685d0f403157
|
136
|
+
- test/fixtures/named-license-file-prefix.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
|
137
|
+
- test/fixtures/named-license-file-prefix.git/refs/heads/master
|
138
|
+
- test/fixtures/named-license-file-suffix.git/HEAD
|
139
|
+
- test/fixtures/named-license-file-suffix.git/config
|
140
|
+
- test/fixtures/named-license-file-suffix.git/objects/36/465372136f81a2089f486298ca77ef41611198
|
141
|
+
- test/fixtures/named-license-file-suffix.git/objects/4a/2a139e7fbd24eef5c5ef3d22f490e89405f6a3
|
142
|
+
- test/fixtures/named-license-file-suffix.git/objects/c9/b229e500e529fdbd4f50746ba207e91d0677b6
|
143
|
+
- test/fixtures/named-license-file-suffix.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
|
144
|
+
- test/fixtures/named-license-file-suffix.git/refs/heads/master
|
131
145
|
- test/functions.rb
|
132
146
|
- test/helper.rb
|
133
147
|
- test/test_licensee.rb
|