sixarm_ruby_to_id 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -66,7 +66,7 @@ Cast a hash of year, month, day to a date id YYYY-MM-DD:
66
66
 
67
67
  ## Changes
68
68
 
69
- * 2012-08-21 1.0.6 Add Hash#to_date_id
69
+ * 2012-08-21 1.0.7 Add Hash#to_date_id
70
70
  * 2012-08-11 1.0.0 Publish
71
71
 
72
72
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.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 && month && day ? sprintf("%4.4d-%2.2d-%2.2d", year.to_i, month.to_i, day.to_i) : nil
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 "returns nil if it doesn't have a year" do
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 "returns nil if it doesn't have a month" do
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 "returns nil if it doesn't have a day" do
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
- �ߍ`-Nܤ�6���� ��LY���p;~��fFw_d U��o���]����/֙)XS_) ^g
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_to_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
metadata.gz.sig CHANGED
@@ -1,2 +1 @@
1
- 4@�� ��G{���gG���V�@�Y�.� /
2
- "���E����A����/���@������p�Xa�/lEon���p���`��U��lK�p��Au��W<��/|ԓ)$��fv�j
1
+ ")�������&�58��"����溂�SC�O��s3l��F� ��R�U�#Ft�w�^�����D���X���C�Ɛ%ʣԗ ����:����住1;|��+�ݝ��gN'�6 �"�/ p2U�5Mt-