bibliothecary 7.1.2 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/bibliothecary/parsers/pypi.rb +9 -4
- data/lib/bibliothecary/related_files_info.rb +2 -2
- data/lib/bibliothecary/runner.rb +33 -12
- data/lib/bibliothecary/version.rb +1 -1
- data/lib/bibliothecary.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac170521ce85ef87c25442284632da0d641709136108e15f2b5b4e3050f9f56e
|
|
4
|
+
data.tar.gz: b97db15b605b8f39687c10b70dd46023ce2ebfb8a1d7b9076a5151b81f871c8b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac11fca807e0d45f9dff9984d180577853f238446112e9c65f8e298c26d26f100ad5b0071eba00d02bebbd7b84976aac497ec3cbf6c860839524730ef2945569
|
|
7
|
+
data.tar.gz: ac4fb797dc8a121e93b85a05dc087cd2ed01114da5fbec082b704c3ae9201e5727434bd731338175d46fc1ea56fbfb5b8935e0c2fd9aa829c5c9e686855520da
|
data/README.md
CHANGED
|
@@ -4,9 +4,14 @@ module Bibliothecary
|
|
|
4
4
|
include Bibliothecary::Analyser
|
|
5
5
|
|
|
6
6
|
INSTALL_REGEXP = /install_requires\s*=\s*\[([\s\S]*?)\]/
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
# Capture Group 1 is package.
|
|
9
|
+
# Optional Group 2 is [extras].
|
|
10
|
+
# Capture Group 3 is Version
|
|
11
|
+
REQUIRE_REGEXP = /([a-zA-Z0-9]+[a-zA-Z0-9\-_\.]+)(?:\[.*?\])*([><=\w\.,]+)?/
|
|
12
|
+
|
|
8
13
|
REQUIREMENTS_REGEXP = /^#{REQUIRE_REGEXP}/
|
|
9
|
-
MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip)$/
|
|
14
|
+
MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip|in)$/
|
|
10
15
|
PIP_COMPILE_REGEXP = /.*require.*$/
|
|
11
16
|
|
|
12
17
|
def self.mapping
|
|
@@ -160,7 +165,7 @@ module Bibliothecary
|
|
|
160
165
|
next unless match
|
|
161
166
|
deps << {
|
|
162
167
|
name: match[1],
|
|
163
|
-
requirement: match[
|
|
168
|
+
requirement: match[-1] || '*',
|
|
164
169
|
type: 'runtime'
|
|
165
170
|
}
|
|
166
171
|
end
|
|
@@ -174,7 +179,7 @@ module Bibliothecary
|
|
|
174
179
|
next unless match
|
|
175
180
|
deps << {
|
|
176
181
|
name: match[1],
|
|
177
|
-
requirement: match[
|
|
182
|
+
requirement: match[-1] || '*',
|
|
178
183
|
type: 'runtime'
|
|
179
184
|
}
|
|
180
185
|
end
|
|
@@ -22,8 +22,8 @@ module Bibliothecary
|
|
|
22
22
|
@platform = package_manager.platform_name
|
|
23
23
|
@path = Pathname.new(File.dirname(file_infos.first.relative_path)).cleanpath.to_path
|
|
24
24
|
# `package_manager.determine_kind_from_info(info)` can be an Array, so use include? which also works for string
|
|
25
|
-
@manifests = file_infos.select { |info| package_manager.determine_kind_from_info(info).include? "manifest" }.map
|
|
26
|
-
@lockfiles = file_infos.select { |info| package_manager.determine_kind_from_info(info).include? "lockfile" }.map
|
|
25
|
+
@manifests = file_infos.select { |info| package_manager.determine_kind_from_info(info).include? "manifest" }.map(&:relative_path)
|
|
26
|
+
@lockfiles = file_infos.select { |info| package_manager.determine_kind_from_info(info).include? "lockfile" }.map(&:relative_path)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
data/lib/bibliothecary/runner.rb
CHANGED
|
@@ -42,6 +42,22 @@ module Bibliothecary
|
|
|
42
42
|
Bibliothecary::Parsers.constants.map{|c| Bibliothecary::Parsers.const_get(c) }.sort_by{|c| c.to_s.downcase }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def load_file_info_list_from_contents(file_path_contents_hash)
|
|
46
|
+
# Parses an array of format [{file_path: "", contents: ""},] to match
|
|
47
|
+
# on both filename matches, and one content_match patterns.
|
|
48
|
+
file_list = []
|
|
49
|
+
|
|
50
|
+
file_path_contents_hash.each do |file|
|
|
51
|
+
info = FileInfo.new(nil, file[:file_path], file[:contents])
|
|
52
|
+
|
|
53
|
+
next if ignored_files.include?(info.relative_path)
|
|
54
|
+
|
|
55
|
+
add_files_to_list(file_list, info)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
file_list
|
|
59
|
+
end
|
|
60
|
+
|
|
45
61
|
def load_file_info_list_from_paths(paths)
|
|
46
62
|
file_list = []
|
|
47
63
|
|
|
@@ -50,12 +66,7 @@ module Bibliothecary
|
|
|
50
66
|
|
|
51
67
|
next if ignored_files.include?(info.relative_path)
|
|
52
68
|
|
|
53
|
-
|
|
54
|
-
file = info.dup
|
|
55
|
-
file.package_manager = package_manager
|
|
56
|
-
|
|
57
|
-
file_list.push(file)
|
|
58
|
-
end
|
|
69
|
+
add_files_to_list(file_list, info)
|
|
59
70
|
end
|
|
60
71
|
|
|
61
72
|
file_list
|
|
@@ -71,12 +82,7 @@ module Bibliothecary
|
|
|
71
82
|
next unless FileTest.file?(subpath)
|
|
72
83
|
next if ignored_files.include?(info.relative_path)
|
|
73
84
|
|
|
74
|
-
|
|
75
|
-
file = info.dup
|
|
76
|
-
file.package_manager = package_manager
|
|
77
|
-
|
|
78
|
-
file_list.push(file)
|
|
79
|
-
end
|
|
85
|
+
add_files_to_list(file_list, info)
|
|
80
86
|
end
|
|
81
87
|
|
|
82
88
|
file_list
|
|
@@ -90,6 +96,10 @@ module Bibliothecary
|
|
|
90
96
|
RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_paths(paths).reject { |info| info.package_manager.nil? })
|
|
91
97
|
end
|
|
92
98
|
|
|
99
|
+
def find_manifests_from_contents(file_path_contents_hash)
|
|
100
|
+
RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_contents(file_path_contents_hash).reject { |info| info.package_manager.nil? })
|
|
101
|
+
end
|
|
102
|
+
|
|
93
103
|
def analyse_file(file_path, contents)
|
|
94
104
|
package_managers.select { |pm| pm.match?(file_path, contents) }.map do |pm|
|
|
95
105
|
pm.analyse_contents(file_path, contents)
|
|
@@ -124,5 +134,16 @@ module Bibliothecary
|
|
|
124
134
|
def ignored_files
|
|
125
135
|
@configuration.ignored_files
|
|
126
136
|
end
|
|
137
|
+
|
|
138
|
+
private
|
|
139
|
+
|
|
140
|
+
def add_files_to_list(file_list, info)
|
|
141
|
+
applicable_package_managers(info).each do |package_manager|
|
|
142
|
+
file = info.dup
|
|
143
|
+
file.package_manager = package_manager
|
|
144
|
+
|
|
145
|
+
file_list.push(file)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
127
148
|
end
|
|
128
149
|
end
|
data/lib/bibliothecary.rb
CHANGED
|
@@ -34,6 +34,10 @@ module Bibliothecary
|
|
|
34
34
|
runner.load_file_info_list_from_paths(paths)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def self.load_file_info_list_from_contents(file_path_contents_hash)
|
|
38
|
+
runner.load_file_info_list_from_contents(file_path_contents_hash)
|
|
39
|
+
end
|
|
40
|
+
|
|
37
41
|
def self.analyse_file(file_path, contents)
|
|
38
42
|
runner.analyse_file(file_path, contents)
|
|
39
43
|
end
|
|
@@ -54,6 +58,10 @@ module Bibliothecary
|
|
|
54
58
|
runner.find_manifests_from_paths(paths)
|
|
55
59
|
end
|
|
56
60
|
|
|
61
|
+
def self.find_manifests_from_contents(file_path_contents_hash)
|
|
62
|
+
runner.find_manifests_from_contents(file_path_contents_hash)
|
|
63
|
+
end
|
|
64
|
+
|
|
57
65
|
def self.ignored_dirs
|
|
58
66
|
configuration.ignored_dirs
|
|
59
67
|
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: 7.
|
|
4
|
+
version: 7.2.0
|
|
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-
|
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tomlrb
|