bibliothecary 6.9.3 → 6.9.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: eddf54931d180a739e69e33150ff5b105994976ff9436eae7765a88d7a5d7169
4
- data.tar.gz: 8f53292f1e7c7be586f9810dc723fb39dd145b8f436b6d82c6eb984cf7a726da
3
+ metadata.gz: 103fbc1356cfb20fcf31abf8af5394c2edce750cb6dae48a8f58f43071c16498
4
+ data.tar.gz: 1a4c95071bd3c9b43b2a8a2ca969ce24ca8e616910b70ca324abb4763a881f74
5
5
  SHA512:
6
- metadata.gz: bc54928770a24ef0214a11ca1cb9400875cf752ce28c907651cdc1ac879736e2e1c3860f71a5ebfda275d860dff4c495fcafb2f44cfd6c2b3f8f252b404dc7bc
7
- data.tar.gz: 9886c713649ec7503b7106c91fb1b5242d898ccb1fbd65462494c4d80b56186f08b536fa321fba6658e4c7ba183d624cc974e20c29b7e4bd6ffd3e8c3756661d
6
+ metadata.gz: edfc0874faab4c9bdb4cb5e91aa01a291eede73eba388369dac1ea6a992db20e1767f1305d8bcc3d6019405c4bc8608e519c6ce67eaa52ddc481e60e7a53eb79
7
+ data.tar.gz: 0c366ea34c210a4f5ee8c8c7eb2154a8a6a1ecb103c248314a8f0af3b9cfa5d903d0f26d840733db9208e88db6b9509cc860d9b79a2f7f31283fecd368d1bfb0
data/lib/bibliothecary.rb CHANGED
@@ -29,6 +29,10 @@ module Bibliothecary
29
29
  runner.load_file_info_list(path)
30
30
  end
31
31
 
32
+ def self.load_file_info_list_from_paths(paths)
33
+ runner.load_file_info_list_from_paths(paths)
34
+ end
35
+
32
36
  def self.analyse_file(file_path, contents)
33
37
  runner.analyse_file(file_path, contents)
34
38
  end
@@ -45,6 +49,10 @@ module Bibliothecary
45
49
  runner.find_manifests(path)
46
50
  end
47
51
 
52
+ def self.find_manifests_from_paths(paths)
53
+ runner.find_manifests_from_paths(paths)
54
+ end
55
+
48
56
  def self.ignored_dirs
49
57
  configuration.ignored_dirs
50
58
  end
@@ -126,11 +126,15 @@ module Bibliothecary
126
126
  # org.springframework.boot:spring-boot-starter-web:2.1.0.M3 (*)
127
127
  # Lines can end with (c), (n), or (*)
128
128
  # to indicate that something was a dependency constraint (c), not resolved (n), or resolved previously (*).
129
- dep = line.split(split)[1].sub(/(\((c|n|\*)\))$/, "").strip.split(":")
129
+ dep = line.split(split)[1].sub(/(\((c|n|\*)\))$/, "").sub(" -> ", ":").strip.split(":")
130
+
131
+ # A testImplementation line can look like this so just skip those
132
+ # \--- org.springframework.security:spring-security-test (n)
133
+ next unless dep.length >= 3
134
+
130
135
  version = dep[-1]
131
- version = version.split("->")[-1].strip if line.include?("->")
132
136
  {
133
- name: dep[0, dep.length - 1].join(":"),
137
+ name: dep[0..1].join(":"),
134
138
  requirement: version,
135
139
  type: type
136
140
  }
@@ -197,7 +201,7 @@ module Bibliothecary
197
201
  return nil if field.nil?
198
202
 
199
203
  value = field.nodes.first
200
- match = value.match(MAVEN_PROPERTY_REGEX)
204
+ match = value&.match(MAVEN_PROPERTY_REGEX)
201
205
  if match
202
206
  return extract_property(xml, match[1], value, parent_properties)
203
207
  else
@@ -70,10 +70,12 @@ module Bibliothecary
70
70
  if frameworks.size > 0
71
71
  # we should really return multiple manifests, but bibliothecary doesn't
72
72
  # do that yet so at least pick deterministically.
73
- frameworks[frameworks.keys.sort.last]
74
- else
75
- []
73
+
74
+ # Note, frameworks can be empty, so remove empty ones and then return the last sorted item if any
75
+ frameworks = frameworks.delete_if { |k, v| v.empty? }
76
+ return frameworks[frameworks.keys.sort.last] unless frameworks.empty?
76
77
  end
78
+ []
77
79
  end
78
80
 
79
81
  def self.parse_packages_config(file_contents)
@@ -91,10 +93,16 @@ module Bibliothecary
91
93
 
92
94
  def self.parse_csproj(file_contents)
93
95
  manifest = Ox.parse file_contents
96
+
94
97
  packages = manifest.locate('ItemGroup/PackageReference').map do |dependency|
98
+ requirement = (dependency.Version if dependency.respond_to? "Version") || "*"
99
+ if requirement.is_a?(Ox::Element)
100
+ requirement = dependency.nodes.detect{ |n| n.value == "Version" }&.text
101
+ end
102
+
95
103
  {
96
104
  name: dependency.Include,
97
- requirement: (dependency.Version if dependency.respond_to? "Version") || "*",
105
+ requirement: requirement,
98
106
  type: 'runtime'
99
107
  }
100
108
  end
@@ -46,6 +46,19 @@ module Bibliothecary
46
46
  Bibliothecary::Parsers.constants.map{|c| Bibliothecary::Parsers.const_get(c) }.sort_by{|c| c.to_s.downcase }
47
47
  end
48
48
 
49
+ def load_file_info_list_from_paths(paths)
50
+ file_list = []
51
+ paths.each do |path|
52
+ info = FileInfo.new(nil, path)
53
+
54
+ next if ignored_files.include?(info.relative_path)
55
+
56
+ init_package_manager(info)
57
+ file_list.push(info)
58
+ end
59
+ file_list
60
+ end
61
+
49
62
  def load_file_info_list(path)
50
63
  file_list = []
51
64
  Find.find(path) do |subpath|
@@ -65,6 +78,10 @@ module Bibliothecary
65
78
  RelatedFilesInfo.create_from_file_infos(load_file_info_list(path).reject { |info| info.package_manager.nil? })
66
79
  end
67
80
 
81
+ def find_manifests_from_paths(paths)
82
+ RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_paths(paths).reject { |info| info.package_manager.nil? })
83
+ end
84
+
68
85
  def analyse_file(file_path, contents)
69
86
  package_managers.select { |pm| pm.match?(file_path, contents) }.map do |pm|
70
87
  pm.analyse_contents(file_path, contents)
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "6.9.3"
2
+ VERSION = "6.9.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.9.3
4
+ version: 6.9.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: 2020-11-24 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb