bibliothecary 8.1.0 → 8.2.1

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: 7ed029f460ea32073ccc2d06f6fb297926686064554b1447a7014ff8588382f1
4
- data.tar.gz: 70482eb3f0cfe7afb13124904b1e713596d92e92d90cd6267153ff4319e9d356
3
+ metadata.gz: 9768b5d4829b90bc0bda13059ae884a0f6339621b85b7fcfa8bfa472439200e5
4
+ data.tar.gz: 3a34cc4b9f483502a6a0dbe0750ebe379379e2fbfde7acfb8c5d00d29d904ccc
5
5
  SHA512:
6
- metadata.gz: b8a243cb926cf8e49835f11db86199f8fe8d45dc53b1f80a17c9b3c941bb5935e4c8b8c1a897b40704d8c6c3ddc271fd5d3139aa9373a8328eea3a538c383fac
7
- data.tar.gz: d6dd8f873e0ce3cabf3f526e4e50393c36c1e3c6aacb7b1581bc7720bc022670ecd0cc96114df8d3dcc561341e3ee920d401a578eaf7fe5b066f64a33306d730
6
+ metadata.gz: 4eed23508e442acb7957a4e3022a0ba42eb7ce199572a04d7ab9e3c77055d259e57ade2c294ad79b21ed2e55225ac6b6bb3dc58e55db33be74100643b226b689
7
+ data.tar.gz: b94e436900019c1f5f8adeca6da6ada27131e275fdfd005d3c0d2d6a003ec89292a5631a11cc40391abcba7ee53ceb88506246faca297c1b49d0a55bb8fc9973
@@ -45,7 +45,7 @@ module Bibliothecary
45
45
  # Instead of recursing, we'll work through a queue of components
46
46
  # to process, letting the different parser add components to the
47
47
  # queue however they need to pull them from the source document.
48
- @parse_queue = parse_queue
48
+ @parse_queue = parse_queue.dup
49
49
  end
50
50
 
51
51
  def <<(purl)
@@ -12,6 +12,18 @@ module Bibliothecary
12
12
  # "| \\--- com.google.guava:guava:23.5-jre (*)"
13
13
  GRADLE_DEP_REGEX = /(\+---|\\---){1}/
14
14
 
15
+ # Builtin methods: https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations
16
+ GRADLE_KTS_DEPENDENCY_METHODS = %w(api compile compileOnlyApi implementation runtimeOnly testCompileOnly testImplementation testRuntimeOnly)
17
+
18
+ # An intentionally overly-simplified regex to scrape deps from build.gradle.kts files.
19
+ # To be truly useful bibliothecary would need a full Kotlin parser that speaks Gradle,
20
+ # because the Kotlin DSL has many dynamic ways of declaring dependencies.
21
+
22
+ GRADLE_KTS_VERSION_REGEX = /[\w.-]+/ # e.g. '1.2.3'
23
+ GRADLE_KTS_INTERPOLATED_VERSION_REGEX = /\$\{.*\}/ # e.g. '${my-project-settings["version"]}'
24
+ GRADLE_KTS_GAV_REGEX = /([\w.-]+)\:([\w.-]+)(?:\:(#{GRADLE_KTS_VERSION_REGEX}|#{GRADLE_KTS_INTERPOLATED_VERSION_REGEX}))?/
25
+ GRADLE_KTS_SIMPLE_REGEX = /(#{GRADLE_KTS_DEPENDENCY_METHODS.join('|')})\s*\(\s*"#{GRADLE_KTS_GAV_REGEX}"\s*\)\s*$/m # e.g. "group:artifactId:1.2.3"
26
+
15
27
  MAVEN_PROPERTY_REGEX = /\$\{(.+?)\}/
16
28
  MAX_DEPTH = 5
17
29
 
@@ -236,8 +248,16 @@ module Bibliothecary
236
248
  end
237
249
 
238
250
  def self.parse_gradle_kts(file_contents, options: {})
239
- # TODO: the gradle-parser side needs to be implemented for this, coming soon.
240
- []
251
+ file_contents
252
+ .scan(GRADLE_KTS_SIMPLE_REGEX) # match 'implementation("group:artifactId:version")'
253
+ .reject { |(_type, group, artifactId, _version)| group.nil? || artifactId.nil? } # remove any matches with missing group/artifactId
254
+ .map { |(type, group, artifactId, version)|
255
+ {
256
+ name: [group, artifactId].join(":"),
257
+ requirement: version || "*",
258
+ type: type
259
+ }
260
+ }
241
261
  end
242
262
 
243
263
  def self.gradle_dependency_name(group, name)
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.1.0"
2
+ VERSION = "8.2.1"
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: 8.1.0
4
+ version: 8.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-28 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb