gem_sorter 0.5.6 → 0.5.7
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/lib/gem_sorter/version.rb +1 -1
- data/lib/gem_sorter.rb +20 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 981a2ef59205d15bdb574b03a7f7d162e3d2a2319b2d81f19380deb8bc1b03ab
|
|
4
|
+
data.tar.gz: 0bd57414513bcb5d5d9ebb5578bc13d9cc1239d4816b3d5e0bdcb5d80baaff68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94f6b10e1b084a7521cc35ef3a7c0ed7516c4e7a298ea9f3077c40fab480b7e5454e656d5fc50f7d349bf682e17fb26dc85c60490aa72e4224e227d01ca5baea
|
|
7
|
+
data.tar.gz: 9b8b8b08728f9c987b7041d1e9b1053c6dfab936eb1553dd1674cc07e0ed11080aea410db656593372eaa8fa2a26b754118ff2589577f5a5cb31a26b13c2e8fb
|
data/lib/gem_sorter/version.rb
CHANGED
data/lib/gem_sorter.rb
CHANGED
|
@@ -308,10 +308,10 @@ module GemSorter
|
|
|
308
308
|
raise "Error: Could not fetch gem information from RubyGems for #{gem_name} version #{version}. Status: #{response.code}"
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
-
|
|
311
|
+
gemfile_text = extract_gemfile_text_from_html(response.body)
|
|
312
312
|
|
|
313
|
-
if
|
|
314
|
-
|
|
313
|
+
if gemfile_text
|
|
314
|
+
gemfile_text
|
|
315
315
|
else
|
|
316
316
|
raise "Error: Could not extract Gemfile text for #{gem_name} version #{version}."
|
|
317
317
|
end
|
|
@@ -323,6 +323,23 @@ module GemSorter
|
|
|
323
323
|
end
|
|
324
324
|
end
|
|
325
325
|
|
|
326
|
+
# Extracts the ready-to-paste Gemfile line from a RubyGems gem/version page.
|
|
327
|
+
#
|
|
328
|
+
# RubyGems renders it inside an <input id="gemfile_text"> element. The markup
|
|
329
|
+
# lists the attributes as `value="..." id="gemfile_text"` (value first), and
|
|
330
|
+
# the value itself may contain both single quotes and ">" characters, e.g.
|
|
331
|
+
# <input type="text" value="gem 'rails', '>= 8.0'" id="gemfile_text" ...>
|
|
332
|
+
# so the value is captured by its own surrounding quote character rather than
|
|
333
|
+
# by relying on tag boundaries or attribute order. A second pattern covers the
|
|
334
|
+
# reverse `id="gemfile_text" ... value="..."` ordering just in case.
|
|
335
|
+
def extract_gemfile_text_from_html(body)
|
|
336
|
+
match = body.match(/\svalue=(["'])(.*?)\1(?=[^>]*\bid=["']gemfile_text["'])/m) ||
|
|
337
|
+
body.match(/\bid=["']gemfile_text["'][^>]*?\svalue=(["'])(.*?)\1/m)
|
|
338
|
+
return nil unless match
|
|
339
|
+
|
|
340
|
+
CGI.unescapeHTML(match[2])
|
|
341
|
+
end
|
|
342
|
+
|
|
326
343
|
def fetch_versions_from_lockfile(lockfile_path)
|
|
327
344
|
return {} unless File.exist?(lockfile_path)
|
|
328
345
|
|