licensee 9.9.3 → 9.9.4
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/matchers/dice.rb +7 -1
- data/lib/licensee/projects/github_project.rb +23 -8
- data/lib/licensee/version.rb +1 -1
- data/spec/licensee/project_spec.rb +21 -3
- data/spec/spec_helper.rb +2 -1
- 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: b85ef478c3f4eee0b055871998df44b7ac925d4cf558b12257e4ece69dffb605
|
|
4
|
+
data.tar.gz: 605cc902e7c2ff5dce082c200a12f0758577757dc1c23f3b601aa1a033bce055
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e570922e52f88998432deea4760a3414aa583406cfdb77e156e474c076e82c6314edb2934caeb515d9c24217e6a06ab70909bef3898ff69fc03dd6c55ae99aa5
|
|
7
|
+
data.tar.gz: 970c89d645d161d59380c02934485bff1108fa0d31289975da3f8f87103949e18b1b12eb584291477170a530e833465339887d99a042b605f705a27ab3082512
|
|
@@ -43,7 +43,7 @@ module Licensee
|
|
|
43
43
|
|
|
44
44
|
def matches
|
|
45
45
|
@matches ||= matches_by_similarity.select do |_, similarity|
|
|
46
|
-
similarity >=
|
|
46
|
+
similarity >= minimum_confidence
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -51,6 +51,12 @@ module Licensee
|
|
|
51
51
|
def confidence
|
|
52
52
|
@confidence ||= match ? file.similarity(match) : 0
|
|
53
53
|
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def minimum_confidence
|
|
58
|
+
Licensee.confidence_threshold
|
|
59
|
+
end
|
|
54
60
|
end
|
|
55
61
|
end
|
|
56
62
|
end
|
|
@@ -28,19 +28,34 @@ module Licensee
|
|
|
28
28
|
private
|
|
29
29
|
|
|
30
30
|
def files
|
|
31
|
-
@files
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
return @files if defined? @files_from_tree
|
|
32
|
+
@files = dir_files
|
|
33
|
+
return @files unless @files.empty?
|
|
34
|
+
msg = "Could not load GitHub repo #{repo}, it may be private or deleted"
|
|
35
|
+
raise RepoNotFound, msg
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
def load_file(file)
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
client.contents(@repo, path: file[:path],
|
|
40
|
+
accept: 'application/vnd.github.v3.raw').to_s
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def dir_files(path = nil)
|
|
44
|
+
path = path.gsub('./', '') if path
|
|
45
|
+
files = client.contents(@repo, path: path)
|
|
46
|
+
files = files.select { |data| data[:type] == 'file' }
|
|
47
|
+
files.each { |data| data[:dir] = File.dirname(data[:path]) }
|
|
48
|
+
files.map(&:to_h)
|
|
49
|
+
rescue Octokit::NotFound
|
|
50
|
+
[]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def client
|
|
54
|
+
@client ||= Octokit::Client.new access_token: access_token
|
|
40
55
|
end
|
|
41
56
|
|
|
42
|
-
def
|
|
43
|
-
|
|
57
|
+
def access_token
|
|
58
|
+
ENV['OCTOKIT_ACCESS_TOKEN']
|
|
44
59
|
end
|
|
45
60
|
end
|
|
46
61
|
end
|
data/lib/licensee/version.rb
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
FileUtils.rm_rf File.expand_path '.git', path
|
|
28
28
|
end
|
|
29
29
|
elsif described_class == Licensee::Projects::GitHubProject
|
|
30
|
-
|
|
30
|
+
before do
|
|
31
31
|
stub_request(
|
|
32
32
|
:get, "#{api_base}/#{stubbed_org}/#{fixture}/contents/"
|
|
33
33
|
).to_return(
|
|
@@ -43,9 +43,8 @@
|
|
|
43
43
|
.with(headers: { 'accept' => 'application/vnd.github.v3.raw' })
|
|
44
44
|
.to_return(status: 200, body: File.read(file))
|
|
45
45
|
end
|
|
46
|
-
|
|
47
|
-
"https://github.com/#{stubbed_org}/#{fixture}"
|
|
48
46
|
end
|
|
47
|
+
let(:path) { "https://github.com/#{stubbed_org}/#{fixture}" }
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
if described_class == Licensee::Projects::GitProject
|
|
@@ -178,6 +177,25 @@
|
|
|
178
177
|
end
|
|
179
178
|
end
|
|
180
179
|
|
|
180
|
+
if described_class == Licensee::Projects::GitHubProject
|
|
181
|
+
before do
|
|
182
|
+
stub_request(
|
|
183
|
+
:get, "#{api_base}/#{stubbed_org}/#{fixture}/contents/"
|
|
184
|
+
).to_return(
|
|
185
|
+
status: 200,
|
|
186
|
+
body: fixture_root_contents_from_api(fixture),
|
|
187
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
file = fixture_path "#{fixture}/project.gemspec"
|
|
191
|
+
relative_path = File.basename(file)
|
|
192
|
+
parts = [api_base, stubbed_org, fixture, 'contents', relative_path]
|
|
193
|
+
stub_request(:get, parts.join('/'))
|
|
194
|
+
.with(headers: { 'accept' => 'application/vnd.github.v3.raw' })
|
|
195
|
+
.to_return(status: 200, body: File.read(file))
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
181
199
|
after do
|
|
182
200
|
FileUtils.rm("#{fixture_path(fixture)}/project.gemspec")
|
|
183
201
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
|
4
|
+
version: 9.9.4
|
|
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-08-
|
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dotenv
|