bibliothecary 6.8.3 → 6.8.4

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: 9f6d0c75dace8b988d53e7b6620e7c1c8aad139ddf4aebbc1497c1428b4bda09
4
+ data.tar.gz: ea3e235adc6e425269eb29fda38694555be29b54bcb5cdc7ec8b455ac06b554c
5
5
  SHA512:
6
- metadata.gz: 803ac1fcc4ed177c468ab66009153c54c96c1079f397d18ef8361a5453f26cf3e51442cb58e059dcf95b2a908bf0f5d54210d9d1dbd018e1c926cdb18d28efd4
7
- data.tar.gz: a288761f1e9db8fb87beca4daa1e08fed93d747192f921e7c38cc81743589f25673bfe805435f8876cadc4a4b0bf68bf948d6bbf0d3b4ea47250f9221c8d8ad4
6
+ metadata.gz: 191203c29364c6fb45bf9228fa49a1ae3e8f176ec1e7331c07e3bf731688ac896220d49a4271773703ec48a240cdb0fdfc555fd887ed14cd459d2788a285339c
7
+ data.tar.gz: 185c27f488fd30d3026447193396637b90a46c286c7cbf02b207ce0dd1ff30d576c73b5a39262f61ad3fe7bf7975f9df0ef20cfb61701ac532cc969733ef26f2
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.8.3"
2
+ VERSION = "6.8.4"
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.4
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: 2019-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb