bibliothecary 6.10.2 → 6.10.7

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: 4da554e866567459e3e2dea24812aa193288f913f7fd32bf2ccb65bb3d331106
4
- data.tar.gz: 4125918d570e46d9076d11abff2f12e80168b9439b3a4c49c0c494367c089c52
3
+ metadata.gz: 97884ae133cf8ff23366cfdfbd6a97382e200313693eaaca8ceae2e743897a72
4
+ data.tar.gz: 5cf10414b41b13552a692fa4802464eab0980489e9a1ce5a1e4f9601add8deb7
5
5
  SHA512:
6
- metadata.gz: 39777e9b798d1b8acc1ca64c7148122e195539ed05aa960bdc9bd851b92c455ba0289a3b48820385d65c31b3b9b63ddf14060a80bc808f1ce676eebe64562a4b
7
- data.tar.gz: 558180871bb9e340c0dd46239b82d976ff39884f56a8a7aedf483422c2182af1ea179c275387188c622a7dbc07a3fdb3d58a75a3e0aeacddea06f0bf13296643
6
+ metadata.gz: 58c47af966516baa1fb6c9586670cf8dc5d1a0831f2b6fa44b750d7e7f62471063b89083ce7306878fb2989cb8b073b3c9b105b68a90883f7f4f9ac86a111999
7
+ data.tar.gz: 2685dcd3c595d20c2d1fc5884dd1187079e2bdeddd6f354762b8ee3dfdb326fcb6574bcf4a15d3b7ea343f22847d188ee6093c4f7ccf6ae13c1b7d61794b6cce
@@ -153,7 +153,8 @@ module Bibliothecary
153
153
  .uniq
154
154
  end
155
155
  def self.parse_maven_tree(file_contents)
156
- captures = file_contents.scan(/^\[INFO\][\s|+-\\]+([[\w.-]+:]+)(?=$|\s\(optional\)$)/).flatten.uniq
156
+ file_contents = file_contents.gsub(/\r\n?/, "\n")
157
+ captures = file_contents.scan(/^\[INFO\](?:(?:\+-)|\||(?:\\-)|\s)+((?:[\w\.-]+:)+[\w\.\-${}]+)/).flatten.uniq
157
158
  captures.map do |item|
158
159
  parts = item.split(":")
159
160
  case parts.count
@@ -204,8 +205,8 @@ module Bibliothecary
204
205
  json = JSON.parse(response.body)
205
206
  return [] unless json['dependencies']
206
207
  json['dependencies'].map do |dependency|
207
- name = [dependency["group"], dependency["name"]].join(':')
208
- next unless name =~ (/[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(\.[A-Za-z0-9_-])?\:[A-Za-z0-9_-]/)
208
+ name = gradle_dependency_name(dependency["group"], dependency["name"])
209
+ next unless name =~ /[\w-]+\.[\w_-]+(\.[\w-])?\:[\w-]/
209
210
  {
210
211
  name: name,
211
212
  requirement: dependency["version"],
@@ -214,6 +215,20 @@ module Bibliothecary
214
215
  end.compact
215
216
  end
216
217
 
218
+ def self.gradle_dependency_name(group, name)
219
+ if group.empty? && name.include?(":")
220
+ group, name = name.split(":", 2)
221
+ end
222
+
223
+ # Strip comments, and single/doublequotes
224
+ [group, name].map do |part|
225
+ part
226
+ .gsub(/\s*\/\/.*$/, "") # Comments
227
+ .gsub(/^["']/, "") # Beginning single/doublequotes
228
+ .gsub(/["']$/, "") # Ending single/doublequotes
229
+ end.join(":")
230
+ end
231
+
217
232
  def self.extract_pom_info(xml, location, parent_properties = {})
218
233
  extract_pom_dep_info(xml, xml, location, parent_properties)
219
234
  end
@@ -22,6 +22,10 @@ module Bibliothecary
22
22
  match_filename("package-lock.json") => {
23
23
  kind: 'lockfile',
24
24
  parser: :parse_package_lock
25
+ },
26
+ match_filename("npm-ls.json") => {
27
+ kind: 'lockfile',
28
+ parser: :parse_ls
25
29
  }
26
30
  }
27
31
  end
@@ -75,6 +79,25 @@ module Bibliothecary
75
79
  }
76
80
  end
77
81
  end
82
+
83
+ def self.parse_ls(file_contents)
84
+ manifest = JSON.parse(file_contents)
85
+
86
+ transform_tree_to_array(manifest.fetch('dependencies', {}))
87
+ end
88
+
89
+ private_class_method def self.transform_tree_to_array(deps_by_name)
90
+ deps_by_name.map do |name, metadata|
91
+ [
92
+ {
93
+ name: name,
94
+ requirement: metadata["version"],
95
+ lockfile_requirement: metadata.fetch("from", "").split('@').last,
96
+ type: "runtime"
97
+ }
98
+ ] + transform_tree_to_array(metadata.fetch("dependencies", {}))
99
+ end.flatten(1)
100
+ end
78
101
  end
79
102
  end
80
103
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.10.2"
2
+ VERSION = "6.10.7"
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.10.2
4
+ version: 6.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb
@@ -288,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  - !ruby/object:Gem::Version
289
289
  version: '0'
290
290
  requirements: []
291
- rubygems_version: 3.0.3
291
+ rubygems_version: 3.1.2
292
292
  signing_key:
293
293
  specification_version: 4
294
294
  summary: Find and parse manifests