bibliothecary 6.12.1 → 7.0.2

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: b4ff3342bf7c25f326b256ca8db4b5c44285bafcec2c66733d4628e829bfb0d5
4
- data.tar.gz: 55536bfc9d528ecfc99300dca1c723dc3ce3444a83af581963940b7c268901cf
3
+ metadata.gz: 1c44d6a07f7c3cdd1e6517420b6fe59f0b453201f0f4deb7e3870f206ace5a04
4
+ data.tar.gz: 07ddf505184913265f608eea5b0ad8f9293b69a47bbe353606651d510b8d6158
5
5
  SHA512:
6
- metadata.gz: ed2f8a734345a88266b2410bfa6559cda8a9fc4b43d946ee5fab89700de1ec57e45441e1e924c70a2ff6641991649a924158577cbf3de10dab00f4cff267c296
7
- data.tar.gz: 3e5f7ac3867b68b07c25c2d2364629440a377ac21f74d9b4cfd680d3f0069aa54f64aa470ab86261546c7f572cec559ccb5937cfe292d2d1ee9139b222c8c08c
6
+ metadata.gz: 2c8693bace5bb30e27ae2cd72c130a68f8c2e8cdbb0f487b5bef59374a7ac6ad103bc10a2214f3ce2409a5c73dd861136f3e7c4b751d1a17b9ff13bb400a4ba7
7
+ data.tar.gz: 6d92229299dd6c3997ab9ff2addde302baf95383660a7849afaa519bc94b519196c7a11aae08bc23c24daaf96bb689c1431f9ab07efe1e0cbcce7f4e0d91e6a5
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "toml-rb", "~> 1.0"
21
+ spec.add_dependency "tomlrb", "~> 2.0"
22
22
  spec.add_dependency "librariesio-gem-parser"
23
23
  spec.add_dependency "ox", ">= 2.8.1"
24
24
  spec.add_dependency "typhoeus"
data/lib/bibliothecary.rb CHANGED
@@ -6,6 +6,7 @@ require "bibliothecary/exceptions"
6
6
  require "bibliothecary/file_info"
7
7
  require "bibliothecary/related_files_info"
8
8
  require "find"
9
+ require "tomlrb"
9
10
 
10
11
  Dir[File.expand_path('../bibliothecary/parsers/*.rb', __FILE__)].each do |file|
11
12
  require file
@@ -1,5 +1,3 @@
1
- require 'toml-rb'
2
-
3
1
  module Bibliothecary
4
2
  module Parsers
5
3
  class Cargo
@@ -19,7 +17,7 @@ module Bibliothecary
19
17
  end
20
18
 
21
19
  def self.parse_manifest(file_contents)
22
- manifest = TomlRB.parse(file_contents)
20
+ manifest = Tomlrb.parse(file_contents)
23
21
  manifest.fetch('dependencies', []).map do |name, requirement|
24
22
  if requirement.respond_to?(:fetch)
25
23
  requirement = requirement['version'] or next
@@ -34,7 +32,7 @@ module Bibliothecary
34
32
  end
35
33
 
36
34
  def self.parse_lockfile(file_contents)
37
- manifest = TomlRB.parse(file_contents)
35
+ manifest = Tomlrb.parse(file_contents)
38
36
  manifest.fetch('package',[]).map do |dependency|
39
37
  next if not dependency['source'] or not dependency['source'].start_with?('registry+')
40
38
  {
@@ -106,12 +106,12 @@ module Bibliothecary
106
106
  end
107
107
 
108
108
  def self.parse_dep_toml(file_contents)
109
- manifest = TomlRB.parse file_contents
109
+ manifest = Tomlrb.parse file_contents
110
110
  map_dependencies(manifest, 'constraint', 'name', 'version', 'runtime')
111
111
  end
112
112
 
113
113
  def self.parse_dep_lockfile(file_contents)
114
- manifest = TomlRB.parse file_contents
114
+ manifest = Tomlrb.parse file_contents
115
115
  map_dependencies(manifest, 'projects', 'name', 'revision', 'runtime')
116
116
  end
117
117
 
@@ -152,10 +152,12 @@ module Bibliothecary
152
152
  .compact
153
153
  .uniq
154
154
  end
155
+
155
156
  def self.parse_maven_tree(file_contents)
156
157
  file_contents = file_contents.gsub(/\r\n?/, "\n")
157
158
  captures = file_contents.scan(/^\[INFO\](?:(?:\+-)|\||(?:\\-)|\s)+((?:[\w\.-]+:)+[\w\.\-${}]+)/).flatten.uniq
158
- captures.map do |item|
159
+
160
+ deps = captures.map do |item|
159
161
  parts = item.split(":")
160
162
  case parts.count
161
163
  when 4
@@ -170,6 +172,10 @@ module Bibliothecary
170
172
  type: type
171
173
  }
172
174
  end
175
+
176
+ # First dep line will be the package itself (unless we're only analyzing a single line)
177
+ package = deps[0]
178
+ deps.size < 2 ? deps : deps[1..-1].reject { |d| d[:name] == package[:name] && d[:requirement] == package[:requirement] }
173
179
  end
174
180
 
175
181
  def self.parse_resolved_dep_line(line)
@@ -238,6 +244,7 @@ module Bibliothecary
238
244
  return nil if field.nil?
239
245
 
240
246
  value = field.nodes.first
247
+ value = value.value if value.is_a?(Ox::CData)
241
248
  match = value&.match(MAVEN_PROPERTY_REGEX)
242
249
  if match
243
250
  return extract_property(xml, match[1], value, parent_properties)
@@ -49,9 +49,18 @@ module Bibliothecary
49
49
  else
50
50
  type = 'runtime'
51
51
  end
52
+
53
+ version = nil
54
+
55
+ if requirement.key?("from")
56
+ version = requirement["from"][/#(?:semver:)?v?(.*)/, 1]
57
+ end
58
+
59
+ version ||= requirement["version"].split("#").last
60
+
52
61
  {
53
62
  name: name,
54
- requirement: requirement["version"],
63
+ requirement: version,
55
64
  type: type
56
65
  }
57
66
  end
@@ -61,12 +61,12 @@ module Bibliothecary
61
61
  end
62
62
 
63
63
  def self.parse_pipfile(file_contents)
64
- manifest = TomlRB.parse(file_contents)
64
+ manifest = Tomlrb.parse(file_contents)
65
65
  map_dependencies(manifest['packages'], 'runtime') + map_dependencies(manifest['dev-packages'], 'develop')
66
66
  end
67
67
 
68
68
  def self.parse_poetry(file_contents)
69
- manifest = TomlRB.parse(file_contents)['tool']['poetry']
69
+ manifest = Tomlrb.parse(file_contents)['tool']['poetry']
70
70
  map_dependencies(manifest['dependencies'], 'runtime') + map_dependencies(manifest['dev-dependencies'], 'develop')
71
71
  end
72
72
 
@@ -124,7 +124,7 @@ module Bibliothecary
124
124
  end
125
125
 
126
126
  def self.parse_poetry_lock(file_contents)
127
- manifest = TomlRB.parse(file_contents)
127
+ manifest = Tomlrb.parse(file_contents)
128
128
  deps = []
129
129
  manifest["package"].each do |package|
130
130
  # next if group == "_meta"
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.12.1"
2
+ VERSION = "7.0.2"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.12.1
4
+ version: 7.0.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: 2021-05-20 00:00:00.000000000 Z
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: toml-rb
14
+ name: tomlrb
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: librariesio-gem-parser
29
29
  requirement: !ruby/object:Gem::Requirement