bibliothecary 10.1.0 → 10.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5819573e0a53cf1f6d12f289f16a89318da9da6124cfbfcf2d5bf43f2a2c60a
4
- data.tar.gz: 0521f708de33c56c3b9c271c68d61f630f88e4ba73923f781c71f6b117c71401
3
+ metadata.gz: 593043fd2afa0c57546f1947d788d7d4882cc398b36ebcc5774cb89446ba07d1
4
+ data.tar.gz: fcf4b7b67a9b0d6de622d6bf4390bf20b64f6c015e13253ffad21257bd142f81
5
5
  SHA512:
6
- metadata.gz: 9c1c1d84cfdf88a8b8d0b9b4692c4ce453c4c759a067e3ea99f5c0b0a4a3bf9136af9d600e0bb8a81cbb5d0ff2a3a24cdc7b9264b4455482dde0e12ef359e20c
7
- data.tar.gz: 7628bb022b1daad35a3a826dfda54a46faa5437065ab36abf80de1fc9d64abf7e2b7636157eb00665b127a58792659a4b7dd3e74a35014bc731e973216c3df2d
6
+ metadata.gz: 9b6922980540f62a05e27a46c612937dc165c4815dab3ca8462ad137e1cb4905ac9a015a7a47777126336eefa5a50794027696d1be9340e88206b71885c6893a
7
+ data.tar.gz: b283d69564bbd69f8684cd4ac530551c42c5ab1c174da3edaa84f9ca4ee9750abc26cd1d6a977ccf69709fe52cb8d821d7875f6821c456ac5727b1a196dbd060
data/CHANGELOG.md CHANGED
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
 
14
14
  ### Removed
15
15
 
16
+ ## [10.2.0] - 2024-08-27
17
+
18
+ ### Changed
19
+
20
+ - `Bibliothecary::Dependency#requirement` now defaults to all versions (`"*"`) instead of `nil` if no version range is specified for the dependency,
21
+
16
22
  ## [10.1.0] - 2024-07-23
17
23
 
18
24
  ### Changed
@@ -54,7 +54,7 @@ module Bibliothecary
54
54
  )
55
55
  @name = name
56
56
  @platform = platform
57
- @requirement = requirement
57
+ @requirement = requirement || "*"
58
58
  @original_requirement = original_requirement
59
59
  # TODO: maybe deprecate this field? Is it possible to replace it with original_requirement?
60
60
  @lockfile_requirement = lockfile_requirement
@@ -72,6 +72,10 @@ module Bibliothecary
72
72
  end
73
73
  alias :== :eql?
74
74
 
75
+ def [](key)
76
+ public_send(key)
77
+ end
78
+
75
79
  def to_h
76
80
  FIELDS.to_h { |f| [f, public_send(f)] }
77
81
  end
@@ -35,7 +35,7 @@ module Bibliothecary
35
35
  dep = dependency.match(REQUIRE_REGEXP)
36
36
  Dependency.new(
37
37
  name: dep[1],
38
- requirement: dep[2] || "*",
38
+ requirement: dep[2],
39
39
  type: name.downcase,
40
40
  )
41
41
  end
@@ -86,7 +86,7 @@ module Bibliothecary
86
86
  next unless match
87
87
  deps << Dependency.new(
88
88
  name: match[1].strip,
89
- requirement: match[2].strip || "*",
89
+ requirement: match[2].strip,
90
90
  type: "runtime",
91
91
  )
92
92
  end
@@ -140,7 +140,7 @@ module Bibliothecary
140
140
  replacement_dep.original_name == dep.name &&
141
141
  (replacement_dep.original_requirement == "*" || replacement_dep.original_requirement == dep.requirement)
142
142
  end
143
-
143
+
144
144
  replaced_dep || dep
145
145
  end
146
146
 
@@ -168,7 +168,7 @@ module Bibliothecary
168
168
  elsif (match = line.match(GOMOD_SINGLELINE_DEP_REGEXP)) # or, detect a singleline dep
169
169
  categorized_deps[match[:category]] << go_mod_category_relative_dep(category: match[:category], line: line, match: match)
170
170
  elsif (current_multiline_category && match = line.match(GOMOD_MULTILINE_DEP_REGEXP)) # otherwise, parse the multiline dep
171
- categorized_deps[current_multiline_category] << go_mod_category_relative_dep(category: current_multiline_category, line: line, match: match)
171
+ categorized_deps[current_multiline_category] << go_mod_category_relative_dep(category: current_multiline_category, line: line, match: match)
172
172
  end
173
173
  end
174
174
  categorized_deps
@@ -180,7 +180,7 @@ module Bibliothecary
180
180
  if (match = line.match(GOSUM_REGEXP))
181
181
  deps << Dependency.new(
182
182
  name: match[1].strip,
183
- requirement: match[2].strip.split("/").first || "*",
183
+ requirement: match[2].strip.split("/").first,
184
184
  type: "runtime",
185
185
  )
186
186
  end
@@ -191,7 +191,7 @@ module Bibliothecary
191
191
  def self.parse_go_resolved(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
192
192
  JSON.parse(file_contents)
193
193
  .select { |dep| dep["Main"] != "true" }
194
- .map do |dep|
194
+ .map do |dep|
195
195
  if dep["Replace"].is_a?(String) && dep["Replace"] != "<nil>" && dep["Replace"] != ""
196
196
  # NOTE: The "replace" directive doesn't actually change the version reported from Go (e.g. "go mod graph"), it only changes
197
197
  # the *source code*. So by replacing the deps here, we're giving more honest results than you'd get when asking go
@@ -213,7 +213,7 @@ module Bibliothecary
213
213
  manifest.fetch(attr_name,[]).map do |dependency|
214
214
  Dependency.new(
215
215
  name: dependency[dep_attr_name],
216
- requirement: dependency[version_attr_name] || "*",
216
+ requirement: dependency[version_attr_name],
217
217
  type: type,
218
218
  )
219
219
  end
@@ -222,21 +222,21 @@ module Bibliothecary
222
222
  # Returns our standard-ish dep Hash based on the category of dep matched ("require", "replace", etc.)
223
223
  def self.go_mod_category_relative_dep(category:, line:, match:)
224
224
  case category
225
- when "replace"
225
+ when "replace"
226
226
  replacement_dep = line.split(GOMOD_REPLACEMENT_SEPARATOR_REGEXP, 2).last
227
227
  replacement_match = replacement_dep.match(GOMOD_DEP_REGEXP)
228
228
  Dependency.new(
229
229
  original_name: match[:name],
230
- original_requirement: match[:requirement] || "*",
230
+ original_requirement: match[:requirement],
231
231
  name: replacement_match[:name],
232
- requirement: replacement_match[:requirement] || "*",
232
+ requirement: replacement_match[:requirement],
233
233
  type: "runtime",
234
234
  direct: !match[:indirect],
235
235
  )
236
236
  when "retract"
237
237
  Dependency.new(
238
238
  name: match[:name],
239
- requirement: match[:requirement] || "*",
239
+ requirement: match[:requirement],
240
240
  type: "runtime",
241
241
  deprecated: true,
242
242
  direct: !match[:indirect],
@@ -244,7 +244,7 @@ module Bibliothecary
244
244
  else
245
245
  Dependency.new(
246
246
  name: match[:name],
247
- requirement: match[:requirement] || "*",
247
+ requirement: match[:requirement],
248
248
  type: "runtime",
249
249
  direct: !match[:indirect],
250
250
  )
@@ -43,7 +43,7 @@ module Bibliothecary
43
43
  dep = dependency.delete("==").split(" ")
44
44
  Dependency.new(
45
45
  name: dep[0],
46
- requirement: dep[1] || "*",
46
+ requirement: dep[1],
47
47
  type: "runtime",
48
48
  )
49
49
  end
@@ -323,7 +323,7 @@ module Bibliothecary
323
323
  .map { |(type, group, artifactId, version)|
324
324
  Dependency.new(
325
325
  name: [group, artifactId].join(":"),
326
- requirement: version || "*",
326
+ requirement: version,
327
327
  type: type,
328
328
  )
329
329
  }
@@ -336,7 +336,7 @@ module Bibliothecary
336
336
  .map { |(type, group, artifactId, version)|
337
337
  Dependency.new(
338
338
  name: [group, artifactId].join(":"),
339
- requirement: version || "*",
339
+ requirement: version,
340
340
  type: type,
341
341
  )
342
342
  }
@@ -72,7 +72,7 @@ module Bibliothecary
72
72
  .map do |name, dep|
73
73
  Dependency.new(
74
74
  name: name.split("node_modules/").last,
75
- requirement: dep["version"] || "*",
75
+ requirement: dep["version"],
76
76
  type: dep.fetch("dev", false) || dep.fetch("devOptional", false) ? "development" : "runtime",
77
77
  local: dep.fetch("link", false),
78
78
  )
@@ -94,7 +94,7 @@ module Bibliothecary
94
94
  manifest.packages.locate("package").map do |dependency|
95
95
  Dependency.new(
96
96
  name: dependency.id,
97
- requirement: (dependency.version if dependency.respond_to? "version") || "*",
97
+ requirement: (dependency.version if dependency.respond_to? "version"),
98
98
  type: dependency.respond_to?("developmentDependency") && dependency.developmentDependency == "true" ? "development" : "runtime",
99
99
  )
100
100
  end
@@ -106,7 +106,7 @@ module Bibliothecary
106
106
  manifest = Ox.parse file_contents
107
107
 
108
108
  packages = manifest.locate("ItemGroup/PackageReference").select{ |dep| dep.respond_to? "Include" }.map do |dependency|
109
- requirement = (dependency.Version if dependency.respond_to? "Version") || "*"
109
+ requirement = (dependency.Version if dependency.respond_to? "Version")
110
110
  if requirement.is_a?(Ox::Element)
111
111
  requirement = dependency.nodes.detect{ |n| n.value == "Version" }&.text
112
112
  end
@@ -133,7 +133,7 @@ module Bibliothecary
133
133
  manifest.package.metadata.dependencies.locate("dependency").map do |dependency|
134
134
  Dependency.new(
135
135
  name: dependency.id,
136
- requirement: dependency.attributes[:version] || "*",
136
+ requirement: dependency.attributes[:version],
137
137
  type: dependency.respond_to?("developmentDependency") && dependency.developmentDependency == "true" ? "development" : "runtime",
138
138
  )
139
139
  end
@@ -165,7 +165,7 @@ module Bibliothecary
165
165
  "*"
166
166
  end
167
167
  else
168
- info || "*"
168
+ info
169
169
  end
170
170
  end
171
171
 
@@ -217,7 +217,7 @@ module Bibliothecary
217
217
  next unless match
218
218
  deps << Dependency.new(
219
219
  name: match[1],
220
- requirement: match[-1] || "*",
220
+ requirement: match[-1],
221
221
  type: "runtime",
222
222
  )
223
223
  end
@@ -269,7 +269,7 @@ module Bibliothecary
269
269
  elsif (match = line.delete(" ").match(REQUIREMENTS_REGEXP))
270
270
  deps << Dependency.new(
271
271
  name: match[1],
272
- requirement: match[-1] || "*",
272
+ requirement: match[-1],
273
273
  type: type,
274
274
  )
275
275
  end
@@ -287,7 +287,7 @@ module Bibliothecary
287
287
 
288
288
  requirement = uri.path[/@(.+)$/, 1]
289
289
 
290
- Dependency.new(name: name, requirement: requirement || "*", type: type)
290
+ Dependency.new(name: name, requirement: requirement, type: type)
291
291
  end
292
292
 
293
293
  def self.pip_compile?(file_contents)
@@ -35,7 +35,7 @@ module Bibliothecary
35
35
  hash.fetch(key,[]).map do |name, requirement|
36
36
  Dependency.new(
37
37
  name: name,
38
- requirement: requirement["version"] || "*",
38
+ requirement: requirement["version"],
39
39
  type: type,
40
40
  )
41
41
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "10.1.0"
2
+ VERSION = "10.2.0"
3
3
  end
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: 10.1.0
4
+ version: 10.2.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: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb