bibliothecary 6.8.3 → 6.8.8

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: 631db7c6b4d1e299b186bd8491fc99ab0a6fee4b81b7224b70f1548b44d6ed09
4
- data.tar.gz: 8c46571d73f5001114e4e2d880c07e03d0d4d8bc44851f1bb9eae667c83f6cc6
3
+ metadata.gz: 9a942d8a210e009f17a359b9ead9049423c091d9609d6d1770eb79fc47fb16d6
4
+ data.tar.gz: bd1f6a3f7d3652981ee46002fe3466480c9bf9d08c7dc1dbd5bffab3698e21a0
5
5
  SHA512:
6
- metadata.gz: 803ac1fcc4ed177c468ab66009153c54c96c1079f397d18ef8361a5453f26cf3e51442cb58e059dcf95b2a908bf0f5d54210d9d1dbd018e1c926cdb18d28efd4
7
- data.tar.gz: a288761f1e9db8fb87beca4daa1e08fed93d747192f921e7c38cc81743589f25673bfe805435f8876cadc4a4b0bf68bf948d6bbf0d3b4ea47250f9221c8d8ad4
6
+ metadata.gz: af583cc0c0dea0e280a3b28c30a9bbda9413331e76d1bfd0eba6908d209b43893cd2677acdb6113d498833514b0656cd57a0014f4949a48d1d276a629838acba
7
+ data.tar.gz: e8f49049133561c3fdfeb48d692736e407457943f19668251f75c5db93fae1276540754e7f0a6b0986f80f303e81a7df72ecb1dbf03c48f05d81b0e1f2057922
@@ -1 +1 @@
1
- 2.5.1
1
+ 2.6.6
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.1
3
+ - 2.6.6
4
4
  cache: bundler
5
5
  before_install:
6
6
  - gem update --system
7
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
8
- - gem install bundler -v '< 2'
7
+ - gem install bundler
9
8
  script:
10
9
  - bundle exec rake spec && bundle exec codeclimate-test-reporter
11
10
  notifications:
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "strings-ansi"
29
29
  spec.add_dependency "strings"
30
30
 
31
- spec.add_development_dependency "bundler", "~> 1.11"
32
31
  spec.add_development_dependency "pry"
33
32
  spec.add_development_dependency "rake", "~> 12.0"
34
33
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -1,67 +1,53 @@
1
- require 'json'
1
+ require "json"
2
2
 
3
3
  module Bibliothecary
4
4
  module Parsers
5
5
  class Conda
6
6
  include Bibliothecary::Analyser
7
- FILE_KINDS = %w[manifest lockfile]
8
7
 
9
8
  def self.mapping
10
9
  {
11
10
  match_filename("environment.yml") => {
12
- kind: FILE_KINDS
11
+ parser: :parse_conda,
12
+ kind: "manifest",
13
13
  },
14
14
  match_filename("environment.yaml") => {
15
- kind: FILE_KINDS
16
- }
15
+ parser: :parse_conda,
16
+ kind: "manifest",
17
+ },
18
+ match_filename("environment.yml.lock") => {
19
+ parser: :parse_conda_lockfile,
20
+ kind: "lockfile",
21
+ },
22
+ match_filename("environment.yaml.lock") => {
23
+ parser: :parse_conda_lockfile,
24
+ kind: "lockfile",
25
+ },
17
26
  }
18
27
  end
19
28
 
20
- # Overrides Analyser.analyse_contents_from_info
21
- def self.analyse_contents_from_info(info)
22
- [parse_conda(info), parse_pip(info)].flatten.compact
23
- rescue Bibliothecary::RemoteParsingError => e
24
- Bibliothecary::Analyser::create_error_analysis(platform_name, info.relative_path, "runtime", e.message)
25
- rescue Psych::SyntaxError => e
26
- Bibliothecary::Analyser::create_error_analysis(platform_name, info.relative_path, "runtime", e.message)
27
- end
28
-
29
- private
30
-
31
29
  def self.parse_conda(info)
32
- results = call_conda_parser_web(info.contents)
33
- FILE_KINDS.map do |kind|
34
- Bibliothecary::Analyser.create_analysis(
35
- "conda",
36
- info.relative_path,
37
- kind,
38
- results[kind.to_sym].map { |dep| dep.slice(:name, :requirement).merge(type: "runtime") }
39
- )
40
- end
30
+ dependencies = call_conda_parser_web(info, "manifest")[:manifest]
31
+ dependencies.map { |dep| dep.merge(type: "runtime") }
41
32
  end
42
33
 
43
- def self.parse_pip(info)
44
- dependencies = YAML.safe_load(info.contents)["dependencies"]
45
- pip = dependencies.find { |dep| dep.is_a?(Hash) && dep["pip"]}
46
- return unless pip
47
-
48
- Bibliothecary::Analyser.create_analysis(
49
- "pypi",
50
- info.relative_path,
51
- "manifest",
52
- Pypi.parse_requirements_txt(pip["pip"].join("\n"))
53
- )
34
+ def self.parse_conda_lockfile(info)
35
+ dependencies = call_conda_parser_web(info, "lockfile")[:lockfile]
36
+ dependencies.map { |dep| dep.merge(type: "runtime") }
54
37
  end
55
38
 
56
- def self.call_conda_parser_web(file_contents)
39
+ private_class_method def self.call_conda_parser_web(file_contents, kind)
57
40
  host = Bibliothecary.configuration.conda_parser_host
58
41
  response = Typhoeus.post(
59
42
  "#{host}/parse",
60
43
  headers: {
61
- ContentType: 'multipart/form-data'
44
+ ContentType: "multipart/form-data",
62
45
  },
63
- # hardcoding `environment.yml` to send to `conda.libraries.io`, downside is logs will always show `environment.yml` there
64
- body: {file: file_contents, filename: 'environment.yml'}
46
+ body: {
47
+ file: file_contents,
48
+ # Unfortunately we do not get the filename in the mapping parsers, so hardcoding the file name depending on the kind
49
+ filename: kind == "manifest" ? "environment.yml" : "environment.yml.lock",
50
+ }
65
51
  )
66
52
  raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{host}/parse", response.response_code) unless response.success?
67
53
 
@@ -7,12 +7,13 @@ module Bibliothecary
7
7
  include Bibliothecary::Analyser
8
8
 
9
9
  GPM_REGEXP = /^(.+)\s+(.+)$/
10
- GOMOD_REGEX = /^(.+)\s+(.+)$/
11
- GOMOD_IGNORABLE_REGEX = /^(module\s|require\s+\(|go\s|\))/m
10
+ GOMOD_REGEX = /^(require\s+)?(.+)\s+(.+)$/
11
+ GOMOD_IGNORABLE_REGEX = /^(\/\/|module\s|go\s|exclude\s|replace\s|require\s+\(|\))/m
12
12
  GOSUM_REGEX = /^(.+)\s+(.+)\s+(.+)$/
13
13
 
14
14
  def self.mapping
15
15
  {
16
+ # Go Modules (recommended)
16
17
  match_filename("go.mod") => {
17
18
  kind: 'manifest',
18
19
  parser: :parse_go_mod
@@ -21,6 +22,7 @@ module Bibliothecary
21
22
  kind: 'lockfile',
22
23
  parser: :parse_go_sum
23
24
  },
25
+ # Glide (unmaintained: https://github.com/Masterminds/glide#go-modules)
24
26
  match_filename("glide.yaml") => {
25
27
  kind: 'manifest',
26
28
  parser: :parse_glide_yaml
@@ -29,6 +31,7 @@ module Bibliothecary
29
31
  kind: 'lockfile',
30
32
  parser: :parse_glide_lockfile
31
33
  },
34
+ # Godep (unmaintained: https://github.com/tools/godep)
32
35
  match_filename("Godeps/Godeps.json") => {
33
36
  kind: 'manifest',
34
37
  parser: :parse_godep_json
@@ -37,6 +40,7 @@ module Bibliothecary
37
40
  kind: 'manifest',
38
41
  parser: :parse_gpm
39
42
  },
43
+ # Govendor (unmaintained: https://github.com/kardianos/govendor)
40
44
  match_filename("vendor/manifest") => {
41
45
  kind: 'manifest',
42
46
  parser: :parse_gb_manifest
@@ -45,6 +49,7 @@ module Bibliothecary
45
49
  kind: 'manifest',
46
50
  parser: :parse_govendor
47
51
  },
52
+ # Go dep (deprecated: https://github.com/golang/dep#dep)
48
53
  match_filename("Gopkg.toml") => {
49
54
  kind: 'manifest',
50
55
  parser: :parse_dep_toml
@@ -112,8 +117,8 @@ module Bibliothecary
112
117
  next if line.match(GOMOD_IGNORABLE_REGEX)
113
118
  if match = line.gsub(/(\/\/(.*))/, '').match(GOMOD_REGEX)
114
119
  deps << {
115
- name: match[1].strip,
116
- requirement: match[2].strip || '*',
120
+ name: match[2].strip,
121
+ requirement: match[3].strip || '*',
117
122
  type: 'runtime'
118
123
  }
119
124
  end
@@ -16,6 +16,10 @@ module Bibliothecary
16
16
  kind: 'lockfile',
17
17
  parser: :parse_project_lock_json
18
18
  },
19
+ match_filename("packages.lock.json") => {
20
+ kind: 'lockfile',
21
+ parser: :parse_packages_lock_json
22
+ },
19
23
  match_filename("packages.config") => {
20
24
  kind: 'manifest',
21
25
  parser: :parse_packages_config
@@ -47,6 +51,31 @@ module Bibliothecary
47
51
  end
48
52
  end
49
53
 
54
+ def self.parse_packages_lock_json(file_contents)
55
+ manifest = JSON.parse file_contents
56
+
57
+ frameworks = {}
58
+ manifest.fetch('dependencies',[]).each do |framework, deps|
59
+ frameworks[framework] = deps.map do |name, details|
60
+ {
61
+ name: name,
62
+ # 'resolved' has been set in all examples so far
63
+ # so fallback to requested is pure paranoia
64
+ requirement: details.fetch('resolved', details.fetch('requested', '*')),
65
+ type: 'runtime'
66
+ }
67
+ end
68
+ end
69
+
70
+ if frameworks.size > 0
71
+ # we should really return multiple manifests, but bibliothecary doesn't
72
+ # do that yet so at least pick deterministically.
73
+ frameworks[frameworks.keys.sort.last]
74
+ else
75
+ []
76
+ end
77
+ end
78
+
50
79
  def self.parse_packages_config(file_contents)
51
80
  manifest = Ox.parse file_contents
52
81
  manifest.packages.locate('package').map do |dependency|
@@ -15,6 +15,10 @@ module Bibliothecary
15
15
  parser: :parse_requirements_txt,
16
16
  can_have_lockfile: false
17
17
  },
18
+ match_filename('pip-resolved-dependencies.txt') => { # Inferred from pip
19
+ kind: 'lockfile',
20
+ parser: :parse_requirements_txt,
21
+ },
18
22
  match_filename("setup.py") => {
19
23
  kind: 'manifest',
20
24
  parser: :parse_setup_py,
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.8.3"
2
+ VERSION = "6.8.8"
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.8.3
4
+ version: 6.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-26 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: bundler
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '1.11'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.11'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: pry
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -302,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
288
  - !ruby/object:Gem::Version
303
289
  version: '0'
304
290
  requirements: []
305
- rubygems_version: 3.0.4
291
+ rubygems_version: 3.0.3
306
292
  signing_key:
307
293
  specification_version: 4
308
294
  summary: Find and parse manifests