licensee 9.9.4 → 9.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/licensee/commands/detect.rb +4 -4
- data/lib/licensee/license_field.rb +4 -0
- data/lib/licensee/project_files/readme_file.rb +2 -2
- data/lib/licensee/version.rb +1 -1
- data/spec/licensee/license_field_spec.rb +5 -0
- data/spec/licensee/project_files/readme_file_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa1cf2d146414880f019c339c2803443db7d63eb2568f7807079aac27a7aec98
|
4
|
+
data.tar.gz: a6243b9cc4b9068090023c70c89a5ea0253580575b534da0c00deaa799441bb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff2872a3d87b3c708ac2585dc41b64dd665008064303ec66a3501ec5160dbc87b5e78a4128921d5a95e3e7eb160ecc625d3d12f0fad36b05b59fa577088581b
|
7
|
+
data.tar.gz: 96466e4da40eb17a01625110f236c40cc90cb99b2e39c7057f2867721c77c565ba16cf08d4c4b02c799d1675a11c765e0dd313c761e273354b19fa8cb0fa1528
|
@@ -49,7 +49,7 @@ class LicenseeCLI < Thor
|
|
49
49
|
next unless matched_file.is_a? Licensee::ProjectFiles::LicenseFile
|
50
50
|
next if matched_file.confidence == 100
|
51
51
|
|
52
|
-
licenses =
|
52
|
+
licenses = licenses_by_similarity(matched_file)
|
53
53
|
next if licenses.empty?
|
54
54
|
say ' Closest non-matching licenses:'
|
55
55
|
rows = licenses[0...3].map do |license, similarity|
|
@@ -89,15 +89,15 @@ class LicenseeCLI < Thor
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
92
|
+
def licenses_by_similarity(matched_file)
|
93
93
|
matcher = Licensee::Matchers::Dice.new(matched_file)
|
94
94
|
potential_licenses = Licensee.licenses(hidden: true).select(&:wordset)
|
95
95
|
matcher.instance_variable_set('@potential_licenses', potential_licenses)
|
96
|
-
matcher.
|
96
|
+
matcher.licenses_by_similarity
|
97
97
|
end
|
98
98
|
|
99
99
|
def closest_license_key(matched_file)
|
100
|
-
licenses =
|
100
|
+
licenses = licenses_by_similarity(matched_file)
|
101
101
|
licenses.first.first.key unless licenses.empty?
|
102
102
|
end
|
103
103
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Licensee
|
2
2
|
module ProjectFiles
|
3
3
|
class ReadmeFile < Licensee::ProjectFiles::LicenseFile
|
4
|
-
EXTENSIONS = %w[md markdown mdown txt rdoc].freeze
|
4
|
+
EXTENSIONS = %w[md markdown mdown txt rdoc rst].freeze
|
5
5
|
SCORES = {
|
6
6
|
/\AREADME\z/i => 1.0,
|
7
7
|
/\AREADME\.(#{Regexp.union(EXTENSIONS).source})\z/i => 0.9
|
@@ -11,7 +11,7 @@ module Licensee
|
|
11
11
|
UNDERLINE_REGEX = /\n[-=]+/m
|
12
12
|
CONTENT_REGEX = /^
|
13
13
|
(?: # Header lookbehind
|
14
|
-
[\#=]+\s#{TITLE_REGEX}
|
14
|
+
[\#=]+\s#{TITLE_REGEX}\s*[\#=]* # Start of hashes or rdoc header
|
15
15
|
|
|
16
16
|
#{TITLE_REGEX}#{UNDERLINE_REGEX} # Start of underlined header
|
17
17
|
)$
|
data/lib/licensee/version.rb
CHANGED
@@ -79,6 +79,11 @@ RSpec.describe Licensee::LicenseField do
|
|
79
79
|
expect(field.to_s).to eql('Foo')
|
80
80
|
end
|
81
81
|
|
82
|
+
it 'returns the raw text' do
|
83
|
+
field = described_class.new('fullname')
|
84
|
+
expect(field.raw_text).to eql('[fullname]')
|
85
|
+
end
|
86
|
+
|
82
87
|
context 'spec_helper' do
|
83
88
|
it 'substitutes all fields' do
|
84
89
|
expected = described_class.keys.sort
|
@@ -12,6 +12,7 @@ RSpec.describe Licensee::ProjectFiles::ReadmeFile do
|
|
12
12
|
'readme.txt' => 0.9,
|
13
13
|
'readme.mdown' => 0.9,
|
14
14
|
'readme.rdoc' => 0.9,
|
15
|
+
'readme.rst' => 0.9,
|
15
16
|
'LICENSE' => 0.0
|
16
17
|
}.each do |filename, expected_score|
|
17
18
|
context "with a file named #{filename}" do
|
@@ -107,6 +108,14 @@ RSpec.describe Licensee::ProjectFiles::ReadmeFile do
|
|
107
108
|
end
|
108
109
|
end
|
109
110
|
|
111
|
+
context 'With trailing hashes' do
|
112
|
+
let(:content) { "## License ##\n\nhello world" }
|
113
|
+
|
114
|
+
it 'returns the license' do
|
115
|
+
expect(license).to eql('hello world')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
110
119
|
context 'Rdoc' do
|
111
120
|
let(:content) { "== License:\n\nhello world" }
|
112
121
|
|
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.
|
4
|
+
version: 9.10.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-
|
11
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|