code-ruby 1.9.9 → 1.9.10

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: 0f787d4f359dec1127a7029174900ad6b5c5846942d189ec1379e661fa403195
4
- data.tar.gz: 490d58386533fedab171549fc5dfbad22f406040f245c83ee85d84214bed8e69
3
+ metadata.gz: 5d0ceecc686aef6964768b675a3be83b75127a0b425bd452745ed06101d4cc2b
4
+ data.tar.gz: 5778826718ab6614081ad28e008cd885d2f1c4ddeb303d5fafa87a67befa63d8
5
5
  SHA512:
6
- metadata.gz: 1b06b4a5f6f2003c7c3ab49426ecb17aa2fb4191d2ba1ab573d8614b47d0231c349f7ac894b9f7d459e772c9197fba01d12c393c66da02274bd09b74d77c935d
7
- data.tar.gz: 94d7ccbc7ca7c782878cf275d5d2f65b1d7a061ce2fe4e2e82b30c8882f55bd5ad0f5fce318834659c55db0375dd80b0616269b1dc534449ad2ed227dcdaa064
6
+ metadata.gz: 531f8de970b16632012ea7cdb0836974d3333c24f506026e128ad317b02845fb5576c10529d833b8223cbc099366c9bddff96b794595939c7afdf7944b2c02f1
7
+ data.tar.gz: 4ca6148814db2b2e3dce20ccc122f96edbbec1cd1c217ae3700c089159df388b98dbde7e85e897045e136688f0ec9fb2520b02b88b913c7e7dc5a8ca80e359e9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (1.9.9)
4
+ code-ruby (1.9.10)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.9
1
+ 1.9.10
data/lib/code/format.rb CHANGED
@@ -394,6 +394,9 @@ class Code
394
394
  end
395
395
 
396
396
  def format_left_operation(operation, indent:)
397
+ merged_string = extract_string_concatenation_parts(left_operation: operation)
398
+ return format_string(merged_string, indent: indent) if merged_string
399
+
397
400
  expression = format_nested_statement(operation[:first], indent: indent)
398
401
 
399
402
  Array(operation[:others]).each do |other|
@@ -421,6 +424,33 @@ class Code
421
424
  expression
422
425
  end
423
426
 
427
+ def extract_string_concatenation_parts(statement)
428
+ return nil unless statement.is_a?(Hash)
429
+
430
+ if statement.key?(:string)
431
+ return Array(statement[:string])
432
+ end
433
+
434
+ return nil unless statement.key?(:left_operation)
435
+
436
+ operation = statement[:left_operation]
437
+ others = Array(operation[:others])
438
+ return nil if others.empty?
439
+ return nil unless others.all? { |other| other[:operator] == "+" }
440
+
441
+ parts = extract_string_concatenation_parts(operation[:first])
442
+ return nil unless parts
443
+
444
+ others.each do |other|
445
+ nested = extract_string_concatenation_parts(other[:statement])
446
+ return nil unless nested
447
+
448
+ parts.concat(nested)
449
+ end
450
+
451
+ parts
452
+ end
453
+
424
454
  def format_right_operation(operation, indent:)
425
455
  operator = operation[:operator].to_s
426
456
  left = format_nested_statement(operation[:left], indent: indent)
@@ -34,6 +34,10 @@ RSpec.describe Code::Format do
34
34
  [
35
35
  "proxy_url = (url) => { \"{proxy_base_url}?{{ url: url, disposition: proxy_inline_disposition }.to_query}\" }",
36
36
  "proxy_url = (url) => {\n \"{proxy_base_url}?\"\n + \"{{\n url: url,\n disposition: proxy_inline_disposition\n }.to_query}\"\n}"
37
+ ],
38
+ [
39
+ "x = { content: \"you select the funniest tweets for a french \" + \"audience from the provided candidates. pick up to \" + \"{max_selected}. prioritize genuinely funny content\" + \" (jokes, memes, punchlines, absurd). avoid \" + \"politics/news/serious content. output only json.\" }",
40
+ "x = {\n content: \"you select the funniest tweets for a french \"\n + \"audience from the provided candidates. pick up to \"\n + \"{max_selected}. prioritize genuinely funny content\"\n + \" (jokes, memes, punchlines, absurd). avoid \"\n + \"politics/news/serious content. output only json.\"\n}"
37
41
  ]
38
42
  ].each do |input, expected|
39
43
  it "formats #{input.inspect}" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.9
4
+ version: 1.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié