bibliothecary 6.8.8 → 6.8.9

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: 9a942d8a210e009f17a359b9ead9049423c091d9609d6d1770eb79fc47fb16d6
4
- data.tar.gz: bd1f6a3f7d3652981ee46002fe3466480c9bf9d08c7dc1dbd5bffab3698e21a0
3
+ metadata.gz: c655fc14eb58f419b202c25b3b28d22f041c840ceda3d527aaf21b122d5663fe
4
+ data.tar.gz: 43b452b2ec6411d409aff5a479fd3d89d2bdf7eeb253b253b5a76849b8990b1a
5
5
  SHA512:
6
- metadata.gz: af583cc0c0dea0e280a3b28c30a9bbda9413331e76d1bfd0eba6908d209b43893cd2677acdb6113d498833514b0656cd57a0014f4949a48d1d276a629838acba
7
- data.tar.gz: e8f49049133561c3fdfeb48d692736e407457943f19668251f75c5db93fae1276540754e7f0a6b0986f80f303e81a7df72ecb1dbf03c48f05d81b0e1f2057922
6
+ metadata.gz: 921763c07b4ae50a14a905e5eed87a558631495500150ac732763a9456b081007b6e05dac4eabfec13f06ed3d3a6b38cdc30436e828204f389a627ab64fbc38b
7
+ data.tar.gz: daf4e977c0c46daec88c6e9cfc0dd41b0e4ce842266716bb40aa3da10effcd5d5ee291ca034f1509f8e0233bd4a6e08ed6ab00896f7cfe4dd66ca5bbe2a859d3
@@ -15,6 +15,21 @@ module Bibliothecary
15
15
  MAVEN_PROPERTY_REGEX = /\$\{(.+?)\}/
16
16
  MAX_DEPTH = 5
17
17
 
18
+ # e.g. "[info] test:"
19
+ SBT_TYPE_REGEX = /^\[info\]\s+([-\w]+):$/
20
+
21
+ # e.g. "[info] org.typelevel:spire-util_2.12"
22
+ SBT_DEP_REGEX = /^\[info\]\s+(.+)$/
23
+
24
+ # e.g. "[info] - 1.7.5"
25
+ SBT_VERSION_REGEX = /^\[info\]\s+-\s+(.+)$/
26
+
27
+ # e.g. "[info] homepage: http://www.slf4j.org"
28
+ SBT_FIELD_REGEX = /^\[info\]\s+([^:]+):\s+(.+)$/
29
+
30
+ # e.g. "[info] "
31
+ SBT_IGNORE_REGEX = /^\[info\]\s*$/
32
+
18
33
  def self.mapping
19
34
  {
20
35
  match_filename("ivy.xml", case_insensitive: true) => {
@@ -41,6 +56,10 @@ module Bibliothecary
41
56
  match_filename("maven-resolved-dependencies.txt", case_insensitive: true) => {
42
57
  kind: 'lockfile',
43
58
  parser: :parse_maven_resolved
59
+ },
60
+ match_filename("sbt-update-full.txt", case_insensitive: true) => {
61
+ kind: 'lockfile',
62
+ parser: :parse_sbt_update_full
44
63
  }
45
64
  }
46
65
  end
@@ -227,6 +246,103 @@ module Bibliothecary
227
246
  xml.locate("parent/#{non_prop_name}").first.nodes.first
228
247
  end
229
248
  end
249
+
250
+ def self.parse_sbt_update_full(file_contents)
251
+ all_deps = []
252
+ type = nil
253
+ lines = file_contents.split("\n")
254
+ while lines.any?
255
+ line = lines.shift
256
+
257
+ type_match = SBT_TYPE_REGEX.match(line)
258
+ next unless type_match
259
+ type = type_match.captures[0]
260
+
261
+ deps = parse_sbt_deps(type, lines)
262
+ all_deps.concat(deps)
263
+ end
264
+
265
+ # strip out evicted dependencies
266
+ all_deps.select! do |dep|
267
+ dep[:fields]["evicted"] != "true"
268
+ end
269
+
270
+ # in the future, we could use "callers" in the fields to
271
+ # decide which deps are direct root deps and which are
272
+ # pulled in by another dep. The direct deps have the sbt
273
+ # project name as a caller.
274
+
275
+ # clean out any duplicates (I'm pretty sure sbt will have done this for
276
+ # us so this is paranoia, basically)
277
+ squished = all_deps.compact.uniq {|item| [item[:name], item[:requirement], item[:type]]}
278
+
279
+ # get rid of the fields
280
+ squished.each do |dep|
281
+ dep.delete(:fields)
282
+ end
283
+
284
+ return squished
285
+ end
286
+
287
+ def self.parse_sbt_deps(type, lines)
288
+ deps = []
289
+ while lines.any? and not SBT_TYPE_REGEX.match(lines[0])
290
+ line = lines.shift
291
+
292
+ next if SBT_IGNORE_REGEX.match(line)
293
+
294
+ dep_match = SBT_DEP_REGEX.match(line)
295
+ if dep_match
296
+ versions = parse_sbt_versions(type, dep_match.captures[0], lines)
297
+ deps.concat(versions)
298
+ else
299
+ lines.unshift(line)
300
+ break
301
+ end
302
+ end
303
+
304
+ deps
305
+ end
306
+
307
+ def self.parse_sbt_versions(type, name, lines)
308
+ versions = []
309
+ while lines.any? and not SBT_TYPE_REGEX.match(lines[0])
310
+ line = lines.shift
311
+
312
+ version_match = SBT_VERSION_REGEX.match(line)
313
+ if version_match
314
+ versions.push(parse_sbt_version(type, name, version_match.captures[0], lines))
315
+ else
316
+ lines.unshift(line)
317
+ break
318
+ end
319
+ end
320
+
321
+ versions
322
+ end
323
+
324
+ def self.parse_sbt_version(type, name, version, lines)
325
+ fields = {}
326
+ while lines.any? and not SBT_TYPE_REGEX.match(lines[0])
327
+ line = lines.shift
328
+
329
+ field_match = SBT_FIELD_REGEX.match(line)
330
+ if field_match
331
+ fields[field_match.captures[0]] = field_match.captures[1]
332
+ else
333
+ lines.unshift(line)
334
+ break
335
+ end
336
+ end
337
+
338
+ {
339
+ name: name,
340
+ requirement: version,
341
+ type: type,
342
+ # we post-process using some of these fields and then delete them again
343
+ fields: fields
344
+ }
345
+ end
230
346
  end
231
347
  end
232
348
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.8.8"
2
+ VERSION = "6.8.9"
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: 6.8.8
4
+ version: 6.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb