bibliothecary 6.11.0 → 7.0.0

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: caaa965267d6272e22ec385e0ad56505f645cdc3437163ec2a9d40471c1e620b
4
- data.tar.gz: a2ad1df3e6481e0faed3d27039557b5b248f73fe5fa9864cd7d9462e215af72a
3
+ metadata.gz: 527bb093daab817755bf4f5a3d35b1aa831f292f9fe8112ddf6a917b368239ac
4
+ data.tar.gz: 37ffb251371c1aed5465e15e933dd41921f341ff4794da004d8678cda695cd25
5
5
  SHA512:
6
- metadata.gz: 2a333bfa32d1c31abf164afd8a09b7060ffe2809b43199273e706e83dd01d9638e57f85787390deba7e923a9b26494e47074718df319bac159d9cfbb4bb32a26
7
- data.tar.gz: 7a68137ae7f02721a2ae8ae94dad59783a07ba291c440cbc6469af0164b0f57a83b055dd16ac5ca58ba2a00de76e217a8fd778b30c98b1585760aa47f60c3ff1
6
+ metadata.gz: 6f67cfe62ca501f2ad8064e3fff37593e929d20d8210d619a57e88a887f4fc981081fb1cdc09e9e8b5ab582d22eb46e760b6f53456e9ecfb179a744a7c6b1d91
7
+ data.tar.gz: 407398a4772816f145da883104d5a21516117fd8e544ecaff3e0dd438c26a02f8a17bc766e2c51a602ac72008c6954e16ee9478db2f80700d3ac47ebb6182858
data/README.md CHANGED
@@ -88,6 +88,7 @@ All available config options are in: https://github.com/librariesio/bibliothecar
88
88
  - *.nuspec
89
89
  - paket.lock
90
90
  - *.csproj
91
+ - project.assets.json
91
92
  - Bower
92
93
  - bower.json
93
94
  - CPAN
@@ -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
@@ -63,6 +64,8 @@ module Bibliothecary
63
64
 
64
65
  class << self
65
66
  attr_writer :configuration
67
+ alias analyze analyse
68
+ alias analyze_file analyse_file
66
69
  end
67
70
 
68
71
  def self.runner
@@ -101,6 +101,7 @@ module Bibliothecary
101
101
  def analyse(folder_path, file_list)
102
102
  analyse_file_info(file_list.map { |full_path| FileInfo.new(folder_path, full_path) })
103
103
  end
104
+ alias analyze analyse
104
105
 
105
106
  def analyse_file_info(file_info_list)
106
107
  matching_info = file_info_list
@@ -111,10 +112,12 @@ module Bibliothecary
111
112
  .merge(related_paths: related_paths(info, matching_info))
112
113
  end
113
114
  end
115
+ alias analyze_file_info analyse_file_info
114
116
 
115
117
  def analyse_contents(filename, contents)
116
118
  analyse_contents_from_info(FileInfo.new(nil, filename, contents))
117
119
  end
120
+ alias analyze_contents analyse_contents
118
121
 
119
122
  def analyse_contents_from_info(info)
120
123
  # If your Parser needs to return multiple responses for one file, please override this method
@@ -126,6 +129,7 @@ module Bibliothecary
126
129
  rescue Bibliothecary::FileParsingError => e
127
130
  Bibliothecary::Analyser::create_error_analysis(platform_name, info.relative_path, kind, e.message)
128
131
  end
132
+ alias analyze_contents_from_info analyse_contents_from_info
129
133
 
130
134
  # calling this with contents=nil can produce less-informed
131
135
  # results, but kept for back compat
@@ -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
 
@@ -238,6 +238,7 @@ module Bibliothecary
238
238
  return nil if field.nil?
239
239
 
240
240
  value = field.nodes.first
241
+ value = value.value if value.is_a?(Ox::CData)
241
242
  match = value&.match(MAVEN_PROPERTY_REGEX)
242
243
  if match
243
244
  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
@@ -35,7 +35,11 @@ module Bibliothecary
35
35
  match_filename("paket.lock") => {
36
36
  kind: 'lockfile',
37
37
  parser: :parse_paket_lock
38
- }
38
+ },
39
+ match_filename("project.assets.json") => {
40
+ kind: 'lockfile',
41
+ parser: :parse_project_assets_json
42
+ },
39
43
  }
40
44
  end
41
45
 
@@ -137,6 +141,34 @@ module Bibliothecary
137
141
  # we only have to enforce uniqueness by name because paket ensures that there is only the single version globally in the project
138
142
  packages.uniq {|package| package[:name] }
139
143
  end
144
+
145
+ def self.parse_project_assets_json(file_contents)
146
+ manifest = JSON.parse file_contents
147
+
148
+ frameworks = {}
149
+ manifest.fetch("targets",[]).each do |framework, deps|
150
+ frameworks[framework] = deps
151
+ .select { |name, details| details["type"] == "package" }
152
+ .map do |name, details|
153
+ name_split = name.split("/")
154
+ {
155
+ name: name_split[0],
156
+ requirement: name_split[1],
157
+ type: "runtime"
158
+ }
159
+ end
160
+ end
161
+
162
+ if frameworks.size > 0
163
+ # we should really return multiple manifests, but bibliothecary doesn't
164
+ # do that yet so at least pick deterministically.
165
+
166
+ # Note, frameworks can be empty, so remove empty ones and then return the last sorted item if any
167
+ frameworks = frameworks.delete_if { |k, v| v.empty? }
168
+ return frameworks[frameworks.keys.sort.last] unless frameworks.empty?
169
+ end
170
+ []
171
+ end
140
172
  end
141
173
  end
142
174
  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"
@@ -26,6 +26,7 @@ module Bibliothecary
26
26
 
27
27
  analyses
28
28
  end
29
+ alias analyze analyse
29
30
 
30
31
  # deprecated; use load_file_info_list.
31
32
  def load_file_list(path)
@@ -94,6 +95,7 @@ module Bibliothecary
94
95
  pm.analyse_contents(file_path, contents)
95
96
  end.flatten.uniq.compact
96
97
  end
98
+ alias analyze_file analyse_file
97
99
 
98
100
  # this skips manifests sometimes because it doesn't look at file
99
101
  # contents and can't establish from only regexes that the thing
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.11.0"
2
+ VERSION = "7.0.0"
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.11.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2021-06-17 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
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
- description:
209
+ description:
210
210
  email:
211
211
  - andrewnez@gmail.com
212
212
  executables:
@@ -274,7 +274,7 @@ homepage: https://github.com/librariesio/bibliothecary
274
274
  licenses:
275
275
  - AGPL-3.0
276
276
  metadata: {}
277
- post_install_message:
277
+ post_install_message:
278
278
  rdoc_options: []
279
279
  require_paths:
280
280
  - lib
@@ -289,8 +289,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  - !ruby/object:Gem::Version
290
290
  version: '0'
291
291
  requirements: []
292
- rubygems_version: 3.1.2
293
- signing_key:
292
+ rubygems_version: 3.2.15
293
+ signing_key:
294
294
  specification_version: 4
295
295
  summary: Find and parse manifests
296
296
  test_files: []