bibliothecary 8.2.5 → 8.3.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: 6f7fbf7ad34eaff5fc178a7befb091ec010341f3d5ad2a2b468c84c7fa3c3741
4
- data.tar.gz: 7fd04a9d3d2e28e79cec97b15cd7983f558a8fa4351bc0d1819cdce74ad65a8c
3
+ metadata.gz: ca91a1e5491b7b57370221351c1c90631fd77c12a9687328eccb69b633b477c4
4
+ data.tar.gz: 9cdbb6238e28ac32d61c624f1d0a98f29939684fdbfe76b29f24b9fa1737c295
5
5
  SHA512:
6
- metadata.gz: 5a6488a468d0369e391329359622334d177fd7bcb6694efee45b25f8b5c0cd77145fd517606a7550744b5d17725440b98dc5b8b2f00801183498ac7dbfb9bfc4
7
- data.tar.gz: 627e705c0201a891941bce2e2765cc9cd651473c49368270db4d0360fba6f15e3b645909bbe1052aebd2c5e24472ebfb07c7c90e68e87bf1558c40840c595c1d
6
+ metadata.gz: '01295bf67f3ba73a4683b2fc39773d8ae53ac2b1a64ccf674bf8e93aa1cae2cdacb1575a0592f2c9fbb86ddf3cca7cd60475b12252976bad6eafc07514339b34'
7
+ data.tar.gz: 701ab67291c19f5e7e180beeaa0501050fd3a1726d8d02918b3e305969f70266377d1ad66c65d17517a171c24440df917d233420916bc4429780541bdd688b0f
@@ -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
  {
@@ -84,7 +84,7 @@ module Bibliothecary
84
84
  end
85
85
 
86
86
  def self.parse_poetry(file_contents, options: {})
87
- manifest = Tomlrb.parse(file_contents)['tool']['poetry']
87
+ manifest = Tomlrb.parse(file_contents).fetch('tool', {}).fetch('poetry', {})
88
88
  map_dependencies(manifest['dependencies'], 'runtime') + map_dependencies(manifest['dev-dependencies'], 'develop')
89
89
  end
90
90
 
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.2.5"
2
+ VERSION = "8.3.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.2.5
4
+ version: 8.3.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-05-16 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb