bibliothecary 14.4.0 → 15.0.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 +4 -4
- data/CHANGELOG.md +14 -0
- data/UPGRADING_TO_15_0_0.md +264 -0
- data/lib/bibliothecary/analyser/analysis.rb +2 -2
- data/lib/bibliothecary/analyser.rb +24 -20
- data/lib/bibliothecary/dependency.rb +1 -4
- data/lib/bibliothecary/file_info.rb +7 -3
- data/lib/bibliothecary/multi_parsers/cyclonedx.rb +24 -21
- data/lib/bibliothecary/multi_parsers/dependencies_csv.rb +7 -4
- data/lib/bibliothecary/multi_parsers/spdx.rb +40 -26
- data/lib/bibliothecary/{multi_parsers → parser_mixins}/bundler_like_manifest.rb +1 -1
- data/lib/bibliothecary/{multi_parsers → parser_mixins}/json_runtime.rb +1 -1
- data/lib/bibliothecary/parsers/bower.rb +0 -2
- data/lib/bibliothecary/parsers/cargo.rb +0 -4
- data/lib/bibliothecary/parsers/cocoapods.rb +1 -3
- data/lib/bibliothecary/parsers/conan.rb +0 -4
- data/lib/bibliothecary/parsers/conda.rb +0 -4
- data/lib/bibliothecary/parsers/cpan.rb +0 -2
- data/lib/bibliothecary/parsers/cran.rb +0 -4
- data/lib/bibliothecary/parsers/dub.rb +1 -3
- data/lib/bibliothecary/parsers/elm.rb +1 -3
- data/lib/bibliothecary/parsers/go.rb +0 -4
- data/lib/bibliothecary/parsers/haxelib.rb +1 -3
- data/lib/bibliothecary/parsers/julia.rb +0 -2
- data/lib/bibliothecary/parsers/maven.rb +0 -4
- data/lib/bibliothecary/parsers/meteor.rb +1 -3
- data/lib/bibliothecary/parsers/npm.rb +0 -4
- data/lib/bibliothecary/parsers/nuget.rb +1 -5
- data/lib/bibliothecary/parsers/packagist.rb +0 -4
- data/lib/bibliothecary/parsers/pub.rb +0 -2
- data/lib/bibliothecary/parsers/pypi.rb +0 -4
- data/lib/bibliothecary/parsers/rubygems.rb +1 -5
- data/lib/bibliothecary/parsers/shard.rb +0 -2
- data/lib/bibliothecary/parsers/vcpkg.rb +0 -4
- data/lib/bibliothecary/related_files_info.rb +19 -15
- data/lib/bibliothecary/runner/multi_manifest_filter.rb +2 -83
- data/lib/bibliothecary/runner.rb +40 -23
- data/lib/bibliothecary/version.rb +1 -1
- data/lib/bibliothecary.rb +16 -3
- metadata +5 -4
data/lib/bibliothecary/runner.rb
CHANGED
|
@@ -15,17 +15,17 @@ module Bibliothecary
|
|
|
15
15
|
def analyse(path, ignore_unparseable_files: true)
|
|
16
16
|
info_list = load_file_info_list(path)
|
|
17
17
|
|
|
18
|
-
info_list = info_list.reject { |info| info.
|
|
18
|
+
info_list = info_list.reject { |info| info.parser.nil? } if ignore_unparseable_files
|
|
19
19
|
|
|
20
20
|
# Each package manager needs to see its entire list so it can
|
|
21
21
|
# associate related manifests and lockfiles for example.
|
|
22
|
-
analyses =
|
|
23
|
-
matching_infos = info_list.select { |info| info.
|
|
24
|
-
|
|
22
|
+
analyses = parsers.map do |p|
|
|
23
|
+
matching_infos = info_list.select { |info| info.parser == p }
|
|
24
|
+
p.analyse_file_info(matching_infos, options: @options)
|
|
25
25
|
end
|
|
26
26
|
analyses = analyses.flatten.compact
|
|
27
27
|
|
|
28
|
-
info_list.select { |info| info.
|
|
28
|
+
info_list.select { |info| info.parser.nil? }.each do |info|
|
|
29
29
|
analyses.push(Bibliothecary::Analyser.create_error_analysis("unknown", info.relative_path, "unknown",
|
|
30
30
|
"No parser for this file type"))
|
|
31
31
|
end
|
|
@@ -39,13 +39,26 @@ module Bibliothecary
|
|
|
39
39
|
load_file_info_list(path).map(&:full_path)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def applicable_package_managers(
|
|
43
|
-
|
|
42
|
+
def applicable_package_managers(_info)
|
|
43
|
+
raise "Runner#applicable_package_managers() has been removed in bibliothecary 15.0.0. Use applicable_parsers() instead, which now includes MultiParsers."
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def applicable_parsers(info)
|
|
47
|
+
managers = parsers.select { |p| p.match_info?(info) }
|
|
44
48
|
managers.empty? ? [nil] : managers
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
def package_managers
|
|
48
|
-
|
|
52
|
+
raise "Runner#applicable_package_managers() has been removed in bibliothecary 15.0.0. Use applicable_parsers() instead, which now includes MultiParsers."
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def parsers
|
|
56
|
+
[Bibliothecary::Parsers, Bibliothecary::MultiParsers]
|
|
57
|
+
.flat_map do |mod|
|
|
58
|
+
mod.constants
|
|
59
|
+
.map { |c| mod.const_get(c) }
|
|
60
|
+
.sort_by { |c| c.to_s.downcase }
|
|
61
|
+
end
|
|
49
62
|
end
|
|
50
63
|
|
|
51
64
|
# Parses an array of format [{file_path: "", contents: ""},] to match
|
|
@@ -60,7 +73,7 @@ module Bibliothecary
|
|
|
60
73
|
|
|
61
74
|
next if ignored_files.include?(info.relative_path)
|
|
62
75
|
|
|
63
|
-
|
|
76
|
+
add_matching_parsers_for_file_to_list(file_list, info)
|
|
64
77
|
end
|
|
65
78
|
|
|
66
79
|
file_list
|
|
@@ -74,7 +87,7 @@ module Bibliothecary
|
|
|
74
87
|
|
|
75
88
|
next if ignored_files.include?(info.relative_path)
|
|
76
89
|
|
|
77
|
-
|
|
90
|
+
add_matching_parsers_for_file_to_list(file_list, info)
|
|
78
91
|
end
|
|
79
92
|
|
|
80
93
|
file_list
|
|
@@ -90,7 +103,7 @@ module Bibliothecary
|
|
|
90
103
|
next unless FileTest.file?(subpath)
|
|
91
104
|
next if ignored_files.include?(info.relative_path)
|
|
92
105
|
|
|
93
|
-
|
|
106
|
+
add_matching_parsers_for_file_to_list(file_list, info)
|
|
94
107
|
end
|
|
95
108
|
|
|
96
109
|
file_list
|
|
@@ -100,11 +113,11 @@ module Bibliothecary
|
|
|
100
113
|
#
|
|
101
114
|
# @return [Array<Bibliothecary::RelatedFilesInfo>]
|
|
102
115
|
def find_manifests(path)
|
|
103
|
-
RelatedFilesInfo.create_from_file_infos(load_file_info_list(path).reject { |info| info.
|
|
116
|
+
RelatedFilesInfo.create_from_file_infos(load_file_info_list(path).reject { |info| info.parser.nil? })
|
|
104
117
|
end
|
|
105
118
|
|
|
106
119
|
def find_manifests_from_paths(paths)
|
|
107
|
-
RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_paths(paths).reject { |info| info.
|
|
120
|
+
RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_paths(paths).reject { |info| info.parser.nil? })
|
|
108
121
|
end
|
|
109
122
|
|
|
110
123
|
# file_path_contents_hash contains an Array of { file_path, contents }
|
|
@@ -112,7 +125,7 @@ module Bibliothecary
|
|
|
112
125
|
RelatedFilesInfo.create_from_file_infos(
|
|
113
126
|
load_file_info_list_from_contents(
|
|
114
127
|
file_path_contents_hash
|
|
115
|
-
).reject { |info| info.
|
|
128
|
+
).reject { |info| info.parser.nil? }
|
|
116
129
|
)
|
|
117
130
|
end
|
|
118
131
|
|
|
@@ -120,8 +133,8 @@ module Bibliothecary
|
|
|
120
133
|
def analyse_file(file_path, contents)
|
|
121
134
|
contents = Bibliothecary.utf8_string(contents)
|
|
122
135
|
|
|
123
|
-
|
|
124
|
-
|
|
136
|
+
parsers.select { |p| p.match?(file_path, contents) }.map do |p|
|
|
137
|
+
p.analyse_contents(file_path, contents, options: @options)
|
|
125
138
|
end.flatten.uniq.compact
|
|
126
139
|
end
|
|
127
140
|
alias analyze_file analyse_file
|
|
@@ -137,12 +150,12 @@ module Bibliothecary
|
|
|
137
150
|
ignored_dirs.include?(f) || f.start_with?(*ignored_dirs_with_slash)
|
|
138
151
|
end
|
|
139
152
|
allowed_file_list = allowed_file_list.reject { |f| ignored_files.include?(f) }
|
|
140
|
-
|
|
153
|
+
parsers.map do |p|
|
|
141
154
|
# (skip rubocop false positive, since match? is a custom method)
|
|
142
155
|
allowed_file_list.select do |file_path| # rubocop:disable Style/SelectByRegexp
|
|
143
156
|
# this is a call to match? without file contents, which will skip
|
|
144
157
|
# ambiguous filenames that are only possibly a manifest
|
|
145
|
-
|
|
158
|
+
p.match?(file_path)
|
|
146
159
|
end
|
|
147
160
|
end.flatten.uniq.compact
|
|
148
161
|
end
|
|
@@ -161,19 +174,23 @@ module Bibliothecary
|
|
|
161
174
|
#
|
|
162
175
|
# This means we're likely analyzing these files twice in processing,
|
|
163
176
|
# but we need that accurate package manager information.
|
|
164
|
-
def filter_multi_manifest_entries(
|
|
165
|
-
|
|
177
|
+
def filter_multi_manifest_entries(_path, _related_files_info_entries)
|
|
178
|
+
raise "Bibliothecary::Runner#filter_multi_manifest_entries() has been removed in bibliothecary 15.0.0. Since MultiParsers now act like Parsers, there is no replacement or need for it."
|
|
166
179
|
end
|
|
167
180
|
|
|
168
181
|
private
|
|
169
182
|
|
|
183
|
+
def add_matching_package_managers_for_file_to_list(_file_list, _file_info)
|
|
184
|
+
raise "Runner#add_matching_package_managers_for_file_to_list() has been removed in bibliothecary 15.0.0. Use add_matching_parsers_for_file_to_list() instead, which now includes MultiParsers."
|
|
185
|
+
end
|
|
186
|
+
|
|
170
187
|
# Get the list of all package managers that apply to the file provided
|
|
171
188
|
# as file_info, and, for each one, duplicate file_info and fill in
|
|
172
189
|
# the appropriate package manager.
|
|
173
|
-
def
|
|
174
|
-
|
|
190
|
+
def add_matching_parsers_for_file_to_list(file_list, file_info)
|
|
191
|
+
applicable_parsers(file_info).each do |parser|
|
|
175
192
|
new_file_info = file_info.dup
|
|
176
|
-
new_file_info.
|
|
193
|
+
new_file_info.parser = parser
|
|
177
194
|
|
|
178
195
|
file_list.push(new_file_info)
|
|
179
196
|
end
|
data/lib/bibliothecary.rb
CHANGED
|
@@ -13,9 +13,14 @@ require "bibliothecary/purl_util"
|
|
|
13
13
|
require "find"
|
|
14
14
|
require "tomlrb"
|
|
15
15
|
|
|
16
|
+
Dir[File.expand_path("bibliothecary/parser_mixins/*.rb", __dir__)].each do |file|
|
|
17
|
+
require file
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
Dir[File.expand_path("bibliothecary/multi_parsers/*.rb", __dir__)].each do |file|
|
|
17
21
|
require file
|
|
18
22
|
end
|
|
23
|
+
|
|
19
24
|
Dir[File.expand_path("bibliothecary/parsers/*.rb", __dir__)].each do |file|
|
|
20
25
|
require file
|
|
21
26
|
end
|
|
@@ -33,8 +38,12 @@ module Bibliothecary
|
|
|
33
38
|
runner.load_file_list(path)
|
|
34
39
|
end
|
|
35
40
|
|
|
36
|
-
def self.applicable_package_managers(
|
|
37
|
-
|
|
41
|
+
def self.applicable_package_managers(_info)
|
|
42
|
+
raise "Bibliothecary.applicable_package_managers() has been removed in bibliothecary 15.0.0. Use parsers() instead, which now includes MultiParsers."
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.applicable_parsers(info)
|
|
46
|
+
runner.applicable_parsers(info)
|
|
38
47
|
end
|
|
39
48
|
|
|
40
49
|
def self.load_file_info_list(path)
|
|
@@ -58,7 +67,11 @@ module Bibliothecary
|
|
|
58
67
|
end
|
|
59
68
|
|
|
60
69
|
def self.package_managers
|
|
61
|
-
|
|
70
|
+
raise "Bibliothecary.package_managers() has been removed in bibliothecary 15.0.0. Use parsers() instead, which now includes MultiParsers."
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.parsers
|
|
74
|
+
runner.parsers
|
|
62
75
|
end
|
|
63
76
|
|
|
64
77
|
def self.find_manifests(path)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bibliothecary
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 15.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Nesbitt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: commander
|
|
@@ -160,6 +160,7 @@ files:
|
|
|
160
160
|
- LICENSE.txt
|
|
161
161
|
- README.md
|
|
162
162
|
- Rakefile
|
|
163
|
+
- UPGRADING_TO_15_0_0.md
|
|
163
164
|
- bibliothecary.gemspec
|
|
164
165
|
- bin/bibliothecary
|
|
165
166
|
- bin/console
|
|
@@ -174,11 +175,11 @@ files:
|
|
|
174
175
|
- lib/bibliothecary/dependency.rb
|
|
175
176
|
- lib/bibliothecary/exceptions.rb
|
|
176
177
|
- lib/bibliothecary/file_info.rb
|
|
177
|
-
- lib/bibliothecary/multi_parsers/bundler_like_manifest.rb
|
|
178
178
|
- lib/bibliothecary/multi_parsers/cyclonedx.rb
|
|
179
179
|
- lib/bibliothecary/multi_parsers/dependencies_csv.rb
|
|
180
|
-
- lib/bibliothecary/multi_parsers/json_runtime.rb
|
|
181
180
|
- lib/bibliothecary/multi_parsers/spdx.rb
|
|
181
|
+
- lib/bibliothecary/parser_mixins/bundler_like_manifest.rb
|
|
182
|
+
- lib/bibliothecary/parser_mixins/json_runtime.rb
|
|
182
183
|
- lib/bibliothecary/parser_result.rb
|
|
183
184
|
- lib/bibliothecary/parsers/bower.rb
|
|
184
185
|
- lib/bibliothecary/parsers/cargo.rb
|