bibliothecary 8.2.3 → 8.2.4

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: 6bf3193b6daf685565ca3fe2105ca8be8e03c5e83d1edcafe3ca6d3c7be12d8b
4
- data.tar.gz: c2b96281c11a89bf49f830bbb0be00e35d18096dcc8a8e8b2d0038e1256a6eed
3
+ metadata.gz: 631a4574650b4e69a1aec283acf4c0d1fb8338a1c4b767500b3b613c51357d7c
4
+ data.tar.gz: 1f280d94aacce63d88302f767561d9e9f05e8d3381cd4a618cff5f04cc73511f
5
5
  SHA512:
6
- metadata.gz: d3d45d37ac4c8e3c982d708f454906ab41db86fc285ba800d90acb6d2e541ae7151e7d09c5ae10eccec2678760b24f2bbb3d5c2e77048b714aa71c953395ce70
7
- data.tar.gz: b86748a552b1774895cad46925205a7c4915907d336436c945a7dc027d80e8feff7d12465c9524ea12a3495d4635e45c4cd32489456453b4c744a22fdf7c5c32
6
+ metadata.gz: d5e68b0a9fe18880ce752f45e66ba68a31834ce35356e025f892eadb409c613c3d3d57b19fedb65362e0977393757c8a0d7fa521f5e8c3ebbe90dd1aa96b1f86
7
+ data.tar.gz: 0ce08bdc863f9e82ed831d99b6132c043d6da012c297f81f5a0a801e847143b5a60a4545d2ce177a1deeaa7e62ed3a50010268b396d34c3f9794d04dccfbd365
@@ -179,20 +179,55 @@ module Bibliothecary
179
179
  deps
180
180
  end
181
181
 
182
+ # While the thing in the repo that PyPI is using might be either in
183
+ # egg format or wheel format, PyPI uses "egg" in the fragment of the
184
+ # VCS URL to specify what package in the PyPI index the VCS URL
185
+ # should be treated as.
186
+ NoEggSpecified = Class.new(ArgumentError)
187
+
188
+ # Parses a requirements.txt file, following the
189
+ # https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers
190
+ # and https://pip.pypa.io/en/stable/topics/vcs-support/#git.
191
+ # Invalid lines in requirements.txt are skipped.
182
192
  def self.parse_requirements_txt(file_contents, options: {})
183
193
  deps = []
184
194
  file_contents.split("\n").each do |line|
185
- match = line.delete(' ').match(REQUIREMENTS_REGEXP)
186
- next unless match
187
- deps << {
188
- name: match[1],
189
- requirement: match[-1] || '*',
190
- type: 'runtime'
191
- }
195
+ if line['://']
196
+ begin
197
+ result = parse_requirements_txt_url(line)
198
+ rescue URI::Error, NoEggSpecified => e
199
+ next
200
+ end
201
+
202
+ deps << result.merge(
203
+ type: 'runtime'
204
+ )
205
+ else
206
+ match = line.delete(' ').match(REQUIREMENTS_REGEXP)
207
+ next unless match
208
+
209
+ deps << {
210
+ name: match[1],
211
+ requirement: match[-1] || '*',
212
+ type: 'runtime'
213
+ }
214
+ end
192
215
  end
193
216
  deps
194
217
  end
195
218
 
219
+ def self.parse_requirements_txt_url(url)
220
+ uri = URI.parse(url)
221
+ raise NoEggSpecified, "No egg specified in #{url}" unless uri.fragment
222
+
223
+ name = uri.fragment[/^egg=([^&]+)([&]|$)/, 1]
224
+ raise NoEggSpecified, "No egg specified in #{url}" unless name
225
+
226
+ requirement = uri.path[/@(.+)$/, 1]
227
+
228
+ { name: name, requirement: requirement || "*" }
229
+ end
230
+
196
231
  def self.pip_compile?(file_contents)
197
232
  return file_contents.include?("This file is autogenerated by pip-compile")
198
233
  rescue Exception # rubocop:disable Lint/RescueException
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.2.3"
2
+ VERSION = "8.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.3
4
+ version: 8.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt