bibliothecary 6.10.7 → 6.12.3

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: 97884ae133cf8ff23366cfdfbd6a97382e200313693eaaca8ceae2e743897a72
4
- data.tar.gz: 5cf10414b41b13552a692fa4802464eab0980489e9a1ce5a1e4f9601add8deb7
3
+ metadata.gz: ef4babc39a950bb7babd698d6b6de3022003aa6e6e112a0065d9b104adfcef13
4
+ data.tar.gz: 55fdb8f2a96a88d1d4810baccd74a5a0e0a753e91d68594325952610ade584c2
5
5
  SHA512:
6
- metadata.gz: 58c47af966516baa1fb6c9586670cf8dc5d1a0831f2b6fa44b750d7e7f62471063b89083ce7306878fb2989cb8b073b3c9b105b68a90883f7f4f9ac86a111999
7
- data.tar.gz: 2685dcd3c595d20c2d1fc5884dd1187079e2bdeddd6f354762b8ee3dfdb326fcb6574bcf4a15d3b7ea343f22847d188ee6093c4f7ccf6ae13c1b7d61794b6cce
6
+ metadata.gz: ad94c2c9e51aadbe003721deaf0d853269f04ff2730319256910283f15dd49517b9b4178747796d2c1c7bd4442c55d9ff411f95641a77d6fc6fed2e4c0f87bf8
7
+ data.tar.gz: 0220eeddcae84c0f2a6d7c0cb34bab3fdcd517a1da3c6e266913b6bc9729b285283dbe3cb771766b8efcee4f024320181ea42d7265b4e436ba3d261f8e42f203
@@ -0,0 +1,28 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@0.1.2
4
+
5
+ jobs:
6
+ test:
7
+ docker:
8
+ - image: circleci/ruby:2.6.6-stretch-node
9
+ executor: ruby/default
10
+ steps:
11
+ - checkout
12
+ - run:
13
+ name: Which bundler?
14
+ command: bundle -v
15
+ - ruby/bundle-install
16
+ - run:
17
+ name: Run specs
18
+ command: bundle exec rake spec
19
+ - run:
20
+ name: CodeClimate
21
+ command: bundle exec codeclimate-test-reporter
22
+
23
+ workflows:
24
+ version: 2.1
25
+ test:
26
+ jobs:
27
+ - test
28
+
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
data/lib/bibliothecary.rb CHANGED
@@ -21,8 +21,8 @@ module Bibliothecary
21
21
  runner.load_file_list(path)
22
22
  end
23
23
 
24
- def self.init_package_manager(info)
25
- runner.init_package_manager(info)
24
+ def self.applicable_package_managers(info)
25
+ runner.applicable_package_managers(info)
26
26
  end
27
27
 
28
28
  def self.load_file_info_list(path)
@@ -63,6 +63,8 @@ module Bibliothecary
63
63
 
64
64
  class << self
65
65
  attr_writer :configuration
66
+ alias analyze analyse
67
+ alias analyze_file analyse_file
66
68
  end
67
69
 
68
70
  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
@@ -26,14 +26,13 @@ module Bibliothecary
26
26
  }
27
27
  end
28
28
 
29
- def self.parse_conda(info)
30
- dependencies = call_conda_parser_web(info, "manifest")[:manifest]
29
+ def self.parse_conda(info, kind = "manifest")
30
+ dependencies = call_conda_parser_web(info, kind)[kind.to_sym]
31
31
  dependencies.map { |dep| dep.merge(type: "runtime") }
32
32
  end
33
33
 
34
34
  def self.parse_conda_lockfile(info)
35
- dependencies = call_conda_parser_web(info, "lockfile")[:lockfile]
36
- dependencies.map { |dep| dep.merge(type: "runtime") }
35
+ parse_conda(info, "lockfile")
37
36
  end
38
37
 
39
38
  private_class_method def self.call_conda_parser_web(file_contents, kind)
@@ -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
@@ -39,7 +39,24 @@ module Bibliothecary
39
39
  match_filename("poetry.lock") => {
40
40
  kind: 'lockfile',
41
41
  parser: :parse_poetry_lock
42
- }
42
+ },
43
+ # Pip dependencies can be embedded in conda environment files
44
+ match_filename("environment.yml") => {
45
+ parser: :parse_conda,
46
+ kind: "manifest",
47
+ },
48
+ match_filename("environment.yaml") => {
49
+ parser: :parse_conda,
50
+ kind: "manifest",
51
+ },
52
+ match_filename("environment.yml.lock") => {
53
+ parser: :parse_conda,
54
+ kind: "lockfile",
55
+ },
56
+ match_filename("environment.yaml.lock") => {
57
+ parser: :parse_conda,
58
+ kind: "lockfile",
59
+ },
43
60
  }
44
61
  end
45
62
 
@@ -53,6 +70,17 @@ module Bibliothecary
53
70
  map_dependencies(manifest['dependencies'], 'runtime') + map_dependencies(manifest['dev-dependencies'], 'develop')
54
71
  end
55
72
 
73
+ def self.parse_conda(file_contents)
74
+ contents = YAML.safe_load(file_contents)
75
+ return [] unless contents
76
+
77
+ dependencies = contents["dependencies"]
78
+ pip = dependencies.find { |dep| dep.is_a?(Hash) && dep["pip"]}
79
+ return [] unless pip
80
+
81
+ Pypi.parse_requirements_txt(pip["pip"].join("\n"))
82
+ end
83
+
56
84
  def self.map_dependencies(packages, type)
57
85
  return [] unless packages
58
86
  packages.map do |name, info|
@@ -26,20 +26,16 @@ 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)
32
33
  load_file_info_list(path).map { |info| info.full_path }
33
34
  end
34
35
 
35
- def init_package_manager(info)
36
- # set the package manager on each info
37
- matches = package_managers.select { |pm| pm.match_info?(info) }
38
-
39
- info.package_manager = matches[0] if matches.length == 1
40
-
41
- # this is a bug at the moment if it's raised (we don't handle it sensibly)
42
- raise "Multiple package managers fighting over #{info.relative_path}: #{matches.map(&:to_s)}" if matches.length > 1
36
+ def applicable_package_managers(info)
37
+ managers = package_managers.select { |pm| pm.match_info?(info) }
38
+ managers.length > 0 ? managers : [nil]
43
39
  end
44
40
 
45
41
  def package_managers
@@ -48,29 +44,41 @@ module Bibliothecary
48
44
 
49
45
  def load_file_info_list_from_paths(paths)
50
46
  file_list = []
47
+
51
48
  paths.each do |path|
52
49
  info = FileInfo.new(nil, path)
53
50
 
54
51
  next if ignored_files.include?(info.relative_path)
55
52
 
56
- init_package_manager(info)
57
- file_list.push(info)
53
+ applicable_package_managers(info).each do |package_manager|
54
+ file = info.dup
55
+ file.package_manager = package_manager
56
+
57
+ file_list.push(file)
58
+ end
58
59
  end
60
+
59
61
  file_list
60
62
  end
61
63
 
62
64
  def load_file_info_list(path)
63
65
  file_list = []
66
+
64
67
  Find.find(path) do |subpath|
65
68
  info = FileInfo.new(path, subpath)
69
+
66
70
  Find.prune if FileTest.directory?(subpath) && ignored_dirs.include?(info.relative_path)
67
71
  next unless FileTest.file?(subpath)
68
72
  next if ignored_files.include?(info.relative_path)
69
73
 
70
- init_package_manager(info)
74
+ applicable_package_managers(info).each do |package_manager|
75
+ file = info.dup
76
+ file.package_manager = package_manager
71
77
 
72
- file_list.push(info)
78
+ file_list.push(file)
79
+ end
73
80
  end
81
+
74
82
  file_list
75
83
  end
76
84
 
@@ -87,6 +95,7 @@ module Bibliothecary
87
95
  pm.analyse_contents(file_path, contents)
88
96
  end.flatten.uniq.compact
89
97
  end
98
+ alias analyze_file analyse_file
90
99
 
91
100
  # this skips manifests sometimes because it doesn't look at file
92
101
  # contents and can't establish from only regexes that the thing
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.10.7"
2
+ VERSION = "6.12.3"
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.7
4
+ version: 6.12.3
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-04-16 00:00:00.000000000 Z
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb
@@ -216,6 +216,7 @@ executables:
216
216
  extensions: []
217
217
  extra_rdoc_files: []
218
218
  files:
219
+ - ".circleci/config.yml"
219
220
  - ".codeclimate.yml"
220
221
  - ".github/CONTRIBUTING.md"
221
222
  - ".gitignore"