code-ruby 1.9.2 → 1.9.3

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: 3f549a94b79e05b4a9bcdaccb20f8aac62c12d0df2126be010cdd8837500b48c
4
- data.tar.gz: 96d615d2927a7f25c35151ceb3c574bcaad56f47e9e3a127363421840a467cc9
3
+ metadata.gz: 22952473dbe9b9dae4c19097315ed02cd5ffd54760b4769e9bb103d1460f0a56
4
+ data.tar.gz: 91bcb3130986a3fbee06a08f5c814121f4efbe54bb4a8c193e399befceb4a465
5
5
  SHA512:
6
- metadata.gz: ca729f38f8dbed018a444f541fa18630df17fc53c0638041279c308a7a7867fb1f22a1d7dfca279f120868e6fbb12cbf50651c4247e95d2c504ceb70353936d1
7
- data.tar.gz: 41d3ce239359a6df336152f4a4fada3e5526549abe7a27e2cb929ecb46cb4319f36a248395ccca258aadb3be0d5ff80c86c3f8749ece21cb776b59174870ff43
6
+ metadata.gz: 444ad49c72cc55a137333d7906955a750de131d32e81dd971e4627217618c3b4be318b4483ad30d266e217cb677c379ecbc3aa1abf410db843e3262a9e8cf644
7
+ data.tar.gz: 154153bc86d78b3f34e1bab45ba094fa1b481146f7e654a049a90311d7483dba7850e86934bc1598193199d163ed788fdc201dfa3fc54e97c4b2376188a0abab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (1.9.2)
4
+ code-ruby (1.9.3)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.2
1
+ 1.9.3
@@ -97,9 +97,11 @@ class Code
97
97
  sig(args)
98
98
  code_future?
99
99
  when "format"
100
- sig(args) { [String, { locale: String.maybe }] }
100
+ sig(args) { [String.maybe, { locale: String.maybe }] }
101
101
 
102
- if code_second.something?
102
+ if code_value.is_a?(Dictionary)
103
+ code_format(nil, locale: code_value.code_get(:locale))
104
+ elsif code_second.something?
103
105
  code_format(code_value, locale: code_second.code_get(:locale))
104
106
  else
105
107
  code_format(code_value)
@@ -414,9 +416,11 @@ class Code
414
416
  sig(args)
415
417
  code_sunday?
416
418
  when "format"
417
- sig(args) { [String, { locale: String.maybe }] }
419
+ sig(args) { [String.maybe, { locale: String.maybe }] }
418
420
 
419
- if code_second.something?
421
+ if code_value.is_a?(Dictionary)
422
+ code_format(nil, locale: code_value.code_get(:locale))
423
+ elsif code_second.something?
420
424
  code_format(code_value, locale: code_second.code_get(:locale))
421
425
  else
422
426
  code_format(code_value)
@@ -700,9 +704,11 @@ class Code
700
704
  code_format = format.to_code
701
705
  code_locale = locale.to_code
702
706
 
703
- locale = code_locale.raw.presence_in(LOCALES) || I18n.locale
707
+ requested_locale = code_locale.raw&.to_s
708
+ locale = requested_locale&.presence_in(LOCALES)&.to_sym || I18n.locale
709
+ locale = I18n.locale unless I18n.available_locales.include?(locale.to_sym)
704
710
 
705
- format = code_format.raw
711
+ format = code_format.raw || :default
706
712
  format = format.to_sym if I18n.exists?("date.formats.#{format}", locale)
707
713
 
708
714
  String.new(I18n.l(raw, format: format, locale: locale))
@@ -188,9 +188,11 @@ class Code
188
188
  sig(args)
189
189
  code_sunday?
190
190
  when "format"
191
- sig(args) { [String, { locale: String.maybe }] }
191
+ sig(args) { [String.maybe, { locale: String.maybe }] }
192
192
 
193
- if code_second.something?
193
+ if code_value.is_a?(Dictionary)
194
+ code_format(nil, locale: code_value.code_get(:locale))
195
+ elsif code_second.something?
194
196
  code_format(code_value, locale: code_second.code_get(:locale))
195
197
  else
196
198
  code_format(code_value)
@@ -463,9 +465,11 @@ class Code
463
465
  sig(args)
464
466
  code_sunday?
465
467
  when "format"
466
- sig(args) { [String, { locale: String.maybe }] }
468
+ sig(args) { [String.maybe, { locale: String.maybe }] }
467
469
 
468
- if code_second.something?
470
+ if code_value.is_a?(Dictionary)
471
+ code_format(nil, locale: code_value.code_get(:locale))
472
+ elsif code_second.something?
469
473
  code_format(code_value, locale: code_second.code_get(:locale))
470
474
  else
471
475
  code_format(code_value)
@@ -809,9 +813,11 @@ class Code
809
813
  code_format = format.to_code
810
814
  code_locale = locale.to_code
811
815
 
812
- locale = code_locale.raw.presence_in(LOCALES) || I18n.locale
816
+ requested_locale = code_locale.raw&.to_s
817
+ locale = requested_locale&.presence_in(LOCALES)&.to_sym || I18n.locale
818
+ locale = I18n.locale unless I18n.available_locales.include?(locale.to_sym)
813
819
 
814
- format = code_format.raw
820
+ format = code_format.raw || :default
815
821
  format = format.to_sym if I18n.exists?("time.formats.#{format}", locale)
816
822
 
817
823
  String.new(I18n.l(raw, format: format, locale: locale))
data/spec/code_spec.rb CHANGED
@@ -248,7 +248,9 @@ RSpec.describe Code do
248
248
  %w[Class.new(nothing) Nothing],
249
249
  %w[Class.new(true) Boolean],
250
250
  %w[Date Date],
251
+ ["Date.format == Date.format(:default)", "true"],
251
252
  %w[Date("0001-01-01").to_string :0001-01-01],
253
+ ["Date(\"2024-03-02\").format == Date(\"2024-03-02\").format(:default)", "true"],
252
254
  %w[Date("2024-03-02").to_string :2024-03-02],
253
255
  %w[Decimal(1) 1.0],
254
256
  %w[Decimal(1) 1],
@@ -296,6 +298,10 @@ RSpec.describe Code do
296
298
  ["Class.new(Time, Boolean)", "Time"],
297
299
  %w[Date("2024-3-2").to_string :2024-03-02],
298
300
  %w[Date("2024-3-2").to_string :2024-03-02],
301
+ ["Time.format.present?", "true"],
302
+ ["Class(Time.format(locale: :fr))", "String"],
303
+ ["Time.new(\"2024-03-05.06:10:59.UTC\").format(locale: :fr) == Time.new(\"2024-03-05.06:10:59.UTC\").format(:default, locale: :fr)", "true"],
304
+ ["Time.new(\"2024-03-05.06:10:59.UTC\").format == Time.new(\"2024-03-05.06:10:59.UTC\").format(:default)", "true"],
299
305
  ["Decimal(1, :2)", "100"],
300
306
  ["Decimal(:1, 2)", "100.0"],
301
307
  ["Decimal.new(1, :2)", "100"],
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.2
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié