bibliothecary 7.1.3 → 7.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 363f07f35de59f9e70b69e78e25c47a16eaaeb88399db593af9fa8907f9057b4
4
- data.tar.gz: e960f21a1d5df9dbe686efce3dd0968e08b60f24b20767fc861a344704e9f3f9
3
+ metadata.gz: ba740dd30abb75fb073f3160d963a970ffa41099966e86a38558fc50c515c9bf
4
+ data.tar.gz: 19de22f64f4390acd0c15781283d1089c85459aa989393485ab25337e246ef01
5
5
  SHA512:
6
- metadata.gz: c4758b79d123881d8ead04bc325f2121388e216edffebfceadd2dae1183d8cb04999b205055d29a3b509ffee640e534dce9701a71fb97812d573a3bee0357297
7
- data.tar.gz: 753f4495fb06a20dd2e77a41520c9db05b44442f94b261df5c2871454110636ca58efb22ccfecfb1922da8f5510e0edd6e3d5ec9384cf48494325c7489c90757
6
+ metadata.gz: 9f7f301227e79af9a7f3bafc5484e39426c9d5faee1ee1c6a97f4173d6b438def08cf36ea3a8eedaa06d9ce0741ee6bf012b7aba1a972680c79b397ac57a1ac9
7
+ data.tar.gz: 11bbaf66d5dcb32b042923abf85be353d96a6d1f09c1e641e0c40df215d9f70347e56b4d7afe81b5bb27a685318667c7c53d2ba24a2961e2a4dad72ad1c90273
data/README.md CHANGED
@@ -53,8 +53,6 @@ All available config options are in: https://github.com/librariesio/bibliothecar
53
53
 
54
54
  ## Supported package manager file formats
55
55
 
56
- - Hackage
57
- - \*.cabal
58
56
  - npm
59
57
  - package.json
60
58
  - package-lock.json
@@ -81,6 +79,8 @@ All available config options are in: https://github.com/librariesio/bibliothecar
81
79
  - requirements/*.pip
82
80
  - Pipfile
83
81
  - Pipfile.lock
82
+ - pyproject.toml
83
+ - poetry.lock
84
84
  - Nuget
85
85
  - packages.config
86
86
  - Project.json
@@ -149,7 +149,7 @@ All available config options are in: https://github.com/librariesio/bibliothecar
149
149
  - Haxelib
150
150
  - haxelib.json
151
151
  - Hackage
152
- - *.cabal
152
+ - \*.cabal
153
153
  - cabal.config
154
154
 
155
155
  ## Development
@@ -4,7 +4,12 @@ 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
14
  MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip|in)$/
10
15
  PIP_COMPILE_REGEXP = /.*require.*$/
@@ -21,6 +26,10 @@ module Bibliothecary
21
26
  parser: :parse_requirements_txt,
22
27
  can_have_lockfile: false
23
28
  },
29
+ match_filename('requirements.frozen') => { # pattern exists to store frozen deps in requirements.frozen
30
+ parser: :parse_requirements_txt,
31
+ kind: 'lockfile',
32
+ },
24
33
  match_filename('pip-resolved-dependencies.txt') => { # Inferred from pip
25
34
  kind: 'lockfile',
26
35
  parser: :parse_requirements_txt,
@@ -160,7 +169,7 @@ module Bibliothecary
160
169
  next unless match
161
170
  deps << {
162
171
  name: match[1],
163
- requirement: match[2] || '*',
172
+ requirement: match[-1] || '*',
164
173
  type: 'runtime'
165
174
  }
166
175
  end
@@ -174,7 +183,7 @@ module Bibliothecary
174
183
  next unless match
175
184
  deps << {
176
185
  name: match[1],
177
- requirement: match[2] || '*',
186
+ requirement: match[-1] || '*',
178
187
  type: 'runtime'
179
188
  }
180
189
  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.3"
2
+ VERSION = "7.2.1"
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.3
4
+ version: 7.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
- description:
209
+ description:
210
210
  email:
211
211
  - andrewnez@gmail.com
212
212
  executables:
@@ -274,7 +274,7 @@ homepage: https://github.com/librariesio/bibliothecary
274
274
  licenses:
275
275
  - AGPL-3.0
276
276
  metadata: {}
277
- post_install_message:
277
+ post_install_message:
278
278
  rdoc_options: []
279
279
  require_paths:
280
280
  - lib
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  requirements: []
292
292
  rubygems_version: 3.1.2
293
- signing_key:
293
+ signing_key:
294
294
  specification_version: 4
295
295
  summary: Find and parse manifests
296
296
  test_files: []