licensed 5.0.2 → 5.0.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/Brewfile +3 -0
- data/CHANGELOG.md +2 -884
- data/Gemfile.lock +57 -46
- data/lib/licensed/configuration.rb +1 -1
- data/lib/licensed/git.rb +36 -38
- data/lib/licensed/shell.rb +1 -1
- data/lib/licensed/sources/gradle.rb +3 -5
- data/lib/licensed/sources/nuget.rb +42 -44
- data/lib/licensed/sources/pip.rb +9 -7
- data/lib/licensed/sources/pnpm.rb +18 -13
- data/lib/licensed/sources/source.rb +45 -39
- data/lib/licensed/version.rb +1 -1
- data/licensed.gemspec +2 -2
- metadata +7 -6
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
licensed (5.0.
|
4
|
+
licensed (5.0.4)
|
5
5
|
csv (~> 3.3)
|
6
6
|
json (~> 2.6)
|
7
7
|
licensee (~> 9.16)
|
@@ -15,113 +15,124 @@ PATH
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
17
17
|
specs:
|
18
|
-
activesupport (7.
|
18
|
+
activesupport (7.2.2.1)
|
19
19
|
base64
|
20
|
+
benchmark (>= 0.3)
|
20
21
|
bigdecimal
|
21
|
-
concurrent-ruby (~> 1.0, >= 1.
|
22
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
22
23
|
connection_pool (>= 2.2.5)
|
23
24
|
drb
|
24
25
|
i18n (>= 1.6, < 2)
|
26
|
+
logger (>= 1.4.2)
|
25
27
|
minitest (>= 5.1)
|
26
|
-
|
27
|
-
tzinfo (~> 2.0)
|
28
|
+
securerandom (>= 0.3)
|
29
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
28
30
|
addressable (2.8.7)
|
29
31
|
public_suffix (>= 2.0.2, < 7.0)
|
30
32
|
ast (2.4.2)
|
31
33
|
base64 (0.2.0)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
benchmark (0.4.0)
|
35
|
+
bigdecimal (3.1.9)
|
36
|
+
byebug (12.0.0)
|
37
|
+
concurrent-ruby (1.3.5)
|
38
|
+
connection_pool (2.5.0)
|
39
|
+
csv (3.3.4)
|
40
|
+
dotenv (3.1.7)
|
38
41
|
drb (2.2.1)
|
39
|
-
faraday (2.12.
|
42
|
+
faraday (2.12.2)
|
40
43
|
faraday-net_http (>= 2.0, < 3.5)
|
41
44
|
json
|
42
45
|
logger
|
43
46
|
faraday-net_http (3.4.0)
|
44
47
|
net-http (>= 0.5.0)
|
45
|
-
i18n (1.14.
|
48
|
+
i18n (1.14.7)
|
46
49
|
concurrent-ruby (~> 1.0)
|
47
|
-
json (2.
|
50
|
+
json (2.11.3)
|
51
|
+
language_server-protocol (3.17.0.4)
|
48
52
|
licensee (9.18.0)
|
49
53
|
dotenv (>= 2, < 4)
|
50
54
|
octokit (>= 4.20, < 10.0)
|
51
55
|
reverse_markdown (>= 1, < 4)
|
52
56
|
rugged (>= 0.24, < 2.0)
|
53
57
|
thor (>= 0.19, < 2.0)
|
54
|
-
|
58
|
+
lint_roller (1.1.0)
|
59
|
+
logger (1.6.6)
|
55
60
|
mini_portile2 (2.8.8)
|
56
|
-
minitest (5.25.
|
61
|
+
minitest (5.25.5)
|
57
62
|
minitest-hooks (1.5.2)
|
58
63
|
minitest (> 5.3)
|
59
64
|
mocha (2.7.1)
|
60
65
|
ruby2_keywords (>= 0.0.5)
|
61
|
-
|
62
|
-
net-http (0.5.0)
|
66
|
+
net-http (0.6.0)
|
63
67
|
uri
|
64
|
-
nokogiri (1.
|
68
|
+
nokogiri (1.18.8)
|
65
69
|
mini_portile2 (~> 2.8.2)
|
66
70
|
racc (~> 1.4)
|
67
71
|
octokit (9.2.0)
|
68
72
|
faraday (>= 1, < 3)
|
69
73
|
sawyer (~> 0.9)
|
70
|
-
parallel (1.
|
71
|
-
parser (3.
|
74
|
+
parallel (1.27.0)
|
75
|
+
parser (3.3.7.1)
|
72
76
|
ast (~> 2.4.1)
|
77
|
+
racc
|
73
78
|
pathname-common_prefix (0.0.2)
|
74
79
|
public_suffix (6.0.1)
|
75
80
|
racc (1.8.1)
|
76
|
-
rack (3.
|
81
|
+
rack (3.1.12)
|
77
82
|
rainbow (3.1.1)
|
78
83
|
rake (13.2.1)
|
79
|
-
regexp_parser (2.
|
84
|
+
regexp_parser (2.10.0)
|
80
85
|
reverse_markdown (3.0.0)
|
81
86
|
nokogiri
|
82
|
-
|
83
|
-
rubocop (1.45.1)
|
87
|
+
rubocop (1.73.2)
|
84
88
|
json (~> 2.3)
|
89
|
+
language_server-protocol (~> 3.17.0.2)
|
90
|
+
lint_roller (~> 1.1.0)
|
85
91
|
parallel (~> 1.10)
|
86
|
-
parser (>= 3.
|
92
|
+
parser (>= 3.3.0.2)
|
87
93
|
rainbow (>= 2.2.2, < 4.0)
|
88
|
-
regexp_parser (>=
|
89
|
-
|
90
|
-
rubocop-ast (>= 1.24.1, < 2.0)
|
94
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
95
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
91
96
|
ruby-progressbar (~> 1.7)
|
92
|
-
unicode-display_width (>= 2.4.0, <
|
93
|
-
rubocop-ast (1.
|
94
|
-
parser (>= 3.
|
95
|
-
rubocop-github (0.
|
96
|
-
rubocop (>= 1.
|
97
|
-
rubocop-performance (>= 1.
|
98
|
-
rubocop-rails (>= 2.
|
99
|
-
rubocop-performance (1.
|
100
|
-
|
101
|
-
rubocop
|
102
|
-
|
97
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
98
|
+
rubocop-ast (1.38.1)
|
99
|
+
parser (>= 3.3.1.0)
|
100
|
+
rubocop-github (0.23.0)
|
101
|
+
rubocop (>= 1.72)
|
102
|
+
rubocop-performance (>= 1.24)
|
103
|
+
rubocop-rails (>= 2.23)
|
104
|
+
rubocop-performance (1.24.0)
|
105
|
+
lint_roller (~> 1.1)
|
106
|
+
rubocop (>= 1.72.1, < 2.0)
|
107
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
108
|
+
rubocop-rails (2.30.3)
|
103
109
|
activesupport (>= 4.2.0)
|
110
|
+
lint_roller (~> 1.1)
|
104
111
|
rack (>= 1.1)
|
105
|
-
rubocop (>= 1.
|
106
|
-
|
112
|
+
rubocop (>= 1.72.1, < 2.0)
|
113
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
114
|
+
ruby-progressbar (1.13.0)
|
107
115
|
ruby-xxHash (0.4.0.2)
|
108
116
|
ruby2_keywords (0.0.5)
|
109
|
-
rugged (1.
|
117
|
+
rugged (1.9.0)
|
110
118
|
sawyer (0.9.2)
|
111
119
|
addressable (>= 2.3.5)
|
112
120
|
faraday (>= 0.17.3, < 3)
|
121
|
+
securerandom (0.4.1)
|
113
122
|
thor (1.3.2)
|
114
123
|
tomlrb (2.0.3)
|
115
124
|
tzinfo (2.0.6)
|
116
125
|
concurrent-ruby (~> 1.0)
|
117
|
-
unicode-display_width (
|
118
|
-
|
126
|
+
unicode-display_width (3.1.4)
|
127
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
128
|
+
unicode-emoji (4.0.4)
|
129
|
+
uri (1.0.3)
|
119
130
|
|
120
131
|
PLATFORMS
|
121
132
|
ruby
|
122
133
|
|
123
134
|
DEPENDENCIES
|
124
|
-
byebug (~>
|
135
|
+
byebug (~> 12.0)
|
125
136
|
licensed!
|
126
137
|
minitest (~> 5.17)
|
127
138
|
minitest-hooks (~> 1.5)
|
@@ -228,7 +228,7 @@ module Licensed
|
|
228
228
|
# return the root directory name
|
229
229
|
return root_path_parts[-1] if source_path_parts == root_path_parts
|
230
230
|
|
231
|
-
if source_path_parts[0..root_path_parts.size-1] != root_path_parts
|
231
|
+
if source_path_parts[0..root_path_parts.size - 1] != root_path_parts
|
232
232
|
raise Licensed::Configuration::LoadError,
|
233
233
|
"source_path must be a descendent of the app root to generate an app name from the relative source_path"
|
234
234
|
end
|
data/lib/licensed/git.rb
CHANGED
@@ -1,49 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Licensed
|
3
3
|
module Git
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
4
|
+
# Returns whether git commands are available
|
5
|
+
def self.available?
|
6
|
+
@git ||= Licensed::Shell.tool_available?("git")
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
# Returns the root of the current git repository
|
10
|
+
# or nil if not in a git repository.
|
11
|
+
def self.repository_root
|
12
|
+
return unless available?
|
13
|
+
root = Licensed::Shell.execute("git", "rev-parse", "--show-toplevel", allow_failure: true)
|
14
|
+
return nil if root.empty?
|
15
|
+
root
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
# Returns true if a git repository is found, false otherwise
|
19
|
+
def self.git_repo?
|
20
|
+
!repository_root.to_s.empty?
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
# Returns the most recent git SHA for a file or directory
|
24
|
+
# or nil if SHA is not available
|
25
|
+
#
|
26
|
+
# descriptor - file or directory to retrieve latest SHA for
|
27
|
+
def self.version(descriptor)
|
28
|
+
return unless git_repo? && descriptor
|
29
|
+
Licensed::Shell.execute("git", "rev-list", "-1", "HEAD", "--", descriptor, allow_failure: true)
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
# Returns the commit date for the provided SHA as a timestamp
|
33
|
+
#
|
34
|
+
# sha - commit sha to retrieve date
|
35
|
+
def self.commit_date(sha)
|
36
|
+
return unless git_repo? && sha
|
37
|
+
Licensed::Shell.execute("git", "show", "-s", "-1", "--format=%ct", sha)
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
40
|
+
# Returns the files in the git repository from `git ls-files --recurse-submodules`
|
41
|
+
def self.files
|
42
|
+
return unless git_repo?
|
43
|
+
output = Licensed::Shell.execute("git", "ls-files", "--full-name", "--recurse-submodules")
|
44
|
+
output.lines.map(&:strip)
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
data/lib/licensed/shell.rb
CHANGED
@@ -13,11 +13,9 @@ module Licensed
|
|
13
13
|
GRADLE_LICENSES_PATH = ".gradle-licenses".freeze
|
14
14
|
GRADLE_LICENSES_CSV_NAME = "licenses.csv".freeze
|
15
15
|
class Dependency < Licensed::Dependency
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
(@licenses ||= {})[url] ||= Net::HTTP.get(URI(url))
|
20
|
-
end
|
16
|
+
# Cache and return the results of getting the license content.
|
17
|
+
def self.retrieve_license(url)
|
18
|
+
(@licenses ||= {})[url] ||= Net::HTTP.get(URI(url))
|
21
19
|
end
|
22
20
|
|
23
21
|
def initialize(name:, version:, path:, url:, metadata: {})
|
@@ -106,59 +106,57 @@ module Licensed
|
|
106
106
|
@nuspec_remote_license_file = Licensee::ProjectFiles::LicenseFile.new(license_content, { uri: match[1] }) if license_content
|
107
107
|
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
return unless html
|
109
|
+
def self.strip_html(html)
|
110
|
+
return unless html
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
return html unless html.downcase.include?("<html")
|
113
|
+
ReverseMarkdown.convert(html, unknown_tags: :bypass)
|
114
|
+
end
|
116
115
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
116
|
+
def self.ignored_url?(url)
|
117
|
+
# Many Microsoft packages that now use <license> use this for <licenseUrl>
|
118
|
+
# No need to fetch this page - it just contains NuGet documentation
|
119
|
+
url == "https://aka.ms/deprecateLicenseUrl"
|
120
|
+
end
|
122
121
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
def self.text_content_url(url)
|
123
|
+
# Convert github file URLs to raw URLs
|
124
|
+
return url unless match = url.match(/https?:\/\/(?:www\.)?github.com\/([^\/]+)\/([^\/]+)\/blob\/(.*)/i)
|
125
|
+
"https://github.com/#{match[1]}/#{match[2]}/raw/#{match[3]}"
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
def self.retrieve_license(url)
|
129
|
+
return unless url
|
130
|
+
return if ignored_url?(url)
|
132
131
|
|
133
|
-
|
134
|
-
|
132
|
+
# Transform URLs that are known to return HTML but have a corresponding text-based URL
|
133
|
+
text_url = text_content_url(url)
|
135
134
|
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
raw_content = fetch_content(text_url)
|
136
|
+
strip_html(raw_content)
|
137
|
+
end
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
155
|
-
# The redirect might be to a URL that requires transformation, i.e. a github file
|
156
|
-
redirect_url = text_content_url(redirect_url.to_s)
|
157
|
-
@response_by_url[url] = fetch_content(redirect_url, redirect_limit - 1)
|
139
|
+
def self.fetch_content(url, redirect_limit = 5)
|
140
|
+
url = URI.parse(url) if url.instance_of? String
|
141
|
+
return @response_by_url[url] if (@response_by_url ||= {}).key?(url)
|
142
|
+
return if redirect_limit == 0
|
143
|
+
|
144
|
+
begin
|
145
|
+
response = Net::HTTP.get_response(url)
|
146
|
+
case response
|
147
|
+
when Net::HTTPSuccess then
|
148
|
+
@response_by_url[url] = response.body
|
149
|
+
when Net::HTTPRedirection then
|
150
|
+
redirect_url = URI.parse(response["location"])
|
151
|
+
if redirect_url.relative?
|
152
|
+
redirect_url = url + redirect_url
|
158
153
|
end
|
159
|
-
|
160
|
-
|
154
|
+
# The redirect might be to a URL that requires transformation, i.e. a github file
|
155
|
+
redirect_url = text_content_url(redirect_url.to_s)
|
156
|
+
@response_by_url[url] = fetch_content(redirect_url, redirect_limit - 1)
|
161
157
|
end
|
158
|
+
rescue
|
159
|
+
# Host might no longer exist or some other error, ignore
|
162
160
|
end
|
163
161
|
end
|
164
162
|
end
|
data/lib/licensed/sources/pip.rb
CHANGED
@@ -7,8 +7,6 @@ require "parallel"
|
|
7
7
|
module Licensed
|
8
8
|
module Sources
|
9
9
|
class Pip < Source
|
10
|
-
PACKAGE_INFO_SEPARATOR = "\n---\n"
|
11
|
-
|
12
10
|
def enabled?
|
13
11
|
!pip_command.empty? && Licensed::Shell.tool_available?(pip_command.join(""))
|
14
12
|
end
|
@@ -41,7 +39,7 @@ module Licensed
|
|
41
39
|
# Returns the location of license files in the package, checking for the inclusion of a new `license_files`
|
42
40
|
# folder per https://peps.python.org/pep-0639/
|
43
41
|
def package_license_location(package)
|
44
|
-
dist_info = File.join(package["Location"], package["Name"].gsub("-", "_") +
|
42
|
+
dist_info = File.join(package["Location"], package["Name"].gsub("-", "_") + "-" + package["Version"] + ".dist-info")
|
45
43
|
|
46
44
|
license_path = ["license_files", "licenses"]
|
47
45
|
.map { |directory| File.join(dist_info, directory) }
|
@@ -54,8 +52,12 @@ module Licensed
|
|
54
52
|
# using `pip list` to determine what packages are used and `pip show`
|
55
53
|
# to gather package information
|
56
54
|
def packages
|
57
|
-
|
58
|
-
|
55
|
+
# Handle case where package show command actually includes the separator inside the package info
|
56
|
+
# This is a workaround for the fact that pip show does not have a way to specify a custom separator
|
57
|
+
# Not counting on the package separator here but instead doing them one by one.
|
58
|
+
all_packages = Parallel.map(package_names, in_threads: 4) { |package| pip_show_command(package) }
|
59
|
+
|
60
|
+
all_packages.reduce([]) do |accum, val|
|
59
61
|
accum << parse_package_info(val)
|
60
62
|
end
|
61
63
|
end
|
@@ -89,8 +91,8 @@ module Licensed
|
|
89
91
|
end
|
90
92
|
|
91
93
|
# Returns the output from `pip show <package> <package> ...`
|
92
|
-
def pip_show_command(
|
93
|
-
Licensed::Shell.execute(*pip_command, "--disable-pip-version-check", "show",
|
94
|
+
def pip_show_command(package)
|
95
|
+
Licensed::Shell.execute(*pip_command, "--disable-pip-version-check", "show", package)
|
94
96
|
end
|
95
97
|
|
96
98
|
def virtual_env_dir
|
@@ -18,19 +18,24 @@ module Licensed
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def enumerate_dependencies
|
21
|
-
packages.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
packages.flat_map do |package|
|
22
|
+
versions = package.key?("versions") ? package["versions"] : [package["version"]]
|
23
|
+
paths = package.key?("paths") ? package["paths"] : [package["path"]]
|
24
|
+
|
25
|
+
versions.zip(paths).map do |version, path|
|
26
|
+
name_with_version = "#{package["name"]}@#{version}"
|
27
|
+
Dependency.new(
|
28
|
+
name: name_with_version,
|
29
|
+
version: version,
|
30
|
+
path: path,
|
31
|
+
metadata: {
|
32
|
+
"type" => PNPM.type,
|
33
|
+
"name" => package["name"],
|
34
|
+
"summary" => package["description"],
|
35
|
+
"homepage" => package["homepage"]
|
36
|
+
}
|
37
|
+
)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
@@ -13,50 +13,56 @@ module Licensed
|
|
13
13
|
|
14
14
|
class << self
|
15
15
|
attr_reader :sources
|
16
|
-
def inherited(klass)
|
17
|
-
# register the inherited class as a source on the Licensed::Sources::Source class
|
18
|
-
Licensed::Sources::Source.register_source(klass)
|
19
|
-
end
|
20
16
|
|
21
|
-
def register_source(klass)
|
22
|
-
# add the source class to the known sources list
|
23
|
-
return unless klass < Licensed::Sources::Source
|
24
|
-
(@sources ||= []) << klass
|
25
|
-
end
|
26
17
|
|
27
|
-
# Returns the source name as the first snake cased class or module name
|
28
|
-
# following "Licensed::Sources::". This is the type that is included
|
29
|
-
# in metadata files and cache paths.
|
30
|
-
# e.g. for `Licensed::Sources::Yarn::V1`, this returns "yarn"
|
31
|
-
def type
|
32
|
-
type_and_version[0]
|
33
|
-
end
|
34
18
|
|
35
|
-
# Returns the source name as a "/" delimited string of all the module and
|
36
|
-
# class names following "Licensed::Sources::". This is the type that is
|
37
|
-
# used to distinguish multiple versions of a sources from each other.
|
38
|
-
# e.g. for `Licensed::Sources::Yarn::V1`, this returns `yarn/v1`
|
39
|
-
def full_type
|
40
|
-
type_and_version.join("/")
|
41
|
-
end
|
42
19
|
|
43
|
-
# Returns an array that includes the source's type name at the first index, and
|
44
|
-
# optionally a version string for the source as the second index.
|
45
|
-
# Callers should override this function and not `type` or `full_type` when
|
46
|
-
# needing to adjust the default type and version parsing logic
|
47
|
-
def type_and_version
|
48
|
-
self.name.gsub("#{Licensed::Sources.name}::", "")
|
49
|
-
.gsub(/([A-Z\d]+)([A-Z][a-z])/, "\\1_\\2".freeze)
|
50
|
-
.gsub(/([a-z\d])([A-Z])/, "\\1_\\2".freeze)
|
51
|
-
.downcase
|
52
|
-
.split("::")
|
53
|
-
end
|
54
20
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.inherited(klass)
|
24
|
+
# register the inherited class as a source on the Licensed::Sources::Source class
|
25
|
+
Licensed::Sources::Source.register_source(klass)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.register_source(klass)
|
29
|
+
# add the source class to the known sources list
|
30
|
+
return unless klass < Licensed::Sources::Source
|
31
|
+
(@sources ||= []) << klass
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the source name as the first snake cased class or module name
|
35
|
+
# following "Licensed::Sources::". This is the type that is included
|
36
|
+
# in metadata files and cache paths.
|
37
|
+
# e.g. for `Licensed::Sources::Yarn::V1`, this returns "yarn"
|
38
|
+
def self.type
|
39
|
+
type_and_version[0]
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the source name as a "/" delimited string of all the module and
|
43
|
+
# class names following "Licensed::Sources::". This is the type that is
|
44
|
+
# used to distinguish multiple versions of a sources from each other.
|
45
|
+
# e.g. for `Licensed::Sources::Yarn::V1`, this returns `yarn/v1`
|
46
|
+
def self.full_type
|
47
|
+
type_and_version.join("/")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns an array that includes the source's type name at the first index, and
|
51
|
+
# optionally a version string for the source as the second index.
|
52
|
+
# Callers should override this function and not `type` or `full_type` when
|
53
|
+
# needing to adjust the default type and version parsing logic
|
54
|
+
def self.type_and_version
|
55
|
+
self.name.gsub("#{Licensed::Sources.name}::", "")
|
56
|
+
.gsub(/([A-Z\d]+)([A-Z][a-z])/, "\\1_\\2".freeze)
|
57
|
+
.gsub(/([a-z\d])([A-Z])/, "\\1_\\2".freeze)
|
58
|
+
.downcase
|
59
|
+
.split("::")
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns true if the source requires matching reviewed and ignored dependencies'
|
63
|
+
# versions as well as their name
|
64
|
+
def self.require_matched_dependency_version
|
65
|
+
false
|
60
66
|
end
|
61
67
|
|
62
68
|
# all sources have a configuration
|
data/lib/licensed/version.rb
CHANGED
data/licensed.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.required_ruby_version = ">= 3.
|
24
|
+
spec.required_ruby_version = ">= 3.1.0"
|
25
25
|
|
26
26
|
spec.add_dependency "csv", "~> 3.3"
|
27
27
|
spec.add_dependency "licensee", "~> 9.16"
|
@@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "minitest-hooks", "~> 1.5"
|
39
39
|
spec.add_development_dependency "mocha", "~> 2.0"
|
40
40
|
spec.add_development_dependency "rubocop-github", "~> 0.20"
|
41
|
-
spec.add_development_dependency "byebug", "~>
|
41
|
+
spec.add_development_dependency "byebug", "~> 12.0"
|
42
42
|
end
|