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 +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/object/date.rb +12 -6
- data/lib/code/object/time.rb +12 -6
- data/spec/code_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22952473dbe9b9dae4c19097315ed02cd5ffd54760b4769e9bb103d1460f0a56
|
|
4
|
+
data.tar.gz: 91bcb3130986a3fbee06a08f5c814121f4efbe54bb4a8c193e399befceb4a465
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 444ad49c72cc55a137333d7906955a750de131d32e81dd971e4627217618c3b4be318b4483ad30d266e217cb677c379ecbc3aa1abf410db843e3262a9e8cf644
|
|
7
|
+
data.tar.gz: 154153bc86d78b3f34e1bab45ba094fa1b481146f7e654a049a90311d7483dba7850e86934bc1598193199d163ed788fdc201dfa3fc54e97c4b2376188a0abab
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.9.
|
|
1
|
+
1.9.3
|
data/lib/code/object/date.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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))
|
data/lib/code/object/time.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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"],
|