licensee 9.15.3 → 9.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/bin/licensee +5 -1
  3. data/lib/licensee/commands/license_path.rb +8 -8
  4. data/lib/licensee/content_helper.rb +10 -9
  5. data/lib/licensee/license.rb +12 -4
  6. data/lib/licensee/license_field.rb +2 -2
  7. data/lib/licensee/license_meta.rb +2 -2
  8. data/lib/licensee/matchers/cabal.rb +1 -1
  9. data/lib/licensee/matchers/cargo.rb +1 -1
  10. data/lib/licensee/matchers/copyright.rb +3 -3
  11. data/lib/licensee/matchers/cran.rb +3 -3
  12. data/lib/licensee/matchers/dist_zilla.rb +1 -1
  13. data/lib/licensee/matchers/gemspec.rb +5 -5
  14. data/lib/licensee/matchers/npm_bower.rb +1 -1
  15. data/lib/licensee/matchers/nuget.rb +6 -6
  16. data/lib/licensee/matchers/spdx.rb +1 -1
  17. data/lib/licensee/project_files/license_file.rb +9 -9
  18. data/lib/licensee/project_files/readme_file.rb +3 -3
  19. data/lib/licensee/projects/fs_project.rb +2 -2
  20. data/lib/licensee/projects/git_project.rb +2 -2
  21. data/lib/licensee/projects/github_project.rb +1 -1
  22. data/lib/licensee/rule.rb +1 -1
  23. data/lib/licensee/version.rb +1 -1
  24. data/spec/fixture_spec.rb +1 -1
  25. data/spec/fixtures/agpl-3.0_markdown/LICENSE.md +651 -0
  26. data/spec/fixtures/apache-2.0_markdown/LICENSE.md +195 -0
  27. data/spec/fixtures/bsd-2-author/LICENSE +22 -0
  28. data/spec/fixtures/bsd-3-clause_markdown/LICENSE.md +28 -0
  29. data/spec/fixtures/cc-by-4.0_markdown/LICENSE.md +157 -0
  30. data/spec/fixtures/cc-by-sa-4.0_markdown/LICENSE.md +171 -0
  31. data/spec/fixtures/cc0-1.0_markdown/LICENSE.md +41 -0
  32. data/spec/fixtures/detect.json +1 -1
  33. data/spec/fixtures/epl-1.0_markdown/LICENSE.md +76 -0
  34. data/spec/fixtures/fixtures.yml +105 -41
  35. data/spec/fixtures/gfdl-1.3_markdown/LICENSE.md +450 -0
  36. data/spec/fixtures/gpl-2.0_markdown/LICENSE.md +336 -0
  37. data/spec/fixtures/gpl-3.0_markdown/LICENSE.md +595 -0
  38. data/spec/fixtures/lgpl-2.1_markdown/LICENSE.md +494 -0
  39. data/spec/fixtures/lgpl-3.0_markdown/LICENSE.md +163 -0
  40. data/spec/fixtures/license-hashes.json +6 -6
  41. data/spec/fixtures/mit_markdown/LICENSE.md +26 -0
  42. data/spec/fixtures/mpl-2.0_markdown/LICENSE.md +357 -0
  43. data/spec/fixtures/unlicense_markdown/LICENSE.md +27 -0
  44. data/spec/integration_spec.rb +11 -2
  45. data/spec/licensee/commands/detect_spec.rb +16 -0
  46. data/spec/licensee/commands/license_path_spec.rb +3 -2
  47. data/spec/licensee/content_helper_spec.rb +17 -1
  48. data/spec/licensee/license_meta_spec.rb +2 -2
  49. data/spec/licensee/matchers/cran_matcher_spec.rb +0 -2
  50. data/spec/licensee/matchers/reference_matcher_spec.rb +17 -0
  51. data/spec/spec_helper.rb +1 -1
  52. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +1 -0
  53. data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +1 -1
  54. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +1 -1
  55. data/vendor/choosealicense.com/_licenses/epl-2.0.txt +3 -3
  56. data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +1 -1
  57. data/vendor/choosealicense.com/_licenses/upl-1.0.txt +3 -3
  58. data/vendor/license-list-XML/src/AGPL-3.0.xml +2 -2
  59. data/vendor/license-list-XML/src/Apache-2.0.xml +2 -2
  60. data/vendor/license-list-XML/src/Artistic-2.0.xml +5 -3
  61. data/vendor/license-list-XML/src/BSD-2-Clause.xml +2 -2
  62. data/vendor/license-list-XML/src/BSD-3-Clause-Clear.xml +3 -1
  63. data/vendor/license-list-XML/src/BSD-3-Clause.xml +9 -9
  64. data/vendor/license-list-XML/src/GFDL-1.3.xml +1 -1
  65. data/vendor/license-list-XML/src/GPL-2.0.xml +1 -1
  66. data/vendor/license-list-XML/src/GPL-3.0.xml +1 -1
  67. data/vendor/license-list-XML/src/LGPL-2.1.xml +1 -1
  68. data/vendor/license-list-XML/src/LGPL-3.0.xml +1 -1
  69. metadata +29 -14
  70. data/licensee.gemspec +0 -47
  71. /data/spec/fixtures/{markdown-artistic → artistic-2.0_markdown}/LICENSE.md +0 -0
  72. /data/spec/fixtures/{markdown-gpl → gpl-2.0_markdown_headings}/LICENSE.md +0 -0
  73. /data/spec/licensee/project_files/{package_info_spec.rb → package_manager_file_spec.rb} +0 -0
  74. /data/spec/licensee/projects/{github_project_spec.rb → git_hub_project_spec.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6b54db113cb4f1c4933826886afe3ed5e4b66d757a97df74dc43dbb2f8d6bc7
4
- data.tar.gz: 72fa1baf7073bfb9132823d1953977ab49618d03320694647d6947b66aee311f
3
+ metadata.gz: 4f5ee0aef5bea7c09d85b5fe00cde34590331108dea73bede502928d3e863809
4
+ data.tar.gz: 4ce51466168c4b9aaf354ffe897f6727e598cc534aadff4846f028a2a66dff7c
5
5
  SHA512:
6
- metadata.gz: 461a7ed0479855f6e2c08353ee902b2b8f53661d24161ef22f6c7dbb0f9db1ee375f6fc4e196d1c266cd5830221525af471c9158b64891fa4b0b0b7b373e6eac
7
- data.tar.gz: '09bfdd2cb1d12bd2b4a32bad1de90c65058d9ab1f3ed98ccb94ed9657b8965e236d4be84ce32e7801edf071de3ca7154d34455bfa749d29b1d89d9030c9a0ca4'
6
+ metadata.gz: 314636d52fd93d47a39b9b9835fe3b305735fc84be5767f1ab31a6bb0f933abb0e837d7bb9c4cb20ce64be0bcb0e2043adbce964b09dfc05776d955e6a089012
7
+ data.tar.gz: 308beab7147f0e4f5f8f16c70533e899c5106b30245544d0d27cea2727d28a929e5b328031dd1658be998da04b477e2adc6c5e3f0686cfbe8d2cd05fb93eca25
data/bin/licensee CHANGED
@@ -12,6 +12,10 @@ class LicenseeCLI < Thor
12
12
  class_option :remote, type: :boolean, desc: 'Assume PATH is a GitHub owner/repo path'
13
13
  default_task :detect
14
14
 
15
+ def self.exit_on_failure?
16
+ true
17
+ end
18
+
15
19
  private
16
20
 
17
21
  def path
@@ -33,6 +37,6 @@ class LicenseeCLI < Thor
33
37
  end
34
38
 
35
39
  commands_dir = File.expand_path '../lib/licensee/commands/', __dir__
36
- Dir["#{commands_dir}/*.rb"].sort.each { |c| require(c) }
40
+ Dir["#{commands_dir}/*.rb"].each { |c| require(c) }
37
41
 
38
42
  LicenseeCLI.start(ARGV)
@@ -2,15 +2,15 @@
2
2
 
3
3
  class LicenseeCLI < Thor
4
4
  desc 'license-path [PATH]', "Returns the path to the given project's license file"
5
- def license_path(_path)
6
- if project.license_file
7
- if remote?
8
- say project.license_file.path
9
- else
10
- say File.expand_path project.license_file.path
11
- end
5
+ def license_path(path)
6
+ project = Licensee.project(path)
7
+
8
+ exit 1 unless project.license_file
9
+
10
+ if remote?
11
+ say project.license_file.path
12
12
  else
13
- exit 1
13
+ say File.expand_path(project.license_file.path, path)
14
14
  end
15
15
  end
16
16
  end
@@ -6,8 +6,8 @@ require 'digest'
6
6
  module Licensee
7
7
  module ContentHelper
8
8
  DIGEST = Digest::SHA1
9
- START_REGEX = /\A\s*/.freeze
10
- END_OF_TERMS_REGEX = /^[\s#*_]*end of (the )?terms and conditions[\s#*_]*$/i.freeze
9
+ START_REGEX = /\A\s*/
10
+ END_OF_TERMS_REGEX = /^[\s#*_]*end of (the )?terms and conditions[\s#*_]*$/i
11
11
  REGEXES = {
12
12
  bom: /#{START_REGEX}\xEF\xBB\xBF/,
13
13
  hrs: /^\s*[=\-*]{3,}\s*$/,
@@ -32,11 +32,12 @@ module Licensee
32
32
  mit_optional: /\(including the next paragraph\)/i
33
33
  }.freeze
34
34
  NORMALIZATIONS = {
35
- lists: { from: /^\s*(?:\d\.|\*)\s+([^\n])/, to: '- \1' },
35
+ lists: { from: /^\s*(?:\d\.|[*-])(?: [*_]{0,2}\(?[\da-z]\)[*_]{0,2})?\s+([^\n])/, to: '- \1' },
36
36
  https: { from: /http:/, to: 'https:' },
37
37
  ampersands: { from: '&', to: 'and' },
38
38
  dashes: { from: /(?<!^)([—–-]+)(?!$)/, to: '-' },
39
- quote: { from: /[`'"‘“’”]/, to: "'" }
39
+ quote: { from: /[`'"‘“’”]/, to: "'" },
40
+ hyphenated: { from: /(\w+)-\s*\n\s*(\w+)/, to: '\1-\2' }
40
41
  }.freeze
41
42
 
42
43
  # Legally equivalent words that schould be ignored for comparison
@@ -82,8 +83,8 @@ module Licensee
82
83
  'whilst' => 'while',
83
84
  'wilful' => 'wilfull',
84
85
  'non-commercial' => 'noncommercial',
85
- 'cent' => 'percent',
86
- 'owner' => 'holder'
86
+ 'per cent' => 'percent',
87
+ 'copyright owner' => 'copyright holder'
87
88
  }.freeze
88
89
  STRIP_METHODS = %i[
89
90
  bom
@@ -303,8 +304,8 @@ module Licensee
303
304
 
304
305
  if operation
305
306
  @_content = _content.gsub operation[:from], operation[:to]
306
- elsif respond_to?("normalize_#{from_or_key}", true)
307
- send("normalize_#{from_or_key}")
307
+ elsif respond_to?(:"normalize_#{from_or_key}", true)
308
+ send(:"normalize_#{from_or_key}")
308
309
  else
309
310
  raise ArgumentError, "#{from_or_key} is an invalid normalization"
310
311
  end
@@ -341,7 +342,7 @@ module Licensee
341
342
  # Use that if it's present, otherwise, just return the simple delta.
342
343
  return delta unless respond_to?(:spdx_alt_segments, true)
343
344
 
344
- adjusted_delta = delta - ([fields_normalized.size, spdx_alt_segments].max * 4)
345
+ adjusted_delta = delta - ([fields_normalized.size, spdx_alt_segments].max * 5)
345
346
  adjusted_delta.positive? ? adjusted_delta : 0
346
347
  end
347
348
  end
@@ -74,7 +74,7 @@ module Licensee
74
74
  end
75
75
 
76
76
  def keys_licenses(options = {})
77
- @keys_licenses[options] ||= all(options).map { |l| [l.key, l] }.to_h
77
+ @keys_licenses[options] ||= all(options).to_h { |l| [l.key, l] }
78
78
  end
79
79
  end
80
80
 
@@ -98,8 +98,8 @@ module Licensee
98
98
  pseudo: true
99
99
  }.freeze
100
100
 
101
- SOURCE_PREFIX = %r{https?://(?:www\.)?}i.freeze
102
- SOURCE_SUFFIX = %r{(?:\.html?|\.txt|/)(?:\?[^\s]*)?}i.freeze
101
+ SOURCE_PREFIX = %r{https?://(?:www\.)?}i
102
+ SOURCE_SUFFIX = %r{(?:\.html?|\.txt|/)(?:\?[^\s]*)?}i
103
103
 
104
104
  HASH_METHODS = %i[
105
105
  key spdx_id meta url rules fields other? gpl? lgpl? cc?
@@ -151,7 +151,15 @@ module Licensee
151
151
  string.sub!(/v(\d+\.\d+)/, '\1')
152
152
  string = Regexp.escape(string)
153
153
  string = string.sub(/\\ licen[sc]e/i, '(?:\ licen[sc]e)?')
154
- string = string.sub(/\\ (\d+\\.\d+)/, ',?\s+(?:version\ |v(?:\. )?)?\1')
154
+ version_match = string.match(/\d+\\.(\d+)/)
155
+ if version_match
156
+ vsub = if version_match[1] == '0'
157
+ ',?\s+(?:version\ |v(?:\. )?)?\1(\2)?'
158
+ else
159
+ ',?\s+(?:version\ |v(?:\. )?)?\1\2'
160
+ end
161
+ string = string.sub(/\\ (\d+)(\\.\d+)/, vsub)
162
+ end
155
163
  string = string.sub(/\bgnu\\ /, '(?:GNU )?')
156
164
  title_regex = Regexp.new string, 'i'
157
165
 
@@ -22,7 +22,7 @@ module Licensee
22
22
  @all ||= begin
23
23
  path = '../../vendor/choosealicense.com/_data/fields.yml'
24
24
  path = File.expand_path path, __dir__
25
- fields = YAML.safe_load File.read(path)
25
+ fields = YAML.safe_load_file(path)
26
26
  fields.map { |field| LicenseField.from_hash(field) }
27
27
  end
28
28
  end
@@ -47,7 +47,7 @@ module Licensee
47
47
  end
48
48
 
49
49
  alias key name
50
- FIELD_REGEX = /\[(#{Regexp.union(LicenseField.keys)})\]/.freeze
50
+ FIELD_REGEX = /\[(#{Regexp.union(LicenseField.keys)})\]/
51
51
 
52
52
  # The human-readable field name
53
53
  def label
@@ -43,12 +43,12 @@ module Licensee
43
43
 
44
44
  # Array of symbolized helper methods to expose on the License class
45
45
  def helper_methods
46
- members - PREDICATE_FIELDS + PREDICATE_FIELDS.map { |f| "#{f}?".to_sym }
46
+ members - PREDICATE_FIELDS + PREDICATE_FIELDS.map { |f| :"#{f}?" }
47
47
  end
48
48
  end
49
49
 
50
50
  PREDICATE_FIELDS.each do |field|
51
- alias_method "#{field}?".to_sym, field
51
+ alias_method :"#{field}?", field
52
52
  end
53
53
 
54
54
  # Backward compatibalize `#["spdx-id"]` calls to avoid a breaking change
@@ -5,7 +5,7 @@ module Licensee
5
5
  class Cabal < Licensee::Matchers::Package
6
6
  # While we could parse the cabal file, prefer
7
7
  # a lenient regex for speed and security. Moar parsing moar problems.
8
- LICENSE_REGEX = /^\s*license\s*:\s*([a-z\-0-9.]+)\s*$/ix.freeze
8
+ LICENSE_REGEX = /^\s*license\s*:\s*([a-z\-0-9.]+)\s*$/ix
9
9
  LICENSE_CONVERSIONS = {
10
10
  'GPL-2' => 'GPL-2.0',
11
11
  'GPL-3' => 'GPL-3.0',
@@ -5,7 +5,7 @@ module Licensee
5
5
  class Cargo < Licensee::Matchers::Package
6
6
  LICENSE_REGEX = %r{
7
7
  ^\s*['"]?license['"]?\s*=\s*['"]([a-z\-0-9. +()/]+)['"]\s*
8
- }ix.freeze
8
+ }ix
9
9
 
10
10
  private
11
11
 
@@ -6,9 +6,9 @@ module Licensee
6
6
  attr_reader :file
7
7
 
8
8
  COPYRIGHT_SYMBOLS = Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
9
- MAIN_LINE_REGEX = /[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i.freeze
10
- OPTIONAL_LINE_REGEX = /[_*\-\s]*with Reserved Font Name.*$/i.freeze
11
- REGEX = /#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{OPTIONAL_LINE_REGEX}*)+$/i.freeze
9
+ MAIN_LINE_REGEX = /[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i
10
+ OPTIONAL_LINE_REGEX = /[_*\-\s]*with Reserved Font Name.*$/i
11
+ REGEX = /#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{OPTIONAL_LINE_REGEX}*)+$/i
12
12
  def match
13
13
  # NOTE: must use content, and not content_normalized here
14
14
  Licensee::License.find('no-license') if /#{REGEX}+\z/io.match?(file.content.strip)
@@ -7,9 +7,9 @@ module Licensee
7
7
 
8
8
  # While we could parse the DESCRIPTION file, prefer
9
9
  # a lenient regex for speed and security. Moar parsing moar problems.
10
- LICENSE_FIELD_REGEX = /^license:\s*(.+)/i.freeze
11
- PLUS_FILE_LICENSE_REGEX = /\s*\+\s*file\s+LICENSE$/i.freeze
12
- GPL_VERSION_REGEX = /^GPL(?:-([23])|\s*\(\s*>=\s*([23])\s*\))$/i.freeze
10
+ LICENSE_FIELD_REGEX = /^license:\s*(.+)/i
11
+ PLUS_FILE_LICENSE_REGEX = /\s*\+\s*file\s+LICENSE$/i
12
+ GPL_VERSION_REGEX = /^GPL(?:-([23])|\s*\(\s*>=\s*([23])\s*\))$/i
13
13
 
14
14
  private
15
15
 
@@ -5,7 +5,7 @@ module Licensee
5
5
  class DistZilla < Licensee::Matchers::Package
6
6
  attr_reader :file
7
7
 
8
- LICENSE_REGEX = /^license\s*=\s*([a-z\-0-9._]+)/i.freeze
8
+ LICENSE_REGEX = /^license\s*=\s*([a-z\-0-9._]+)/i
9
9
 
10
10
  private
11
11
 
@@ -5,24 +5,24 @@ module Licensee
5
5
  class Gemspec < Licensee::Matchers::Package
6
6
  # a value is a string surrounded by any amount of whitespace
7
7
  # optionally ended with (non-captured) ".freeze"
8
- VALUE_REGEX = /\s*['"]([a-z\-0-9.]+)['"](?:\.freeze)?\s*/i.freeze
8
+ VALUE_REGEX = /\s*['"]([a-z\-0-9.]+)['"](?:\.freeze)?\s*/i
9
9
 
10
10
  # an array contains one or more values. all values, or array itself,
11
11
  # can be surrounded by any amount of whitespace. do not capture
12
12
  # non-value groups
13
- ARRAY_REGEX = /\s*\[#{VALUE_REGEX}(?:,#{VALUE_REGEX})*\]\s*/i.freeze
13
+ ARRAY_REGEX = /\s*\[#{VALUE_REGEX}(?:,#{VALUE_REGEX})*\]\s*/i
14
14
 
15
15
  DECLARATION_REGEX = /
16
16
  ^\s*[a-z0-9_]+\.([a-z0-9_]+)\s*=#{VALUE_REGEX}$
17
- /ix.freeze
17
+ /ix
18
18
 
19
19
  LICENSE_REGEX = /
20
20
  ^\s*[a-z0-9_]+\.license\s*=#{VALUE_REGEX}$
21
- /ix.freeze
21
+ /ix
22
22
 
23
23
  LICENSE_ARRAY_REGEX = /
24
24
  ^\s*[a-z0-9_]+\.licenses\s*=#{ARRAY_REGEX}$
25
- /ix.freeze
25
+ /ix
26
26
 
27
27
  private
28
28
 
@@ -7,7 +7,7 @@ module Licensee
7
7
  # a lenient regex for speed and security. Moar parsing moar problems.
8
8
  LICENSE_REGEX = /
9
9
  \s*["']license["']\s*:\s*['"]([a-z\-0-9.+ ()]+)['"],?\s*
10
- /ix.freeze
10
+ /ix
11
11
 
12
12
  private
13
13
 
@@ -7,14 +7,14 @@ module Licensee
7
7
  # Moar parsing moar problems.
8
8
  LICENSE_REGEX = %r{
9
9
  <license\s*type\s*=\s*["']expression["']\s*>([a-z\-0-9. +()]+)</license\s*>
10
- }ix.freeze
10
+ }ix
11
11
 
12
- LICENSE_URL_REGEX = %r{<licenseUrl>\s*(.*)\s*</licenseUrl>}i.freeze
12
+ LICENSE_URL_REGEX = %r{<licenseUrl>\s*(.*)\s*</licenseUrl>}i
13
13
 
14
- NUGET_REGEX = %r{https?://licenses.nuget.org/(.*)}i.freeze
15
- OPENSOURCE_REGEX = %r{https?://(?:www\.)?opensource.org/licenses/(.*)}i.freeze
16
- SPDX_REGEX = %r{https?://(?:www\.)?spdx.org/licenses/(.*?)(?:\.html|\.txt)?$}i.freeze
17
- APACHE_REGEX = %r{https?://(?:www\.)?apache.org/licenses/(.*?)(?:\.html|\.txt)?$}i.freeze
14
+ NUGET_REGEX = %r{https?://licenses.nuget.org/(.*)}i
15
+ OPENSOURCE_REGEX = %r{https?://(?:www\.)?opensource.org/licenses/(.*)}i
16
+ SPDX_REGEX = %r{https?://(?:www\.)?spdx.org/licenses/(.*?)(?:\.html|\.txt)?$}i
17
+ APACHE_REGEX = %r{https?://(?:www\.)?apache.org/licenses/(.*?)(?:\.html|\.txt)?$}i
18
18
 
19
19
  private
20
20
 
@@ -5,7 +5,7 @@ module Licensee
5
5
  class Spdx < Licensee::Matchers::Package
6
6
  # While we could parse the LICENSE.spdx file, prefer
7
7
  # a lenient regex for speed and security. Moar parsing moar problems.
8
- LICENSE_REGEX = /PackageLicenseDeclared:\s*([a-z\-0-9. +()]+)\s*/i.freeze
8
+ LICENSE_REGEX = /PackageLicenseDeclared:\s*([a-z\-0-9. +()]+)\s*/i
9
9
 
10
10
  private
11
11
 
@@ -7,29 +7,29 @@ module Licensee
7
7
 
8
8
  # List of extensions to give preference to
9
9
  PREFERRED_EXT = %w[md markdown txt html].freeze
10
- PREFERRED_EXT_REGEX = /\.#{Regexp.union(PREFERRED_EXT)}\z/.freeze
10
+ PREFERRED_EXT_REGEX = /\.#{Regexp.union(PREFERRED_EXT)}\z/
11
11
 
12
12
  # Regex to match any extension except .spdx or .header
13
- LICENSE_EXT_REGEX = %r{\.(?!spdx|header)[^./]+\z}i.freeze
13
+ LICENSE_EXT_REGEX = %r{\.(?!spdx|header)[^./]+\z}i
14
14
 
15
15
  # Regex to match any extension except a few unlikely as license
16
16
  # texts with complex filenames
17
- OTHER_EXT_REGEX = %r{\.(?!xml|go|gemspec)[^./]+\z}i.freeze
17
+ OTHER_EXT_REGEX = %r{\.(?!xml|go|gemspec)[^./]+\z}i
18
18
 
19
19
  # Regex to match any extension
20
- ANY_EXT_REGEX = %r{\.[^./]+\z}i.freeze
20
+ ANY_EXT_REGEX = %r{\.[^./]+\z}i
21
21
 
22
22
  # Regex to match, LICENSE, LICENCE, unlicense, etc.
23
- LICENSE_REGEX = /(un)?licen[sc]e/i.freeze
23
+ LICENSE_REGEX = /(un)?licen[sc]e/i
24
24
 
25
25
  # Regex to match COPYING, COPYRIGHT, etc.
26
- COPYING_REGEX = /copy(ing|right)/i.freeze
26
+ COPYING_REGEX = /copy(ing|right)/i
27
27
 
28
28
  # Regex to match OFL.
29
- OFL_REGEX = /ofl/i.freeze
29
+ OFL_REGEX = /ofl/i
30
30
 
31
31
  # BSD + PATENTS patent file
32
- PATENTS_REGEX = /patents/i.freeze
32
+ PATENTS_REGEX = /patents/i
33
33
 
34
34
  # Hash of Regex => score with which to score potential license files
35
35
  FILENAME_REGEXES = {
@@ -55,7 +55,7 @@ module Licensee
55
55
  # detected as CC-BY or CC-BY-SA which are 98%+ similar
56
56
  CC_FALSE_POSITIVE_REGEX = /
57
57
  ^(creative\ commons\ )?Attribution-(NonCommercial|NoDerivatives)
58
- /xi.freeze
58
+ /xi
59
59
 
60
60
  def possible_matchers
61
61
  [Matchers::Copyright, Matchers::Exact, Matchers::Dice]
@@ -9,8 +9,8 @@ module Licensee
9
9
  /\AREADME\.(#{Regexp.union(EXTENSIONS).source})\z/i => 0.9
10
10
  }.freeze
11
11
 
12
- TITLE_REGEX = /licen[sc]e:?/i.freeze
13
- UNDERLINE_REGEX = /\n[-=]+/m.freeze
12
+ TITLE_REGEX = /licen[sc]e:?/i
13
+ UNDERLINE_REGEX = /\n[-=]+/m
14
14
  CONTENT_REGEX = /^
15
15
  (?: # Header lookbehind
16
16
  [\#=]+\s#{TITLE_REGEX}\s*[\#=]* # Start of hashes or rdoc header
@@ -27,7 +27,7 @@ module Licensee
27
27
  |
28
28
  \z # End of file
29
29
  )
30
- /mix.freeze
30
+ /mix
31
31
 
32
32
  def possible_matchers
33
33
  super.push(Matchers::Reference)
@@ -34,11 +34,11 @@ module Licensee
34
34
  def files
35
35
  @files ||= search_directories.flat_map do |dir|
36
36
  relative_dir = Pathname.new(dir).relative_path_from(dir_path).to_s
37
- Dir.glob(::File.join(dir, @pattern).tr('\\', '/')).map do |file|
37
+ Dir.glob(::File.join(dir, @pattern).tr('\\', '/')).filter_map do |file|
38
38
  next unless ::File.file?(file)
39
39
 
40
40
  { name: ::File.basename(file), dir: relative_dir }
41
- end.compact
41
+ end
42
42
  end
43
43
  end
44
44
 
@@ -71,9 +71,9 @@ module Licensee
71
71
  end
72
72
 
73
73
  def files_from_tree(tree, dir = '.')
74
- tree.select { |e| e[:type] == :blob }.map do |entry|
74
+ tree.select { |e| e[:type] == :blob }.filter_map do |entry|
75
75
  entry.merge(dir: dir)
76
- end.compact
76
+ end
77
77
  end
78
78
  end
79
79
  end
@@ -15,7 +15,7 @@ module Licensee
15
15
  # If there's any trailing data (e.g. `.git`) this pattern will ignore it:
16
16
  # we're going to use the API rather than clone the repo.
17
17
  GITHUB_REPO_PATTERN =
18
- %r{https://github.com/([^/]+/([^/]+(?=\.git)|[^/]+)).*}.freeze
18
+ %r{https://github.com/([^/]+/([^/]+(?=\.git)|[^/]+)).*}
19
19
 
20
20
  class RepoNotFound < StandardError; end
21
21
 
data/lib/licensee/rule.rb CHANGED
@@ -43,7 +43,7 @@ module Licensee
43
43
  end
44
44
 
45
45
  def raw_rules
46
- YAML.safe_load File.read(Rule.file_path)
46
+ YAML.safe_load_file(Rule.file_path)
47
47
  end
48
48
 
49
49
  def groups
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Licensee
4
- VERSION = '9.15.3'
4
+ VERSION = '9.16.1'
5
5
  end
data/spec/fixture_spec.rb CHANGED
@@ -33,7 +33,7 @@ RSpec.describe 'fixture test' do
33
33
  end
34
34
 
35
35
  it 'returns the expected hash' do
36
- hash = license_file ? license_file.content_hash : nil
36
+ hash = license_file&.content_hash
37
37
  expect(hash).to eql(expectations['hash'])
38
38
  end
39
39