bibliothecary 13.0.1 → 14.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 +22 -0
- data/lib/bibliothecary/analyser/analysis.rb +3 -24
- data/lib/bibliothecary/analyser.rb +5 -7
- data/lib/bibliothecary/dependency.rb +1 -1
- data/lib/bibliothecary/multi_parsers/bundler_like_manifest.rb +2 -1
- data/lib/bibliothecary/multi_parsers/cyclonedx.rb +3 -2
- data/lib/bibliothecary/multi_parsers/dependencies_csv.rb +3 -1
- data/lib/bibliothecary/multi_parsers/json_runtime.rb +4 -1
- data/lib/bibliothecary/multi_parsers/spdx.rb +1 -0
- data/lib/bibliothecary/parser_result.rb +37 -0
- data/lib/bibliothecary/parsers/bower.rb +3 -2
- data/lib/bibliothecary/parsers/cargo.rb +8 -4
- data/lib/bibliothecary/parsers/cocoapods.rb +10 -4
- data/lib/bibliothecary/parsers/conda.rb +8 -2
- data/lib/bibliothecary/parsers/cpan.rb +4 -2
- data/lib/bibliothecary/parsers/cran.rb +7 -5
- data/lib/bibliothecary/parsers/dub.rb +3 -1
- data/lib/bibliothecary/parsers/elm.rb +4 -2
- data/lib/bibliothecary/parsers/go.rb +32 -16
- data/lib/bibliothecary/parsers/julia.rb +3 -2
- data/lib/bibliothecary/parsers/maven.rb +61 -27
- data/lib/bibliothecary/parsers/npm.rb +51 -36
- data/lib/bibliothecary/parsers/nuget.rb +33 -20
- data/lib/bibliothecary/parsers/packagist.rb +9 -5
- data/lib/bibliothecary/parsers/pub.rb +7 -4
- data/lib/bibliothecary/parsers/pypi.rb +30 -16
- data/lib/bibliothecary/parsers/rubygems.rb +10 -5
- data/lib/bibliothecary/parsers/shard.rb +7 -4
- data/lib/bibliothecary/version.rb +1 -1
- data/lib/bibliothecary.rb +1 -0
- data/lib/sdl_parser.rb +3 -1
- metadata +3 -2
@@ -24,20 +24,23 @@ module Bibliothecary
|
|
24
24
|
|
25
25
|
def self.parse_yaml_manifest(file_contents, options: {})
|
26
26
|
manifest = YAML.load file_contents
|
27
|
-
map_dependencies(manifest, "dependencies", "runtime", options.fetch(:filename, nil)) +
|
28
|
-
|
27
|
+
dependencies = map_dependencies(manifest, "dependencies", "runtime", options.fetch(:filename, nil)) +
|
28
|
+
map_dependencies(manifest, "dev_dependencies", "development", options.fetch(:filename, nil))
|
29
|
+
ParserResult.new(dependencies: dependencies)
|
29
30
|
end
|
30
31
|
|
31
32
|
def self.parse_yaml_lockfile(file_contents, options: {})
|
32
33
|
manifest = YAML.load file_contents
|
33
|
-
manifest.fetch("packages", []).map do |name, dep|
|
34
|
+
dependencies = manifest.fetch("packages", []).map do |name, dep|
|
34
35
|
Dependency.new(
|
35
36
|
name: name,
|
36
37
|
requirement: dep["version"],
|
37
38
|
type: "runtime",
|
38
|
-
source: options.fetch(:filename, nil)
|
39
|
+
source: options.fetch(:filename, nil),
|
40
|
+
platform: platform_name
|
39
41
|
)
|
40
42
|
end
|
43
|
+
ParserResult.new(dependencies: dependencies)
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -81,8 +81,9 @@ module Bibliothecary
|
|
81
81
|
|
82
82
|
def self.parse_pipfile(file_contents, options: {})
|
83
83
|
manifest = Tomlrb.parse(file_contents)
|
84
|
-
map_dependencies(manifest["packages"], "runtime", options.fetch(:filename, nil)) +
|
85
|
-
|
84
|
+
dependencies = map_dependencies(manifest["packages"], "runtime", options.fetch(:filename, nil)) +
|
85
|
+
map_dependencies(manifest["dev-packages"], "develop", options.fetch(:filename, nil))
|
86
|
+
ParserResult.new(dependencies: dependencies)
|
86
87
|
end
|
87
88
|
|
88
89
|
def self.parse_pyproject(file_contents, options: {})
|
@@ -114,11 +115,15 @@ module Bibliothecary
|
|
114
115
|
|
115
116
|
# Poetry normalizes names in lockfiles but doesn't provide the original, so we need to keep
|
116
117
|
# track of the original name so the dep is connected between manifest+lockfile.
|
117
|
-
deps.map do |dep|
|
118
|
+
dependencies = deps.map do |dep|
|
118
119
|
normalized_name = normalize_name(dep.name)
|
119
|
-
Dependency.new(
|
120
|
-
|
120
|
+
Dependency.new(
|
121
|
+
**dep.to_h,
|
122
|
+
name: normalized_name,
|
123
|
+
original_name: normalized_name == dep.name ? nil : dep.name
|
124
|
+
)
|
121
125
|
end
|
126
|
+
ParserResult.new(dependencies: dependencies)
|
122
127
|
end
|
123
128
|
|
124
129
|
def self.map_dependencies(packages, type, source = nil)
|
@@ -133,6 +138,7 @@ module Bibliothecary
|
|
133
138
|
# https://python-poetry.org/docs/dependency-specification/#multiple-constraints-dependencies
|
134
139
|
package_info.map do |info|
|
135
140
|
Dependency.new(
|
141
|
+
platform: platform_name,
|
136
142
|
name: name,
|
137
143
|
requirement: map_requirements(info),
|
138
144
|
type: type,
|
@@ -142,6 +148,7 @@ module Bibliothecary
|
|
142
148
|
end
|
143
149
|
else
|
144
150
|
Dependency.new(
|
151
|
+
platform: platform_name,
|
145
152
|
name: name,
|
146
153
|
requirement: map_requirements(package_info),
|
147
154
|
type: type,
|
@@ -175,7 +182,7 @@ module Bibliothecary
|
|
175
182
|
group = "runtime" if group == "default"
|
176
183
|
deps += map_dependencies(dependencies, group, options.fetch(:filename, nil))
|
177
184
|
end
|
178
|
-
deps
|
185
|
+
ParserResult.new(dependencies: deps)
|
179
186
|
end
|
180
187
|
|
181
188
|
def self.parse_poetry_lock(file_contents, options: {})
|
@@ -206,16 +213,17 @@ module Bibliothecary
|
|
206
213
|
original_name: normalized_name == package["name"] ? nil : package["name"],
|
207
214
|
requirement: map_requirements(package),
|
208
215
|
type: group,
|
209
|
-
source: options.fetch(:filename, nil)
|
216
|
+
source: options.fetch(:filename, nil),
|
217
|
+
platform: platform_name
|
210
218
|
)
|
211
219
|
end
|
212
220
|
end
|
213
|
-
deps
|
221
|
+
ParserResult.new(dependencies: deps)
|
214
222
|
end
|
215
223
|
|
216
224
|
def self.parse_setup_py(file_contents, options: {})
|
217
225
|
match = file_contents.match(INSTALL_REGEXP)
|
218
|
-
return [] unless match
|
226
|
+
return ParserResult.new(dependencies: []) unless match
|
219
227
|
|
220
228
|
deps = []
|
221
229
|
match[1].gsub(/',(\s)?'/, "\n").split("\n").each do |line|
|
@@ -228,10 +236,11 @@ module Bibliothecary
|
|
228
236
|
name: match[1],
|
229
237
|
requirement: match[-1],
|
230
238
|
type: "runtime",
|
231
|
-
source: options.fetch(:filename, nil)
|
239
|
+
source: options.fetch(:filename, nil),
|
240
|
+
platform: platform_name
|
232
241
|
)
|
233
242
|
end
|
234
|
-
deps
|
243
|
+
ParserResult.new(dependencies: deps)
|
235
244
|
end
|
236
245
|
|
237
246
|
# While the thing in the repo that PyPI is using might be either in
|
@@ -241,16 +250,18 @@ module Bibliothecary
|
|
241
250
|
NoEggSpecified = Class.new(ArgumentError)
|
242
251
|
|
243
252
|
def self.parse_dependency_tree_json(file_contents, options: {})
|
244
|
-
JSON.parse(file_contents)
|
253
|
+
dependencies = JSON.parse(file_contents)
|
245
254
|
.map do |pkg|
|
246
255
|
Dependency.new(
|
247
256
|
name: pkg.dig("package", "package_name"),
|
248
257
|
requirement: pkg.dig("package", "installed_version"),
|
249
258
|
type: "runtime",
|
250
|
-
source: options.fetch(:filename, nil)
|
259
|
+
source: options.fetch(:filename, nil),
|
260
|
+
platform: platform_name
|
251
261
|
)
|
252
262
|
end
|
253
263
|
.uniq
|
264
|
+
ParserResult.new(dependencies: dependencies)
|
254
265
|
end
|
255
266
|
|
256
267
|
# Parses a requirements.txt file, following the
|
@@ -282,12 +293,14 @@ module Bibliothecary
|
|
282
293
|
name: match[1],
|
283
294
|
requirement: match[-1],
|
284
295
|
type: type,
|
285
|
-
source: options.fetch(:filename, nil)
|
296
|
+
source: options.fetch(:filename, nil),
|
297
|
+
platform: platform_name
|
286
298
|
)
|
287
299
|
end
|
288
300
|
end
|
289
301
|
|
290
|
-
deps.uniq
|
302
|
+
dependencies = deps.uniq
|
303
|
+
ParserResult.new(dependencies: dependencies)
|
291
304
|
end
|
292
305
|
|
293
306
|
def self.parse_requirements_txt_url(url, type = nil, source = nil)
|
@@ -303,7 +316,8 @@ module Bibliothecary
|
|
303
316
|
name: name,
|
304
317
|
requirement: requirement,
|
305
318
|
type: type,
|
306
|
-
source: source
|
319
|
+
source: source,
|
320
|
+
platform: platform_name
|
307
321
|
)
|
308
322
|
end
|
309
323
|
|
@@ -37,7 +37,7 @@ module Bibliothecary
|
|
37
37
|
add_multi_parser(Bibliothecary::MultiParsers::Spdx)
|
38
38
|
|
39
39
|
def self.parse_gemfile_lock(file_contents, options: {})
|
40
|
-
file_contents.lines(chomp: true).map do |line|
|
40
|
+
dependencies = file_contents.lines(chomp: true).map do |line|
|
41
41
|
match = line.match(NAME_VERSION_4)
|
42
42
|
bundler_match = line.match(BUNDLED_WITH)
|
43
43
|
next unless match || bundler_match
|
@@ -49,22 +49,26 @@ module Bibliothecary
|
|
49
49
|
name: name,
|
50
50
|
requirement: version,
|
51
51
|
type: "runtime",
|
52
|
-
source: options.fetch(:filename, nil)
|
52
|
+
source: options.fetch(:filename, nil),
|
53
|
+
platform: platform_name
|
53
54
|
)
|
54
55
|
else
|
55
56
|
parse_bundler(file_contents, options.fetch(:filename, nil))
|
56
57
|
end
|
57
58
|
end.compact
|
59
|
+
ParserResult.new(dependencies: dependencies)
|
58
60
|
end
|
59
61
|
|
60
62
|
def self.parse_gemfile(file_contents, options: {})
|
61
63
|
manifest = Gemnasium::Parser.send(:gemfile, file_contents)
|
62
|
-
parse_ruby_manifest(manifest, options.fetch(:filename, nil))
|
64
|
+
dependencies = parse_ruby_manifest(manifest, platform_name, options.fetch(:filename, nil))
|
65
|
+
ParserResult.new(dependencies: dependencies)
|
63
66
|
end
|
64
67
|
|
65
68
|
def self.parse_gemspec(file_contents, options: {})
|
66
69
|
manifest = Gemnasium::Parser.send(:gemspec, file_contents)
|
67
|
-
parse_ruby_manifest(manifest, options.fetch(:filename, nil))
|
70
|
+
dependencies = parse_ruby_manifest(manifest, platform_name, options.fetch(:filename, nil))
|
71
|
+
ParserResult.new(dependencies: dependencies)
|
68
72
|
end
|
69
73
|
|
70
74
|
def self.parse_bundler(file_contents, source = nil)
|
@@ -77,7 +81,8 @@ module Bibliothecary
|
|
77
81
|
name: "bundler",
|
78
82
|
requirement: version,
|
79
83
|
type: "runtime",
|
80
|
-
source: source
|
84
|
+
source: source,
|
85
|
+
platform: platform_name
|
81
86
|
)
|
82
87
|
end
|
83
88
|
end
|
@@ -24,13 +24,15 @@ module Bibliothecary
|
|
24
24
|
|
25
25
|
def self.parse_yaml_lockfile(file_contents, options: {})
|
26
26
|
manifest = YAML.load file_contents
|
27
|
-
map_dependencies(manifest, "shards", "runtime", options.fetch(:filename, nil))
|
27
|
+
dependencies = map_dependencies(manifest, "shards", "runtime", options.fetch(:filename, nil))
|
28
|
+
Bibliothecary::ParserResult.new(dependencies: dependencies)
|
28
29
|
end
|
29
30
|
|
30
31
|
def self.parse_yaml_manifest(file_contents, options: {})
|
31
32
|
manifest = YAML.load file_contents
|
32
|
-
map_dependencies(manifest, "dependencies", "runtime", options.fetch(:filename, nil)) +
|
33
|
-
|
33
|
+
dependencies = map_dependencies(manifest, "dependencies", "runtime", options.fetch(:filename, nil)) +
|
34
|
+
map_dependencies(manifest, "development_dependencies", "runtime", options.fetch(:filename, nil))
|
35
|
+
Bibliothecary::ParserResult.new(dependencies: dependencies)
|
34
36
|
end
|
35
37
|
|
36
38
|
def self.map_dependencies(hash, key, type, source = nil)
|
@@ -39,7 +41,8 @@ module Bibliothecary
|
|
39
41
|
name: name,
|
40
42
|
requirement: requirement["version"],
|
41
43
|
type: type,
|
42
|
-
source: source
|
44
|
+
source: source,
|
45
|
+
platform: platform_name
|
43
46
|
)
|
44
47
|
end
|
45
48
|
end
|
data/lib/bibliothecary.rb
CHANGED
data/lib/sdl_parser.rb
CHANGED
@@ -5,15 +5,17 @@ require "sdl4r"
|
|
5
5
|
class SdlParser
|
6
6
|
attr_reader :contents, :type
|
7
7
|
|
8
|
-
def initialize(type, contents, source = nil)
|
8
|
+
def initialize(type, contents, platform, source = nil)
|
9
9
|
@contents = contents
|
10
10
|
@type = type || "runtime"
|
11
|
+
@platform = platform
|
11
12
|
@source = source
|
12
13
|
end
|
13
14
|
|
14
15
|
def dependencies
|
15
16
|
parse.children("dependency").inject([]) do |deps, dep|
|
16
17
|
deps.push(Bibliothecary::Dependency.new(
|
18
|
+
platform: @platform,
|
17
19
|
name: dep.value,
|
18
20
|
requirement: dep.attribute("version") || ">= 0",
|
19
21
|
type: type,
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibliothecary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 14.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-07-
|
10
|
+
date: 2025-07-24 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: commander
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/bibliothecary/multi_parsers/dependencies_csv.rb
|
178
178
|
- lib/bibliothecary/multi_parsers/json_runtime.rb
|
179
179
|
- lib/bibliothecary/multi_parsers/spdx.rb
|
180
|
+
- lib/bibliothecary/parser_result.rb
|
180
181
|
- lib/bibliothecary/parsers/bower.rb
|
181
182
|
- lib/bibliothecary/parsers/cargo.rb
|
182
183
|
- lib/bibliothecary/parsers/cocoapods.rb
|