sneakers-queue-migrator 0.1.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07b21432931960e830cbb956ab0e53406657147d9674f495ef74237f114e6fc3
4
- data.tar.gz: aa60dd0d5714f56410240567c0a63da1fa937eefd6d3ad706bdb8a6b35cd2bdc
3
+ metadata.gz: 3f6310a0f4c1fd3d40da61e88ac1ff46b49be61a4aeede428ca17e51e4ac8478
4
+ data.tar.gz: de28bac5ed191aa132fb76571ce7cb1467830fbb633d86147e7ab3847c20fda2
5
5
  SHA512:
6
- metadata.gz: af7f10c370532ceb2f76d908bd86fc5d5743cb1c6b491de59ef2eb3fd6749b19ccd6da1a44368c398f51281ce6440e81abd3aa6fb5d3a2f7110de84d5507b99a
7
- data.tar.gz: 772f61353f22feea63646cebe38eaf2c6f0c2864a0041b74f54a6eba88cbf01a2c569780b3ac379899c61b6d8137253187e1376f02bfeeac53bf0a707f9241af
6
+ metadata.gz: e3e08dc7579b5340f53b5b15746d0b2eacde7bb6cba5a75e2700666fdfae67cdeeb14de16a724dfdb7d4683b8736149ad5b5b4139308797fa4613bf355a21e3d
7
+ data.tar.gz: a754909ef4389c038a081884a24ca9dde93d2804c8be7a0862bf297ffb8da7e0abf16bf111187afc77ab2c7295f3c7570d3077ea75f19440309b5b180ae7f071
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sneakers-queue-migrator (0.1.5)
4
+ sneakers-queue-migrator (0.1.7)
5
5
  bunny (~> 2.0)
6
6
  json (~> 2.0)
7
7
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sneakers
4
4
  module Migrator
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.7"
6
6
  end
7
7
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Style/StringConcatenation
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative "migrator/version"
@@ -173,13 +174,16 @@ module Sneakers
173
174
  def parse_options_hash_for_file(str)
174
175
  return {} unless str
175
176
 
176
- # Remove comments and excessive whitespace
177
- code = str.gsub(/#.*$/, "").gsub(/\n/, " ").gsub(/\s+/, " ")
178
- # Convert Ruby %w[ ... ] and %w( ... ) to array syntax for YAML
179
- code = code.gsub(/%w[\[(](.*?)[\])]/) do
180
- words = ::Regexp.last_match(1).strip.split(/\s+/)
181
- "[" + 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(', ') + ']'
182
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*\{[^}]*\},?/, "")
183
187
  # Convert Ruby hashrockets and symbol keys to YAML style, and handle symbol values and numbers with underscores
184
188
  yaml_str = code
185
189
  .gsub(/:(\w+)\s*=>/, '"\\1":') # :foo =>
@@ -424,3 +428,5 @@ module Sneakers
424
428
  end
425
429
  end
426
430
  end
431
+
432
+ # rubocop:enable Style/StringConcatenation
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sneakers-queue-migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Gane