sixarm_ruby_to_id 1.0.7 → 1.0.8

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 CHANGED
@@ -65,7 +65,8 @@ Cast a hash of year, month, day to a date id YYYY-MM-DD:
65
65
 
66
66
 
67
67
  ## Changes
68
-
68
+
69
+ * 2012-09-21 1.0.8 Change stint format to use range dots like "x..y"
69
70
  * 2012-08-21 1.0.7 Add Hash#to_date_id
70
71
  * 2012-08-11 1.0.0 Publish
71
72
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.8
@@ -25,12 +25,25 @@ class String
25
25
 
26
26
  # Cast me to a stint id.
27
27
  #
28
- # " 2000-12-30-2000-12-31".to_stint_id
28
+ # The string is two ISO dates in YYYY-MM-DD.
29
+ #
30
+ # The separator is either:
31
+ #
32
+ # * two dots ".." to include the stop date
33
+ #
34
+ # * three dots "..." to exclude the stop date.
35
+ #
36
+ # Examples:
37
+ #
38
+ # " 2000-12-30..2000-12-31".to_stint_id
39
+ # #=> "2000-12-30-2000-12-31"
40
+ #
41
+ # " 2000-12-30...2000-12-31".to_stint_id
29
42
  # #=> "2000-12-30-2000-12-31"
30
43
  #
31
44
  def to_stint_id
32
45
  s = self.strip
33
- s =~ /\A\d\d\d\d-\d\d-\d\d-\d\d\d\d-\d\d-\d\d\z/ ? s : nil
46
+ s =~ /\A\d\d\d\d-\d\d-\d\d\.\.\.?\d\d\d\d-\d\d-\d\d\z/ ? s : nil
34
47
  end
35
48
 
36
49
 
@@ -13,8 +13,8 @@ describe Array do
13
13
 
14
14
  describe "#to_stint_ids" do
15
15
  it "casts the items to stint ids" do
16
- [" 2000-12-30-2000-12-31 ", " 2001-12-30-2001-12-31 ", " 2002-12-30-2002-12-31 "].to_stint_ids.must_equal ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31"]
17
- [" X000-12-30-2000-12-31 ", " Y001-12-30-2001-12-31 ", " Z002-12-30-2002-12-31 "].to_stint_ids.must_equal [nil, nil, nil]
16
+ [" 2000-12-30..2000-12-31 ", " 2001-12-30..2001-12-31 ", " 2002-12-30..2002-12-31 "].to_stint_ids.must_equal ["2000-12-30..2000-12-31", "2001-12-30..2001-12-31", "2002-12-30..2002-12-31"]
17
+ [" A000-12-30..2000-12-31 ", " B001-12-30..2001-12-31 ", " C002-12-30..2002-12-31 "].to_stint_ids.must_equal [nil, nil, nil]
18
18
  end
19
19
  end
20
20
 
@@ -20,15 +20,17 @@ describe String do
20
20
 
21
21
  describe "#to_stint_id" do
22
22
  it "casts me to a stint id [YYYY-MM-DD, YYYY-MM-DD]" do
23
- " 2000-12-30-2000-12-31 ".to_stint_id.must_equal "2000-12-30-2000-12-31"
24
- " X000-12-30-2000-12-31 ".to_stint_id.must_equal nil
23
+ " 2000-12-30..2000-12-31 ".to_stint_id.must_equal "2000-12-30..2000-12-31"
24
+ " 2000-12-30...2000-12-31 ".to_stint_id.must_equal "2000-12-30...2000-12-31"
25
+ " 2000-12-30-2000-12-31 ".to_stint_id.must_equal nil
26
+ " 2000-12-30 2000-12-31 ".to_stint_id.must_equal nil
25
27
  end
26
28
  end
27
29
 
28
30
  describe "#to_stint_ids" do
29
31
  it "casts me to a list of stint ids" do
30
- " 2000-12-30-2000-12-31 , 2001-12-30-2001-12-31 , 2002-12-30-2002-12-31 ".to_stint_ids.must_equal ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31"]
31
- " X000-12-30-2000-12-31 , Y001-12-30-2001-12-31 , Z002-12-30-2002-12-31 ".to_stint_ids.must_equal [nil, nil, nil]
32
+ " 2000-12-30..2000-12-31 , 2001-12-30..2001-12-31 , 2002-12-30..2002-12-31 ".to_stint_ids.must_equal ["2000-12-30..2000-12-31", "2001-12-30..2001-12-31", "2002-12-30..2002-12-31"]
33
+ " A000-12-30..2000-12-31 , B001-12-30..2001-12-31 , C002-12-30..2002-12-31 ".to_stint_ids.must_equal [nil, nil, nil]
32
34
  end
33
35
  end
34
36
 
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- Ua0$�����ԍ��>�2��R��Jl� ��+�m���ҲNa�.��S���!G�.fi�x?b��%Ea���Veֺ��@�6��z_8yN��ʐLL*+��5#����Ƃ�Ą�%��,�����@t0
1
+ ��;�4Ƿ�9�n���RE:W$,��J�Ѭ��ʋ+l"��ח��g���[��u+ }`TT:X#>�Y��"z��������
2
+ K=�8���8�v)б KFu
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.7
4
+ version: 1.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -35,7 +35,7 @@ cert_chain:
35
35
  L2RORkllUkVIekVSClpEUlFZTXFydTlURU1uYTZIRDl6cGNzdEY3dndUaEdv
36
36
  dmxPUSszWTZwbFE0bk16aXBYY1o5VEhxczY1UElMMHEKZWFid3BDYkFvcG89
37
37
  Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
38
- date: 2012-08-22 00:00:00.000000000 Z
38
+ date: 2012-09-22 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email: sixarm@sixarm.com
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- ")�������&�5�8��"����溂�SC�O��s3l��F� ��R�U�#Ftw�^�����D���X���C�Ɛ%ʣԗ ����:����住1;|��+�ݝ��gN'�6 �"�/ p2U�5Mt-
1
+ Z(��yTbs�>�|��4j��Rb�k aBH��Ul�=�hۏ��S��b/\��Ce+�ZAgV!���|�1����s<�}Oc��6�,��+ �\�#