sneakers-queue-migrator 0.1.4 → 0.1.5

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: 07b21432931960e830cbb956ab0e53406657147d9674f495ef74237f114e6fc3
4
+ data.tar.gz: aa60dd0d5714f56410240567c0a63da1fa937eefd6d3ad706bdb8a6b35cd2bdc
5
5
  SHA512:
6
- metadata.gz: 600d85156bacd65cd41005f58ee3d41f0343ca3aef7fd8c66556da258d0b8112b9fb6dc41c132b5abc41b3bf2369c1b3ac4db6185660c670e7463c2ca68768fd
7
- data.tar.gz: 4a3644e771e0f88f3ee15167e2db7c10ea486b31c84e30a963adf6d122754499fb61f11ffe5db4d29fa3b41fa330aca9b1d57f354959ebd378ee21c465bf4e39
6
+ metadata.gz: af7f10c370532ceb2f76d908bd86fc5d5743cb1c6b491de59ef2eb3fd6749b19ccd6da1a44368c398f51281ce6440e81abd3aa6fb5d3a2f7110de84d5507b99a
7
+ data.tar.gz: 772f61353f22feea63646cebe38eaf2c6f0c2864a0041b74f54a6eba88cbf01a2c569780b3ac379899c61b6d8137253187e1376f02bfeeac53bf0a707f9241af
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.5)
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.5"
6
6
  end
7
7
  end
@@ -13,10 +13,10 @@ module Sneakers
13
13
 
14
14
  class << self
15
15
  # Main migration entrypoint
16
- def migrate!(amqp_url:, amqp_api_url:, subscriber_paths: [], logger: nil, parse_only: false)
16
+ def migrate!(amqp_url:, amqp_api_url:, subscriber_paths: [], logger: nil, load_with_regex: false)
17
17
  logger ||= $stdout
18
18
  # Optionally parse subscribers with regex/static analysis
19
- queues = if parse_only
19
+ queues = if load_with_regex
20
20
  parse_queues_from_files(subscriber_paths, logger)
21
21
  else
22
22
  load_files_to_find_queues(subscriber_paths, logger)
@@ -102,9 +102,10 @@ module Sneakers
102
102
  # Multi-line robust extraction for from_queue calls
103
103
  src_lines = src.lines
104
104
  src_lines.each_with_index do |line, idx|
105
- next unless line =~ /from_queue\s+("|')([\w\-:]+)\1\s*,?\s*$/
105
+ # Match from_queue with or without parentheses, any quote style, and allow whitespace
106
+ next unless line =~ /from_queue\s*(\(|\s)+(['"])([^'"]+)\2\s*,?/
106
107
 
107
- queue_name = ::Regexp.last_match(2)
108
+ queue_name = ::Regexp.last_match(3)
108
109
  # Multi-line argument collection: collect all subsequent lines that are more indented than the from_queue line
109
110
  from_indent = line[/^\s*/].size
110
111
  opts_lines = []
@@ -147,6 +148,7 @@ module Sneakers
147
148
  queues << q
148
149
  seen[q[:name]] = true
149
150
  end
151
+ queues
150
152
  end
151
153
  end
152
154
  end
@@ -173,6 +175,11 @@ module Sneakers
173
175
 
174
176
  # Remove comments and excessive whitespace
175
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
182
+ end
176
183
  # Convert Ruby hashrockets and symbol keys to YAML style, and handle symbol values and numbers with underscores
177
184
  yaml_str = code
178
185
  .gsub(/:(\w+)\s*=>/, '"\\1":') # :foo =>
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Gane