bibliothecary 8.2.6 → 8.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77204631e2bfcd808b697fa06b39e9b026b59231bb4acd705af42c5b36b36001
4
- data.tar.gz: 712424873beece9fca7c15fbde387ff0f11a12973b0a785c8d94ac8cd833b9ed
3
+ metadata.gz: cf83ce2eee3ff72c5c46565c445c66fd9ed78d0a57986feb80437a43f2c948f3
4
+ data.tar.gz: 4177c6b7a5b270c4f07128f88b16308e30b2f3f75e50b3367bc1c379576f349a
5
5
  SHA512:
6
- metadata.gz: 5eb8cad8145bef3d6fb87c713e2cc145a6ca75be9a65b9c81f09c551552c9c8a40a95f7e192dcb7585f9a2ef15d3233522de367b23135fa503704b37c1b8bf06
7
- data.tar.gz: f29c04901db7650463e80a7a0436a629001a9758ae6e21a38683091f4d30a1d76424bd2a3e8ec944ec526801fd5a6122a2940cf333e74a37f6e8c5be019e4f2b
6
+ metadata.gz: 6a3883e9ef9b6713b4f2607283f939c2e0c6523eeefbaac30471d23dafc67506d1a56e032bc7e02f1f7a60d8e10eebe58930325a6df8689d2d66978988cb6bd6
7
+ data.tar.gz: 1cd8c5e10724a994155a1585f60453c36161b17774c0a1838e48a47d711728df0ee40de88c18780328c715e8af4cbd09c69684a0f5e989e715a05489f14d5803
@@ -5,7 +5,6 @@ module Bibliothecary
5
5
  attr_accessor :carthage_parser_host
6
6
  attr_accessor :clojars_parser_host
7
7
  attr_accessor :mix_parser_host
8
- attr_accessor :gradle_parser_host
9
8
  attr_accessor :yarn_parser_host
10
9
  attr_accessor :conda_parser_host
11
10
  attr_accessor :swift_parser_host
@@ -17,7 +16,6 @@ module Bibliothecary
17
16
  @carthage_parser_host = 'https://carthage.libraries.io'
18
17
  @clojars_parser_host = 'https://clojars.libraries.io'
19
18
  @mix_parser_host = 'https://mix.libraries.io'
20
- @gradle_parser_host = 'https://gradle-parser.libraries.io'
21
19
  @yarn_parser_host = 'https://yarn-parser.libraries.io'
22
20
  @conda_parser_host = 'https://conda-parser.libraries.io'
23
21
  @swift_parser_host = 'http://swift.libraries.io'
@@ -13,16 +13,18 @@ module Bibliothecary
13
13
  GRADLE_DEP_REGEX = /(\+---|\\---){1}/
14
14
 
15
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"
16
+ # Deprecated methods: https://docs.gradle.org/current/userguide/upgrading_version_6.html#sec:configuration_removal
17
+ GRADLE_DEPENDENCY_METHODS = %w(api compile compileClasspath compileOnly compileOnlyApi implementation runtime runtimeClasspath runtimeOnly testCompile testCompileOnly testImplementation testRuntime testRuntimeOnly)
18
+
19
+ # Intentionally overly-simplified regexes to scrape deps from build.gradle (Groovy) and build.gradle.kts (Kotlin) files.
20
+ # To be truly useful bibliothecary would need full Groovy / Kotlin parsers that speaks Gradle,
21
+ # because the Groovy and Kotlin DSLs have many dynamic ways of declaring dependencies.
22
+ GRADLE_VERSION_REGEX = /[\w.-]+/ # e.g. '1.2.3'
23
+ GRADLE_VAR_INTERPOLATION_REGEX = /\$\w+/ # e.g. '$myVersion'
24
+ GRADLE_CODE_INTERPOLATION_REGEX = /\$\{.*\}/ # e.g. '${my-project-settings["version"]}'
25
+ GRADLE_GAV_REGEX = /([\w.-]+)\:([\w.-]+)(?:\:(#{GRADLE_VERSION_REGEX}|#{GRADLE_VAR_INTERPOLATION_REGEX}|#{GRADLE_CODE_INTERPOLATION_REGEX}))?/ # e.g. "group:artifactId:1.2.3"
26
+ GRADLE_GROOVY_SIMPLE_REGEX = /(#{GRADLE_DEPENDENCY_METHODS.join('|')})\s*\(?\s*['"]#{GRADLE_GAV_REGEX}['"]/m
27
+ GRADLE_KOTLIN_SIMPLE_REGEX = /(#{GRADLE_DEPENDENCY_METHODS.join('|')})\s*\(\s*"#{GRADLE_GAV_REGEX}"/m
26
28
 
27
29
  MAVEN_PROPERTY_REGEX = /\$\{(.+?)\}/
28
30
  MAX_DEPTH = 5
@@ -233,24 +235,21 @@ module Bibliothecary
233
235
  end
234
236
 
235
237
  def self.parse_gradle(file_contents, options: {})
236
- response = Typhoeus.post("#{Bibliothecary.configuration.gradle_parser_host}/parse", body: file_contents)
237
- raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.gradle_parser_host}/parse", response.response_code) unless response.success?
238
- json = JSON.parse(response.body)
239
- return [] unless json['dependencies']
240
- json['dependencies'].map do |dependency|
241
- name = gradle_dependency_name(dependency["group"], dependency["name"])
242
- next unless name =~ /[\w-]+\.[\w_-]+(\.[\w-])?\:[\w-]/
238
+ file_contents
239
+ .scan(GRADLE_GROOVY_SIMPLE_REGEX) # match 'implementation "group:artifactId:version"'
240
+ .reject { |(_type, group, artifactId, _version)| group.nil? || artifactId.nil? } # remove any matches with missing group/artifactId
241
+ .map { |(type, group, artifactId, version)|
243
242
  {
244
- name: name,
245
- requirement: dependency["version"],
246
- type: dependency["type"]
243
+ name: [group, artifactId].join(":"),
244
+ requirement: version || "*",
245
+ type: type
247
246
  }
248
- end.compact
247
+ }
249
248
  end
250
249
 
251
250
  def self.parse_gradle_kts(file_contents, options: {})
252
251
  file_contents
253
- .scan(GRADLE_KTS_SIMPLE_REGEX) # match 'implementation("group:artifactId:version")'
252
+ .scan(GRADLE_KOTLIN_SIMPLE_REGEX) # match 'implementation("group:artifactId:version")'
254
253
  .reject { |(_type, group, artifactId, _version)| group.nil? || artifactId.nil? } # remove any matches with missing group/artifactId
255
254
  .map { |(type, group, artifactId, version)|
256
255
  {
@@ -21,7 +21,7 @@ module Bibliothecary
21
21
  def results
22
22
  partition_file_entries!
23
23
 
24
- no_lockfile_results + single_file_results + multiple_file_results
24
+ (no_lockfile_results + single_file_results + multiple_file_results).uniq
25
25
  end
26
26
 
27
27
  def no_lockfile_results
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.2.6"
2
+ VERSION = "8.3.2"
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.2.6
4
+ version: 8.3.2
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-05-19 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb