sixarm_ruby_to_id 1.0.6 → 1.0.7
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.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/sixarm_ruby_to_id/hash.rb +5 -3
- data/test/sixarm_ruby_to_id_test/hash_test.rb +19 -3
- data.tar.gz.sig +1 -2
- metadata +1 -1
- metadata.gz.sig +1 -2
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
@@ -8,10 +8,12 @@ class Hash
|
|
8
8
|
# #=> "2000-12-31"
|
9
9
|
#
|
10
10
|
def to_date_id
|
11
|
-
year = self["year"] || self[:year]
|
12
|
-
month = self["month"] || self[:month]
|
11
|
+
year = self["year"] || self[:year]
|
12
|
+
month = self["month"] || self[:month]
|
13
13
|
day = self["day"] || self[:day]
|
14
|
-
year &&
|
14
|
+
year && year!="" && month && month!="" && day && day!="" \
|
15
|
+
? sprintf("%4.4d-%2.2d-%2.2d", year.to_i, month.to_i, day.to_i) \
|
16
|
+
: nil
|
15
17
|
end
|
16
18
|
|
17
19
|
|
@@ -18,17 +18,33 @@ describe Hash do
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
+
describe "with fields for year, month, day any of which are blank strings #=> nil" do
|
22
|
+
|
23
|
+
it "year is blank #=> nil" do
|
24
|
+
{year: "", month: "12", day: "31"}.to_date_id.must_equal nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "month is blank #=> nil" do
|
28
|
+
{year: "2000", month: "", day: "31"}.to_date_id.must_equal nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "day is blank #=> nil" do
|
32
|
+
{year: "2000", month: "12", day: ""}.to_date_id.must_equal nil
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
21
37
|
describe "without fields for year, or month, or day #=> nil" do
|
22
38
|
|
23
|
-
it "
|
39
|
+
it "missing year #=> nil" do
|
24
40
|
{month: "12", day: "31"}.to_date_id.must_equal nil
|
25
41
|
end
|
26
42
|
|
27
|
-
it "
|
43
|
+
it "missing month #=> nil" do
|
28
44
|
{year: "2000", day: "31"}.to_date_id.must_equal nil
|
29
45
|
end
|
30
46
|
|
31
|
-
it "
|
47
|
+
it "missing day #=> nil" do
|
32
48
|
{year: "2000", month: "12"}.to_date_id.must_equal nil
|
33
49
|
end
|
34
50
|
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
j����p�n�{bL����\�V;)%
|
1
|
+
Ua�0$�����ԍ��>�2��R��Jl� ��+�m���ҲNa�.��S���!G�.fi�x?b��%Ea���Veֺ��@�6��z_8yN��ʐLL*+��5#����Ƃ�Ą�%��,�����@t�0
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
�
|
2
|
-
"���E����A����/���@������p�Xa�/lEon���p���`��U��lK�p��Au��W<��/|ԓ)$��fv�j
|
1
|
+
")�������&�5�8��"����溂�S�C�O��s3l��F� ��R�U�#Ft�w�^�����D���X���C�Ɛ%ʣԗ����:����住1;|��+�ݝ��gN'�6�"�/p2U�5Mt-
|