sneakers-queue-migrator 0.1.4 → 0.1.6

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: aa500b657d410fd1686b993cdeea8c99b415b8cf502c66b4f29cca6aa9104554
4
- data.tar.gz: b46319b9ff9a6b1821aaf63b5895e98df85e1be4b980f8f25a320ceacdb9a003
3
+ metadata.gz: 5828ad577fd278f6a7aea2c664dc830f16d223718123ff1c777277a1ae3aa1fa
4
+ data.tar.gz: 33679288215dca825e5f16af92ddf95877e9f0655a2a8e1a73b702ec5f3a3d55
5
5
  SHA512:
6
- metadata.gz: 600d85156bacd65cd41005f58ee3d41f0343ca3aef7fd8c66556da258d0b8112b9fb6dc41c132b5abc41b3bf2369c1b3ac4db6185660c670e7463c2ca68768fd
7
- data.tar.gz: 4a3644e771e0f88f3ee15167e2db7c10ea486b31c84e30a963adf6d122754499fb61f11ffe5db4d29fa3b41fa330aca9b1d57f354959ebd378ee21c465bf4e39
6
+ metadata.gz: bfa2182dd468ce08ee611300fb92c1d7f1541bcf2db0e5214b1b1fd47e0a9d36ccec11998800dd9b8a6abdcacb3e247d49a664f173156669747ae8fdf735d203
7
+ data.tar.gz: cccfd10de6106480a89fbe6ca70351e0ead63e0ca2ec593ad8e3aeecb51ff64a25b0b6896c331a433fb6efeeb0ae73325cd933a23c665281f184ef61439d8246
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sneakers-queue-migrator (0.1.4)
4
+ sneakers-queue-migrator (0.1.6)
5
5
  bunny (~> 2.0)
6
6
  json (~> 2.0)
7
7
 
data/README.md CHANGED
@@ -36,14 +36,14 @@ Sneakers::Migrator.migrate!(
36
36
  amqp_url: 'amqp://user:password@rabbitmq:5672/',
37
37
  amqp_api_url: 'http://user:password@rabbitmq:15672',
38
38
  subscriber_paths: ['app/workers'],
39
- parse_only: false
39
+ load_with_regex: false
40
40
  )
41
41
  ```
42
42
 
43
43
  `amqp_url` - regular bunny connection string
44
44
  `amqp_api_url` - url WITH PORT for the management interface
45
45
  `subscriber_paths` - array of folders to scan for subscribers
46
- `parse_only` - `false` requires the files and reflects the arguments, `true` parses the from_queue block with regex
46
+ `load_with_regex` - `false` requires the files and reflects the arguments, `true` parses the from_queue block with regex
47
47
 
48
48
  ## Development
49
49
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sneakers
4
4
  module Migrator
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.6"
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"
@@ -13,10 +14,10 @@ module Sneakers
13
14
 
14
15
  class << self
15
16
  # Main migration entrypoint
16
- def migrate!(amqp_url:, amqp_api_url:, subscriber_paths: [], logger: nil, parse_only: false)
17
+ def migrate!(amqp_url:, amqp_api_url:, subscriber_paths: [], logger: nil, load_with_regex: false)
17
18
  logger ||= $stdout
18
19
  # Optionally parse subscribers with regex/static analysis
19
- queues = if parse_only
20
+ queues = if load_with_regex
20
21
  parse_queues_from_files(subscriber_paths, logger)
21
22
  else
22
23
  load_files_to_find_queues(subscriber_paths, logger)
@@ -102,9 +103,10 @@ module Sneakers
102
103
  # Multi-line robust extraction for from_queue calls
103
104
  src_lines = src.lines
104
105
  src_lines.each_with_index do |line, idx|
105
- next unless line =~ /from_queue\s+("|')([\w\-:]+)\1\s*,?\s*$/
106
+ # Match from_queue with or without parentheses, any quote style, and allow whitespace
107
+ next unless line =~ /from_queue\s*(\(|\s)+(['"])([^'"]+)\2\s*,?/
106
108
 
107
- queue_name = ::Regexp.last_match(2)
109
+ queue_name = ::Regexp.last_match(3)
108
110
  # Multi-line argument collection: collect all subsequent lines that are more indented than the from_queue line
109
111
  from_indent = line[/^\s*/].size
110
112
  opts_lines = []
@@ -147,6 +149,7 @@ module Sneakers
147
149
  queues << q
148
150
  seen[q[:name]] = true
149
151
  end
152
+ queues
150
153
  end
151
154
  end
152
155
  end
@@ -173,6 +176,12 @@ module Sneakers
173
176
 
174
177
  # Remove comments and excessive whitespace
175
178
  code = str.gsub(/#.*$/, "").gsub(/\n/, " ").gsub(/\s+/, " ")
179
+ # Convert Ruby %w[ ... ] and %w( ... ) to array syntax for YAML
180
+ # Also handle %i[ ... ] for symbol arrays
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
184
+ end
176
185
  # Convert Ruby hashrockets and symbol keys to YAML style, and handle symbol values and numbers with underscores
177
186
  yaml_str = code
178
187
  .gsub(/:(\w+)\s*=>/, '"\\1":') # :foo =>
@@ -417,3 +426,5 @@ module Sneakers
417
426
  end
418
427
  end
419
428
  end
429
+
430
+ # 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.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Gane