evc_rails 0.3.0 → 0.3.1

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: 1a155f85c540ca32801ef3033f92abdc7912a3ff5c533faa19f92b00c774968b
4
- data.tar.gz: 79de2d1b2b3557009c0d9e98f5ade01418ad7e49b61567c2056898ddfe537ea9
3
+ metadata.gz: cbedccd24baa2e896e5f5dc2f232b1a481ac3e5c9e82653f18d6d40d3b888f8d
4
+ data.tar.gz: 022e8e06c631aa3d6d52363377600a9b38870ffaa0506e1d5e732c0bf6859b73
5
5
  SHA512:
6
- metadata.gz: 1039a2e12cc8f11c8855dd0bafd2abd9de98e61a87f9e2c49fe27f7d40a497d30d6f1b05d4da7bfb8b7eede13b75c33ab67df4cb48fe8ab8de4d825284d52388
7
- data.tar.gz: c73e72e59cd863f513bf07e60675081c3db3255b77090da206ae8652a8e6c15f1b6079641fd1e27b5dbe0b95e71ae45d80a7975b0af2479b5d4e802b9b102a0d
6
+ metadata.gz: b0eca6627b253da66c7cc9d44730f0c7dff6306ae6040bae1ac08b294d59723f72d0a3ec2ffc67736de566b7e6567803e2f17c14590c17e0ec1952d96005309a
7
+ data.tar.gz: 0a1268f2b06d7027134d9277b2a48b1372e6483e6c8c08fdd0e2aed1b36f4bf81286edbce9b760a18435ff64f11f2e6fa06a5ba9008af22efe9f24e950daa104
@@ -283,17 +283,85 @@ module EvcRails
283
283
  end.strip
284
284
 
285
285
  params = []
286
- attributes_str.scan(attribute_regex) do |key, quoted_value, single_quoted_value, ruby_expression|
287
- params << if ruby_expression
288
- "#{key}: #{ruby_expression}"
289
- elsif quoted_value
290
- "#{key}: \"#{quoted_value.gsub('"', '\\"')}\""
291
- elsif single_quoted_value
292
- "#{key}: \"#{single_quoted_value.gsub("'", "\\'")}\""
293
- else
294
- # Standalone attribute (no value) - treat as boolean true
295
- "#{key}: true"
296
- end
286
+ str = attributes_str.dup
287
+ until str.nil? || str.empty?
288
+ str = "" if str.nil?
289
+ str.lstrip!
290
+ str = "" if str.nil?
291
+ break if str.empty?
292
+ # Match key
293
+ break unless str =~ /\A(\w+)/
294
+
295
+ key = ::Regexp.last_match(1)
296
+ str = str[::Regexp.last_match(0).length..-1]
297
+ str = "" if str.nil?
298
+ str.lstrip!
299
+ str = "" if str.nil?
300
+ if str.start_with?("=")
301
+ str = str[1..-1]
302
+ str = "" if str.nil?
303
+ str.lstrip!
304
+ str = "" if str.nil?
305
+ if str.start_with?("{")
306
+ # Parse balanced curly braces
307
+ depth = 0
308
+ i = 0
309
+ found = false
310
+ while true
311
+ str = "" if str.nil?
312
+ break if str.empty? || i >= str.length
313
+
314
+ c = str[i]
315
+ if c == "{"
316
+ depth += 1
317
+ elsif c == "}"
318
+ depth -= 1
319
+ if depth == 0
320
+ found = true
321
+ break
322
+ end
323
+ end
324
+ i += 1
325
+ end
326
+ if found
327
+ ruby_expr = str[1...i] # skip opening '{', up to before closing '}'
328
+ str = str[(i + 1)..-1]
329
+ str = "" if str.nil?
330
+ params << "#{key}: #{ruby_expr}"
331
+ else
332
+ # Unbalanced braces, treat as error or fallback
333
+ params << "#{key}: true"
334
+ str = ""
335
+ end
336
+ elsif str.start_with?("\"")
337
+ # Double-quoted string
338
+ if str =~ /\A"([^"]*)"/
339
+ str = str[::Regexp.last_match(0).length..-1]
340
+ str = "" if str.nil?
341
+ params << "#{key}: \"#{::Regexp.last_match(1).gsub('"', '\\"')}\""
342
+ else
343
+ params << "#{key}: true"
344
+ str = ""
345
+ end
346
+ elsif str.start_with?("'")
347
+ # Single-quoted string
348
+ if str =~ /\A'([^']*)'/
349
+ str = str[::Regexp.last_match(0).length..-1]
350
+ str = "" if str.nil?
351
+ params << "#{key}: \"#{::Regexp.last_match(1).gsub("'", "\\'")}\""
352
+ else
353
+ params << "#{key}: true"
354
+ str = ""
355
+ end
356
+ else
357
+ # Unquoted value or malformed, treat as boolean true
358
+ params << "#{key}: true"
359
+ str = ""
360
+ end
361
+ else
362
+ # Standalone attribute (no value) - treat as boolean true
363
+ params << "#{key}: true"
364
+ end
297
365
  end
298
366
  [params, as_variable]
299
367
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvcRails
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evc_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - scttymn