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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4cb5e38f1cd304a7f3610e1f7e6dab39540fb5f
4
- data.tar.gz: 5680e4a5987219b6ac315db16cac710d75626b21
3
+ metadata.gz: a80220390156080250dcaea26db57f17625d8f02
4
+ data.tar.gz: 0fcafa03b8ad6a1b30c28b191f12a6224d193bc2
5
5
  SHA512:
6
- metadata.gz: f5354a2d34d698d2cbad1634f41b987ccc7ab7724c3a0326eab2cb31f5c029c27ae40489017784dfcb7c79c9dbd045d91a1ced46cb26001dfa97f33a621049bd
7
- data.tar.gz: 739bb188cdba12bf00a3a94e3a21a30f7df67f4324cabdcb3645f39d3d27d2ab565403c5725415de181f139d7cd9a1002c0bc9ad416578a5c887589cb84715e8
6
+ metadata.gz: e069fd762d497e70504e3cf3dba03d0daaf3e3aa993ab26178b008901950598112d34c0da4ee638aab3ede891ab13de31c3d0089f4bd5a61d28da790a0397a02
7
+ data.tar.gz: 6ba024fc0f83f26e4773bc0fc28ffbe9c38d92638b5580000d570fe1230aae1c8f7148209161aafb54d2e9d8124321bec434d67419e27e18ebfdff74994f851b
@@ -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
- @license_file = if license_blob
38
- LicenseFile.new(@repository.lookup(license_blob[:oid]))
39
- end
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
@@ -1,3 +1,3 @@
1
1
  class Licensee
2
- VERSION = "4.2.4"
2
+ VERSION = "4.3.0"
3
3
  end
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1,6 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = true
5
+ ignorecase = true
6
+ precomposeunicode = true
@@ -0,0 +1,4 @@
1
+ x��Q
2
+ � ��)�
3
+ �:׳�Q��U�s�n�ߍz
4
+ d:x
@@ -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
@@ -0,0 +1 @@
1
+ 643983d3f82ecc2a7d8e4227946220ebffd477d2
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1,6 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = true
5
+ ignorecase = true
6
+ precomposeunicode = true
@@ -0,0 +1,3 @@
1
+ x��[
2
+ � D��*������DE!*���k��g8 ���k-��FJ �2ZZ��d�^p�f�X]�֦�� �꘿����`�'�[Hm _~�
3
+ WXb�@%4�3
@@ -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
@@ -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.2.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-26 00:00:00.000000000 Z
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