bibliothecary 7.1.2 → 7.2.0

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: 901e953500cd1880a638a6555c5dfc82dd8d8521be5b7bf85fc0d6dff981dfe0
4
- data.tar.gz: 2c1d2c23f53bdea2a91b418bdee9ecc0becb8cbb651f94b53f76b8974b0a765e
3
+ metadata.gz: ac170521ce85ef87c25442284632da0d641709136108e15f2b5b4e3050f9f56e
4
+ data.tar.gz: b97db15b605b8f39687c10b70dd46023ce2ebfb8a1d7b9076a5151b81f871c8b
5
5
  SHA512:
6
- metadata.gz: c1883bdfe4f28f284c4ef661f443b2e23830910368fbe63d8bf4e491e46278aaee12d8014c7181094933d7e3a6f33b6553318b016616ac27af00153ae763d65e
7
- data.tar.gz: 59c5d53bffaeeb8c59df649370ff85c91245d8d7c3762dc97e21dc2663f02a10bd4a65e5c6f8dbf90bc8e2782b7420d3521623bb343e8b44985f396b019649a6
6
+ metadata.gz: ac11fca807e0d45f9dff9984d180577853f238446112e9c65f8e298c26d26f100ad5b0071eba00d02bebbd7b84976aac497ec3cbf6c860839524730ef2945569
7
+ data.tar.gz: ac4fb797dc8a121e93b85a05dc087cd2ed01114da5fbec082b704c3ae9201e5727434bd731338175d46fc1ea56fbfb5b8935e0c2fd9aa829c5c9e686855520da
data/README.md CHANGED
@@ -81,6 +81,8 @@ All available config options are in: https://github.com/librariesio/bibliothecar
81
81
  - requirements/*.pip
82
82
  - Pipfile
83
83
  - Pipfile.lock
84
+ - pyproject.toml
85
+ - poetry.lock
84
86
  - Nuget
85
87
  - packages.config
86
88
  - Project.json
@@ -4,9 +4,14 @@ module Bibliothecary
4
4
  include Bibliothecary::Analyser
5
5
 
6
6
  INSTALL_REGEXP = /install_requires\s*=\s*\[([\s\S]*?)\]/
7
- REQUIRE_REGEXP = /([a-zA-Z0-9]+[a-zA-Z0-9\-_\.]+)([><=\w\.,]+)?/
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[2] || '*',
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[2] || '*',
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 { |info| File.basename(info.relative_path) }
26
- @lockfiles = file_infos.select { |info| package_manager.determine_kind_from_info(info).include? "lockfile" }.map { |info| File.basename(info.relative_path) }
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
@@ -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
- 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
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
- applicable_package_managers(info).each do |package_manager|
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
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "7.1.2"
2
+ VERSION = "7.2.0"
3
3
  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.1.2
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-09-23 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb