licensee 9.9.0.beta.3 → 9.9.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
  SHA256:
3
- metadata.gz: 7068f99fb864749b613e41ea2aebbe89ab89dc84e64dc31f91ac2be663d47cae
4
- data.tar.gz: 981300886595234a0a0b37b9d47b450570fd4e09de5e8964036781cc74d9a496
3
+ metadata.gz: 0e68d77bd40c2b0782aaa0a9e7e2920bbb1fc618f9b9c2de2d327e0402133718
4
+ data.tar.gz: 3c9f04a3200fdb7a54861698f2dd341c057c7c3cf39326679e70c4927a1cdbcd
5
5
  SHA512:
6
- metadata.gz: 44f974f4265ab5169ac2a8f567ba79db34c537b34ed80f8a62265b391a778dbbc6be3fb819acbbab69ae998ab112af46fc4ea4323dffb580fac9bc107e7167c8
7
- data.tar.gz: f556bc5d62310d775677ced65c3340d961efb0f3ead7035369b213aac0a998864339def2a0025f304f00b984c7b5a2b89fa2234d7f4ae116faa035564156a5b7
6
+ metadata.gz: 4a59d88fea1c24eb704762f0482656e100e8d57b76d52d1cf2265db7193e81996ae8a1719fbadbab9e5f0f3d2ba9aa80304769ca47c40776b4c6caee9383ebb3
7
+ data.tar.gz: 88e89806f40aab22b987d2bae53add71b0ee7a0ba2ba92daed4574c900d3f00629cf066991f38a64efdebabbb06e95450a346382bf82b9741b1ccd93c61b0cad
@@ -82,6 +82,7 @@ module Licensee
82
82
  string, _partition, _instructions = string.partition(END_OF_TERMS_REGEX)
83
83
  string = strip_markup(string)
84
84
  string = normalize_quotes(string)
85
+ string = normalize_https(string)
85
86
  strip_whitespace(string)
86
87
  end
87
88
 
@@ -178,5 +179,9 @@ module Licensee
178
179
  def normalize_quotes(string)
179
180
  string.gsub(/\s'([\w -]*?\w)'/, ' "\1"')
180
181
  end
182
+
183
+ def normalize_https(string)
184
+ string.gsub(/http:/, 'https:')
185
+ end
181
186
  end
182
187
  end
@@ -117,6 +117,12 @@ module Licensee
117
117
  @meta ||= LicenseMeta.from_yaml(yaml)
118
118
  end
119
119
 
120
+ def spdx_id
121
+ return meta.spdx_id if meta.spdx_id
122
+ return 'NOASSERTION' if key == 'other'
123
+ return 'NONE' if key == 'no-license'
124
+ end
125
+
120
126
  # Returns the human-readable license name
121
127
  def name
122
128
  title ? title : key.capitalize
@@ -5,7 +5,7 @@ module Licensee
5
5
 
6
6
  # rubocop:disable Metrics/LineLength
7
7
  COPYRIGHT_SYMBOLS = Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
8
- REGEX = /\A\s*#{COPYRIGHT_SYMBOLS}.*$/i
8
+ REGEX = /\A(\s*#{COPYRIGHT_SYMBOLS}.*$)+/i
9
9
  # rubocop:enable Metrics/LineLength
10
10
 
11
11
  def match
@@ -54,6 +54,7 @@ module Licensee
54
54
 
55
55
  def attribution
56
56
  @attribution ||= begin
57
+ return unless copyright? || license.content =~ /\[fullname\]/
57
58
  matches = Matchers::Copyright::REGEX
58
59
  .match(content_without_title_and_version)
59
60
  matches[0] if matches
@@ -67,7 +67,7 @@ module Licensee
67
67
  alias path filename
68
68
 
69
69
  def matched_license
70
- license.key if license
70
+ license.spdx_id if license
71
71
  end
72
72
 
73
73
  # Is this file a COPYRIGHT file with only a copyright statement?
@@ -1,3 +1,3 @@
1
1
  module Licensee
2
- VERSION = '9.9.0.beta.3'.freeze
2
+ VERSION = '9.9.0'.freeze
3
3
  end
@@ -94,7 +94,7 @@
94
94
  "name": "exact",
95
95
  "confidence": 100
96
96
  },
97
- "matched_license": "mit"
97
+ "matched_license": "MIT"
98
98
  },
99
99
  {
100
100
  "filename": "licensee.gemspec",
@@ -105,7 +105,7 @@
105
105
  "name": "gemspec",
106
106
  "confidence": 90
107
107
  },
108
- "matched_license": "mit"
108
+ "matched_license": "MIT"
109
109
  }
110
110
  ]
111
111
  }
@@ -103,6 +103,12 @@ LICENSE
103
103
  expect(license.content_normalized).to_not include('* *')
104
104
  end
105
105
 
106
+ it 'normalizes http: to https:' do
107
+ license = Licensee::License.find('mpl-2.0')
108
+ expect(license.content).to include('http:')
109
+ expect(license.content_normalized).to_not include('http:')
110
+ end
111
+
106
112
  it 'wraps' do
107
113
  lines = mit.content_normalized(wrap: 40).split("\n")
108
114
  expect(lines.first.length).to be <= 40
@@ -11,6 +11,7 @@ RSpec.describe Licensee::License do
11
11
  let(:cc_by) { described_class.find('cc-by-4.0') }
12
12
  let(:unlicense) { described_class.find('unlicense') }
13
13
  let(:other) { described_class.find('other') }
14
+ let(:no_license) { described_class.find('no-license') }
14
15
  let(:gpl) { described_class.find('gpl-3.0') }
15
16
  let(:lgpl) { described_class.find('lgpl-3.0') }
16
17
  let(:content_hash) { '46cdc03462b9af57968df67b450cc4372ac41f53' }
@@ -168,6 +169,11 @@ RSpec.describe Licensee::License do
168
169
  expect(gpl.spdx_id).to eql('GPL-3.0')
169
170
  end
170
171
 
172
+ it 'exposes special SPDX ID for pseudo licenses' do
173
+ expect(other.spdx_id).to eql('NOASSERTION')
174
+ expect(no_license.spdx_id).to eql('NONE')
175
+ end
176
+
171
177
  context '#other?' do
172
178
  it 'knows MIT is not other' do
173
179
  expect(gpl).to_not be_other
@@ -26,7 +26,8 @@ RSpec.describe Licensee::Matchers::Copyright do
26
26
  'Comma-separated date' => 'Copyright (c) 2003, 2004 Ben Balter',
27
27
  'Hyphen-separated date' => 'Copyright (c) 2003-2004 Ben Balter',
28
28
  'ASCII-8BIT encoded' => "Copyright \xC2\xA92015 Ben Balter`",
29
- 'No year' => 'Copyright Ben Balter'
29
+ 'No year' => 'Copyright Ben Balter',
30
+ 'Multiline' => "Copyright Ben Balter\nCopyright Another Entity"
30
31
  .force_encoding('ASCII-8BIT')
31
32
  }.each do |description, notice|
32
33
  context "with a #{description} notice" do
@@ -1,5 +1,6 @@
1
1
  RSpec.describe Licensee::ProjectFiles::LicenseFile do
2
2
  let(:filename) { 'LICENSE.txt' }
3
+ let(:gpl) { Licensee::License.find('gpl-3.0') }
3
4
  let(:mit) { Licensee::License.find('mit') }
4
5
  let(:content) { sub_copyright_info(mit) }
5
6
  let(:content_hash) { '46cdc03462b9af57968df67b450cc4372ac41f53' }
@@ -26,6 +27,23 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
26
27
  end
27
28
  end
28
29
 
30
+ context 'with a non-templated license' do
31
+ let(:content) { sub_copyright_info(gpl) }
32
+
33
+ it "doesn't match" do
34
+ expect(subject.attribution).to be_nil
35
+ end
36
+ end
37
+
38
+ context 'with a copyright file' do
39
+ let(:filename) { 'COPYRIGHT' }
40
+ let(:content) { 'Copyright (C) 2015 Ben Balter' }
41
+
42
+ it "doesn't match" do
43
+ expect(subject.attribution).to eql(content)
44
+ end
45
+ end
46
+
29
47
  it 'creates the wordset' do
30
48
  expect(subject.wordset.count).to eql(91)
31
49
  expect(subject.wordset.first).to eql('permission')
@@ -215,7 +233,6 @@ Creative Commons Attribution-NonCommercial 4.0
215
233
  end
216
234
 
217
235
  context 'GPL' do
218
- let(:gpl) { Licensee::License.find('gpl-3.0') }
219
236
  let(:content) { sub_copyright_info(gpl) }
220
237
 
221
238
  it 'knows its GPL' do
@@ -56,7 +56,7 @@ RSpec.describe Licensee::ProjectFiles::ProjectFile do
56
56
  name: :exact,
57
57
  confidence: 100
58
58
  },
59
- matched_license: 'mit'
59
+ matched_license: 'MIT'
60
60
  }
61
61
  end
62
62
 
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: 9.9.0.beta.3
4
+ version: 9.9.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: 2018-03-26 00:00:00.000000000 Z
11
+ date: 2018-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -339,9 +339,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
339
339
  version: '2.1'
340
340
  required_rubygems_version: !ruby/object:Gem::Requirement
341
341
  requirements:
342
- - - ">"
342
+ - - ">="
343
343
  - !ruby/object:Gem::Version
344
- version: 1.3.1
344
+ version: '0'
345
345
  requirements: []
346
346
  rubyforge_project:
347
347
  rubygems_version: 2.7.6