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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/UPGRADING_TO_15_0_0.md +264 -0
  4. data/lib/bibliothecary/analyser/analysis.rb +2 -2
  5. data/lib/bibliothecary/analyser.rb +24 -20
  6. data/lib/bibliothecary/dependency.rb +1 -4
  7. data/lib/bibliothecary/file_info.rb +7 -3
  8. data/lib/bibliothecary/multi_parsers/cyclonedx.rb +24 -21
  9. data/lib/bibliothecary/multi_parsers/dependencies_csv.rb +7 -4
  10. data/lib/bibliothecary/multi_parsers/spdx.rb +40 -26
  11. data/lib/bibliothecary/{multi_parsers → parser_mixins}/bundler_like_manifest.rb +1 -1
  12. data/lib/bibliothecary/{multi_parsers → parser_mixins}/json_runtime.rb +1 -1
  13. data/lib/bibliothecary/parsers/bower.rb +0 -2
  14. data/lib/bibliothecary/parsers/cargo.rb +0 -4
  15. data/lib/bibliothecary/parsers/cocoapods.rb +1 -3
  16. data/lib/bibliothecary/parsers/conan.rb +0 -4
  17. data/lib/bibliothecary/parsers/conda.rb +0 -4
  18. data/lib/bibliothecary/parsers/cpan.rb +0 -2
  19. data/lib/bibliothecary/parsers/cran.rb +0 -4
  20. data/lib/bibliothecary/parsers/dub.rb +1 -3
  21. data/lib/bibliothecary/parsers/elm.rb +1 -3
  22. data/lib/bibliothecary/parsers/go.rb +0 -4
  23. data/lib/bibliothecary/parsers/haxelib.rb +1 -3
  24. data/lib/bibliothecary/parsers/julia.rb +0 -2
  25. data/lib/bibliothecary/parsers/maven.rb +0 -4
  26. data/lib/bibliothecary/parsers/meteor.rb +1 -3
  27. data/lib/bibliothecary/parsers/npm.rb +0 -4
  28. data/lib/bibliothecary/parsers/nuget.rb +1 -5
  29. data/lib/bibliothecary/parsers/packagist.rb +0 -4
  30. data/lib/bibliothecary/parsers/pub.rb +0 -2
  31. data/lib/bibliothecary/parsers/pypi.rb +0 -4
  32. data/lib/bibliothecary/parsers/rubygems.rb +1 -5
  33. data/lib/bibliothecary/parsers/shard.rb +0 -2
  34. data/lib/bibliothecary/parsers/vcpkg.rb +0 -4
  35. data/lib/bibliothecary/related_files_info.rb +19 -15
  36. data/lib/bibliothecary/runner/multi_manifest_filter.rb +2 -83
  37. data/lib/bibliothecary/runner.rb +40 -23
  38. data/lib/bibliothecary/version.rb +1 -1
  39. data/lib/bibliothecary.rb +16 -3
  40. metadata +5 -4
@@ -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.package_manager.nil? } if ignore_unparseable_files
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 = package_managers.map do |pm|
23
- matching_infos = info_list.select { |info| info.package_manager == pm }
24
- pm.analyse_file_info(matching_infos, options: @options)
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.package_manager.nil? }.each do |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(info)
43
- managers = package_managers.select { |pm| pm.match_info?(info) }
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
- Bibliothecary::Parsers.constants.map { |c| Bibliothecary::Parsers.const_get(c) }.sort_by { |c| c.to_s.downcase }
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
- add_matching_package_managers_for_file_to_list(file_list, info)
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
- add_matching_package_managers_for_file_to_list(file_list, info)
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
- add_matching_package_managers_for_file_to_list(file_list, info)
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.package_manager.nil? })
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.package_manager.nil? })
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.package_manager.nil? }
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
- package_managers.select { |pm| pm.match?(file_path, contents) }.map do |pm|
124
- pm.analyse_contents(file_path, contents, options: @options)
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
- package_managers.map do |pm|
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
- pm.match?(file_path)
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(path, related_files_info_entries)
165
- MultiManifestFilter.new(path: path, related_files_info_entries: related_files_info_entries, runner: self).results
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 add_matching_package_managers_for_file_to_list(file_list, file_info)
174
- applicable_package_managers(file_info).each do |package_manager|
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.package_manager = package_manager
193
+ new_file_info.parser = parser
177
194
 
178
195
  file_list.push(new_file_info)
179
196
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bibliothecary
4
- VERSION = "14.4.0"
4
+ VERSION = "15.0.0"
5
5
  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(info)
37
- runner.applicable_package_managers(info)
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
- runner.package_managers
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: 14.4.0
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-24 00:00:00.000000000 Z
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