sneakers-queue-migrator 0.1.6 → 0.1.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/Gemfile.lock +1 -1
- data/lib/sneakers/migrator/version.rb +1 -1
- data/lib/sneakers/migrator.rb +9 -7
- 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: 3f6310a0f4c1fd3d40da61e88ac1ff46b49be61a4aeede428ca17e51e4ac8478
|
4
|
+
data.tar.gz: de28bac5ed191aa132fb76571ce7cb1467830fbb633d86147e7ab3847c20fda2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e08dc7579b5340f53b5b15746d0b2eacde7bb6cba5a75e2700666fdfae67cdeeb14de16a724dfdb7d4683b8736149ad5b5b4139308797fa4613bf355a21e3d
|
7
|
+
data.tar.gz: a754909ef4389c038a081884a24ca9dde93d2804c8be7a0862bf297ffb8da7e0abf16bf111187afc77ab2c7295f3c7570d3077ea75f19440309b5b180ae7f071
|
data/Gemfile.lock
CHANGED
data/lib/sneakers/migrator.rb
CHANGED
@@ -174,14 +174,16 @@ module Sneakers
|
|
174
174
|
def parse_options_hash_for_file(str)
|
175
175
|
return {} unless str
|
176
176
|
|
177
|
-
#
|
178
|
-
code = str.gsub(
|
179
|
-
|
180
|
-
|
181
|
-
code = code.gsub(/%[wi][\[(](.*?)[\])]/) do
|
182
|
-
words = ::Regexp.last_match(1).strip.split(/\s+/)
|
183
|
-
"[" + words.map { |w| "\"#{w}\"" }.join(", ") + "]" # rubocop:disable Style/StringConcatenation
|
177
|
+
# First, convert all %w[...] and %i[...] (even multi-line) to YAML arrays
|
178
|
+
code = str.gsub(/%[wi][\[(]((?:.|\n)*?)[\])]/m) do
|
179
|
+
words = ::Regexp.last_match(1).gsub(/#.*$/, '').split(/\s+/).reject(&:empty?)
|
180
|
+
'[' + words.map { |w| '"' + w + '"' }.join(', ') + ']'
|
184
181
|
end
|
182
|
+
# Remove comments and blank lines
|
183
|
+
code = code.lines.reject { |l| l.strip.start_with?("#") || l.strip.empty? }.join(" ")
|
184
|
+
# Remove handler: ... and backoff_function: ... (ignore these keys and their values)
|
185
|
+
code = code.gsub(/\bhandler:\s*[^,}]+,?/, "")
|
186
|
+
code = code.gsub(/\bbackoff_function:\s*->\s*\([^)]*\)\s*\{[^}]*\},?/, "")
|
185
187
|
# Convert Ruby hashrockets and symbol keys to YAML style, and handle symbol values and numbers with underscores
|
186
188
|
yaml_str = code
|
187
189
|
.gsub(/:(\w+)\s*=>/, '"\\1":') # :foo =>
|