sixarm_ruby_to_id 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.md +6 -0
- data/CONTRIBUTING.md +28 -0
- data/LICENSE.md +28 -0
- data/README.md +6 -40
- data/Rakefile +8 -2
- data/VERSION +1 -1
- data/lib/sixarm_ruby_to_id.rb +0 -3
- data/lib/sixarm_ruby_to_id/array.rb +10 -12
- data/lib/sixarm_ruby_to_id/date.rb +14 -3
- data/lib/sixarm_ruby_to_id/hash.rb +6 -4
- data/lib/sixarm_ruby_to_id/nil.rb +4 -10
- data/lib/sixarm_ruby_to_id/numeric.rb +12 -1
- data/lib/sixarm_ruby_to_id/object.rb +23 -2
- data/lib/sixarm_ruby_to_id/string.rb +4 -10
- data/test/sixarm_ruby_to_id_test.rb +2 -2
- data/test/sixarm_ruby_to_id_test/array_test.rb +5 -2
- data/test/sixarm_ruby_to_id_test/date_test.rb +11 -3
- data/test/sixarm_ruby_to_id_test/hash_test.rb +9 -8
- data/test/sixarm_ruby_to_id_test/nil_test.rb +5 -2
- data/test/sixarm_ruby_to_id_test/numeric_test.rb +5 -2
- data/test/sixarm_ruby_to_id_test/object_test.rb +14 -5
- data/test/sixarm_ruby_to_id_test/string_test.rb +6 -5
- metadata +137 -41
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f767a489b1dd0865beb06885c80b95f1d363aaa2
|
4
|
+
data.tar.gz: 2c2acff7f9ee5b80e42826000ab44d81f0d0a616
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b800bc3090a46b3f2c56950e21ce2b0589669e320f836003f9704c4a0fdda3846bad13102f047c1ca7bda6c6c4649ea1fb617ad2230e2ad6705df6bec6882cd6
|
7
|
+
data.tar.gz: b1b399f43e22c1d7d07a9a4d350a678658a90293aa8fef49f204b53a2bdce4491c26064af8923ceafed98f4568ba38bef0dd7e8d9942359e73df53e4af35e274
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Thank you for contributing!
|
4
|
+
|
5
|
+
If you would like to contribute a donation, an easy way is to use PayPal to sixarm@sixarm.com.
|
6
|
+
|
7
|
+
If you would like to contribute help, the next section is for you.
|
8
|
+
|
9
|
+
|
10
|
+
## Contributing to the source
|
11
|
+
|
12
|
+
We love pull requests for improvments to the source code and documentation.
|
13
|
+
|
14
|
+
There are three easy steps:
|
15
|
+
|
16
|
+
1. Fork the repo.
|
17
|
+
|
18
|
+
* Before you do any work please run our existing tests to make sure the code runs cleanly.
|
19
|
+
|
20
|
+
2. Work as you like.
|
21
|
+
|
22
|
+
* Please create tests. This helps us know that all your code runs cleanly.
|
23
|
+
|
24
|
+
3. Push to your fork and submit a pull request.
|
25
|
+
|
26
|
+
* We'll take a look as soon as we can; this is typically within a business day.
|
27
|
+
|
28
|
+
Thank you again!
|
data/LICENSE.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# License
|
2
|
+
|
3
|
+
You may choose any of these open source licenses:
|
4
|
+
|
5
|
+
* Apache License
|
6
|
+
* BSD License
|
7
|
+
* CreativeCommons License, Non-commercial Share Alike
|
8
|
+
* GNU Affero General Public License (AGPL)
|
9
|
+
* GNU General Public License Version (GPL)
|
10
|
+
* GNU Lesser General Public License (LGPL)
|
11
|
+
* MIT License
|
12
|
+
* Perl Artistic License
|
13
|
+
* Ruby License
|
14
|
+
|
15
|
+
The software is provided "as is", without warranty of any kind,
|
16
|
+
express or implied, including but not limited to the warranties of
|
17
|
+
merchantability, fitness for a particular purpose and noninfringement.
|
18
|
+
|
19
|
+
In no event shall the authors or copyright holders be liable for any
|
20
|
+
claim, damages or other liability, whether in an action of contract,
|
21
|
+
tort or otherwise, arising from, out of or in connection with the
|
22
|
+
software or the use or other dealings in the software.
|
23
|
+
|
24
|
+
This license is for the included software that is created by SixArm.
|
25
|
+
Some of the included software may have its own licenses, copyrights,
|
26
|
+
authors, etc. and these may take precedence over the SixArm license.
|
27
|
+
|
28
|
+
Copyright (c) Joel Parker Henderson
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# SixArm.com » Ruby » <br> ToId
|
1
|
+
# SixArm.com » Ruby » <br> ToId parses an object to id
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/SixArm/sixarm_ruby_to_id.png)](https://codeclimate.com/github/SixArm/sixarm_ruby_to_id)
|
4
|
+
[![Build Status](https://travis-ci.org/SixArm/sixarm_ruby_to_id.png)](https://travis-ci.org/SixArm/sixarm_ruby_to_id)
|
2
5
|
|
3
6
|
* Doc: <http://sixarm.com/sixarm_ruby_to_id/doc>
|
4
7
|
* Gem: <http://rubygems.org/gems/sixarm_ruby_to_id>
|
@@ -24,7 +27,7 @@ Install:
|
|
24
27
|
|
25
28
|
Bundler:
|
26
29
|
|
27
|
-
gem "sixarm_ruby_to_id", "
|
30
|
+
gem "sixarm_ruby_to_id", ">=1.0.9", "<2"
|
28
31
|
|
29
32
|
Require:
|
30
33
|
|
@@ -41,7 +44,7 @@ To enable high security for all our gems:
|
|
41
44
|
|
42
45
|
To install with high security:
|
43
46
|
|
44
|
-
gem install sixarm_ruby_to_id --
|
47
|
+
gem install sixarm_ruby_to_id --trust-policy HighSecurity
|
45
48
|
|
46
49
|
|
47
50
|
## Examples
|
@@ -61,40 +64,3 @@ Cast a comma-separated list to string ids:
|
|
61
64
|
Cast a hash of year, month, day to a date id YYYY-MM-DD:
|
62
65
|
|
63
66
|
{year: "2000", month: "12", day: "31"}.to_date_id #=> "2000-12-31"
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
## Changes
|
68
|
-
|
69
|
-
* 2012-09-21 1.0.8 Change stint format to use range dots like "x..y"
|
70
|
-
* 2012-08-21 1.0.7 Add Hash#to_date_id
|
71
|
-
* 2012-08-11 1.0.0 Publish
|
72
|
-
|
73
|
-
|
74
|
-
## License
|
75
|
-
|
76
|
-
You may choose any of these open source licenses:
|
77
|
-
|
78
|
-
* Apache License
|
79
|
-
* BSD License
|
80
|
-
* CreativeCommons License, Non-commercial Share Alike
|
81
|
-
* GNU General Public License Version 2 (GPL 2)
|
82
|
-
* GNU Lesser General Public License (LGPL)
|
83
|
-
* MIT License
|
84
|
-
* Perl Artistic License
|
85
|
-
* Ruby License
|
86
|
-
|
87
|
-
The software is provided "as is", without warranty of any kind,
|
88
|
-
express or implied, including but not limited to the warranties of
|
89
|
-
merchantability, fitness for a particular purpose and noninfringement.
|
90
|
-
|
91
|
-
In no event shall the authors or copyright holders be liable for any
|
92
|
-
claim, damages or other liability, whether in an action of contract,
|
93
|
-
tort or otherwise, arising from, out of or in connection with the
|
94
|
-
software or the use or other dealings in the software.
|
95
|
-
|
96
|
-
This license is for the included software that is created by SixArm;
|
97
|
-
some of the included software may have its own licenses, copyrights,
|
98
|
-
authors, etc. and these do take precedence over the SixArm license.
|
99
|
-
|
100
|
-
Copyright (c) 2005-2013 Joel Parker Henderson
|
data/Rakefile
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "rake"
|
3
|
+
require "rake/testtask"
|
4
4
|
|
5
5
|
Rake::TestTask.new(:test) do |t|
|
6
6
|
t.libs << 'lib' << 'test'
|
7
7
|
t.pattern = 'test/*.rb'
|
8
8
|
end
|
9
|
+
task :default => [:test]
|
10
|
+
task :default => [:test]
|
11
|
+
task :default => [:test]
|
12
|
+
task :default => [:test]
|
13
|
+
task :default => [:test]
|
14
|
+
task :default => [:test]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.9
|
data/lib/sixarm_ruby_to_id.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# Cast an array to an id.
|
4
|
+
#
|
5
|
+
class Array
|
3
6
|
|
4
7
|
# Cast the items to date ids.
|
5
|
-
#
|
6
|
-
# "2000-12-31,2001-12-31,2002-12-31".
|
8
|
+
#
|
9
|
+
# [" 2000-12-31 ", " 2001-12-31 ", " 2002-12-31 "].to_date_ids
|
7
10
|
# #=> ["2000-12-31", "2001-12-31", "2002-12-13"]
|
8
11
|
#
|
9
12
|
def to_date_ids
|
10
13
|
map{|x| x.to_date_id}
|
11
14
|
end
|
12
15
|
|
13
|
-
|
14
16
|
# Cast the items to stint ids.
|
15
|
-
#
|
16
|
-
# ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31".to_stint_ids
|
17
|
+
#
|
18
|
+
# ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31".to_stint_ids
|
17
19
|
# #=> ["2000-12-30-2000-12-31", "2001-12-30-2001-12-31", "2002-12-30-2002-12-31"]
|
18
20
|
#
|
19
21
|
def to_stint_ids
|
20
22
|
map{|x| x.to_stint_id}
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
25
|
# Cast the items to integer ids.
|
25
26
|
#
|
26
27
|
# [" 1 ", " 2 ", " 3 "].to_i_ids
|
@@ -30,24 +31,22 @@ class Array
|
|
30
31
|
map{|x| x.to_i_id}
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
34
|
# Cast the items to string ids.
|
35
35
|
#
|
36
|
-
# [" a ", " b ", " c "].to_i_ids
|
36
|
+
# [" a ", " b ", " c "].to_i_ids
|
37
37
|
# #=> ["a", "b", "c"]
|
38
38
|
#
|
39
39
|
def to_s_ids
|
40
40
|
map{|x| x.to_s_id}
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
43
|
# Cast the items to string uuids.
|
45
44
|
#
|
46
45
|
# [
|
47
46
|
# " 00000000-0000-0000-0000-000000000000 "
|
48
47
|
# " 11111111-1111-1111-1111-111111111111 ",
|
49
48
|
# " 22222222-2222-2222-2222-222222222222 "
|
50
|
-
# ].to_s_uuids
|
49
|
+
# ].to_s_uuids
|
51
50
|
# #=> [
|
52
51
|
# "00000000-0000-0000-0000-000000000000"
|
53
52
|
# "11111111-1111-1111-1111-111111111111",
|
@@ -58,5 +57,4 @@ class Array
|
|
58
57
|
map{|x| x.to_s_uuid}
|
59
58
|
end
|
60
59
|
|
61
|
-
|
62
60
|
end
|
@@ -1,14 +1,25 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# Cast a date to an id.
|
4
|
+
#
|
5
|
+
class Date
|
3
6
|
|
4
7
|
# Cast me to a date id.
|
5
|
-
#
|
6
|
-
# Date.today.to_date_id
|
8
|
+
#
|
9
|
+
# Date.today.to_date_id
|
7
10
|
# #=> "2000-12-31"
|
8
11
|
#
|
9
12
|
def to_date_id
|
10
13
|
self.to_time.strftime("%Y-%m-%d")
|
11
14
|
end
|
12
15
|
|
16
|
+
# Cast me to a list of date ids.
|
17
|
+
#
|
18
|
+
# Date.today.to_date_id
|
19
|
+
# #=> "2000-12-31"
|
20
|
+
#
|
21
|
+
def to_date_ids
|
22
|
+
[self.to_date_id]
|
23
|
+
end
|
13
24
|
|
14
25
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# Cast a hash to an id.
|
4
|
+
#
|
5
|
+
class Hash
|
3
6
|
|
4
7
|
# Cast me to a date id by parsing fields for year, month, day.
|
5
8
|
#
|
@@ -8,13 +11,12 @@ class Hash
|
|
8
11
|
# #=> "2000-12-31"
|
9
12
|
#
|
10
13
|
def to_date_id
|
11
|
-
year = self["year"] || self[:year]
|
12
|
-
month = self["month"] || self[:month]
|
14
|
+
year = self["year"] || self[:year]
|
15
|
+
month = self["month"] || self[:month]
|
13
16
|
day = self["day"] || self[:day]
|
14
17
|
year && year!="" && month && month!="" && day && day!="" \
|
15
18
|
? sprintf("%4.4d-%2.2d-%2.2d", year.to_i, month.to_i, day.to_i) \
|
16
19
|
: nil
|
17
20
|
end
|
18
21
|
|
19
|
-
|
20
22
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# Cast a nil to an id.
|
4
|
+
#
|
5
|
+
class NilClass
|
3
6
|
|
4
7
|
# Always return nil.
|
5
8
|
#
|
@@ -7,55 +10,46 @@ class NilClass
|
|
7
10
|
nil
|
8
11
|
end
|
9
12
|
|
10
|
-
|
11
13
|
# Always return nil.
|
12
14
|
#
|
13
15
|
def to_date_ids
|
14
16
|
nil
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
19
|
# Always return nil.
|
19
20
|
#
|
20
21
|
def to_stint_id
|
21
22
|
nil
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
25
|
# Always return nil.
|
26
26
|
#
|
27
27
|
def to_stint_ids
|
28
28
|
nil
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
31
|
# Always return nil.
|
33
32
|
#
|
34
33
|
def to_i_id
|
35
34
|
nil
|
36
35
|
end
|
37
36
|
|
38
|
-
|
39
37
|
# Always return nil.
|
40
38
|
#
|
41
39
|
def to_i_ids
|
42
40
|
nil
|
43
41
|
end
|
44
42
|
|
45
|
-
|
46
43
|
# Always return nil.
|
47
44
|
#
|
48
45
|
def to_s_id
|
49
46
|
nil
|
50
47
|
end
|
51
48
|
|
52
|
-
|
53
49
|
# Always return nil.
|
54
50
|
#
|
55
51
|
def to_s_ids
|
56
52
|
nil
|
57
53
|
end
|
58
54
|
|
59
|
-
|
60
55
|
end
|
61
|
-
|
@@ -1,12 +1,23 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# Cast a number to an id.
|
4
|
+
#
|
5
|
+
class Numeric
|
3
6
|
|
4
7
|
# Cast me to an int.
|
8
|
+
#
|
9
|
+
# 3.14.to_i_id
|
10
|
+
# #=> 3
|
11
|
+
#
|
5
12
|
def to_i_id
|
6
13
|
to_i
|
7
14
|
end
|
8
15
|
|
9
16
|
# Cast me to a list of int.
|
17
|
+
#
|
18
|
+
# 3.14.to_i_ids
|
19
|
+
# #=> [3]
|
20
|
+
#
|
10
21
|
def to_i_ids
|
11
22
|
[to_i]
|
12
23
|
end
|
@@ -1,10 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Cast an object to an id.
|
4
|
+
#
|
1
5
|
class Object
|
2
6
|
|
3
|
-
#
|
7
|
+
# Cast me to an int id.
|
8
|
+
#
|
9
|
+
# Object.new.to_i_ids
|
10
|
+
# #=> 70186724200120
|
11
|
+
#
|
12
|
+
# Call #object_id.to_i on the object; this is a decent default.
|
4
13
|
# Subclasses will override this, e.g. String, Array, Numeric, etc.
|
5
14
|
#
|
6
15
|
def to_i_id
|
7
|
-
|
16
|
+
object_id.to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
# Cast me to a list of int ids.
|
20
|
+
#
|
21
|
+
# Object.new.to_i_ids
|
22
|
+
# #=> [70186724200120]
|
23
|
+
#
|
24
|
+
# Call #object_id.to_i on the object; this is a decent default.
|
25
|
+
# Subclasses will override this, e.g. String, Array, Numeric, etc.
|
26
|
+
#
|
27
|
+
def to_i_ids
|
28
|
+
[self.to_i_id]
|
8
29
|
end
|
9
30
|
|
10
31
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# Cast a string to an id.
|
4
|
+
#
|
5
|
+
class String
|
3
6
|
|
4
7
|
# Cast me to a date id.
|
5
8
|
#
|
@@ -11,7 +14,6 @@ class String
|
|
11
14
|
s =~ /\A\d\d\d\d-\d\d-\d\d\z/ ? s : nil
|
12
15
|
end
|
13
16
|
|
14
|
-
|
15
17
|
# Cast me to a list of date ids.
|
16
18
|
# The string is comma-separated.
|
17
19
|
#
|
@@ -22,7 +24,6 @@ class String
|
|
22
24
|
split(/,/).map{|x| x.to_date_id}
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
27
|
# Cast me to a stint id.
|
27
28
|
#
|
28
29
|
# The string is two ISO dates in YYYY-MM-DD.
|
@@ -46,7 +47,6 @@ class String
|
|
46
47
|
s =~ /\A\d\d\d\d-\d\d-\d\d\.\.\.?\d\d\d\d-\d\d-\d\d\z/ ? s : nil
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
50
|
# Cast me to a list of stint ids.
|
51
51
|
# The string is comma-separated.
|
52
52
|
#
|
@@ -57,7 +57,6 @@ class String
|
|
57
57
|
split(/,/).map{|x| x.to_stint_id}
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
60
|
# Cast me to an integer id.
|
62
61
|
#
|
63
62
|
# " 1 ".to_i_id
|
@@ -67,7 +66,6 @@ class String
|
|
67
66
|
strip.to_i
|
68
67
|
end
|
69
68
|
|
70
|
-
|
71
69
|
# Cast me (a comma-separated list) to a list of integer ids.
|
72
70
|
# The string is comma-separated.
|
73
71
|
#
|
@@ -78,7 +76,6 @@ class String
|
|
78
76
|
split(/,/).map{|x| x.to_i_id}
|
79
77
|
end
|
80
78
|
|
81
|
-
|
82
79
|
# Cast me to a string id.
|
83
80
|
#
|
84
81
|
# " a "
|
@@ -88,7 +85,6 @@ class String
|
|
88
85
|
strip
|
89
86
|
end
|
90
87
|
|
91
|
-
|
92
88
|
# Cast me to a list of string ids.
|
93
89
|
# The string is comma-separated.
|
94
90
|
#
|
@@ -99,7 +95,6 @@ class String
|
|
99
95
|
split(/,/).to_s_ids
|
100
96
|
end
|
101
97
|
|
102
|
-
|
103
98
|
# Cast me to a string uuid.
|
104
99
|
#
|
105
100
|
# " 00000000-0000-0000-0000-000000000000 ".to_s_uuids
|
@@ -109,7 +104,6 @@ class String
|
|
109
104
|
strip.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/) ? $& : nil
|
110
105
|
end
|
111
106
|
|
112
|
-
|
113
107
|
# Cast me to a list of string ids.
|
114
108
|
# The string is comma-separated.
|
115
109
|
#
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "simplecov"
|
4
|
+
SimpleCov.start
|
5
|
+
|
6
|
+
require "sixarm_ruby_to_id"
|
4
7
|
|
5
8
|
describe Date do
|
6
9
|
|
@@ -10,5 +13,10 @@ describe Date do
|
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
13
|
-
|
16
|
+
describe "#to_date_ids" do
|
17
|
+
it "casts to a date id YYYY-MM-DD list" do
|
18
|
+
Date.parse("2000-12-31").to_date_ids.must_equal ["2000-12-31"]
|
19
|
+
end
|
20
|
+
end
|
14
21
|
|
22
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "simplecov"
|
4
|
+
SimpleCov.start
|
5
|
+
|
6
|
+
require "sixarm_ruby_to_id"
|
4
7
|
|
5
8
|
describe Hash do
|
6
9
|
|
@@ -23,11 +26,11 @@ describe Hash do
|
|
23
26
|
it "year is blank #=> nil" do
|
24
27
|
{year: "", month: "12", day: "31"}.to_date_id.must_equal nil
|
25
28
|
end
|
26
|
-
|
29
|
+
|
27
30
|
it "month is blank #=> nil" do
|
28
31
|
{year: "2000", month: "", day: "31"}.to_date_id.must_equal nil
|
29
32
|
end
|
30
|
-
|
33
|
+
|
31
34
|
it "day is blank #=> nil" do
|
32
35
|
{year: "2000", month: "12", day: ""}.to_date_id.must_equal nil
|
33
36
|
end
|
@@ -39,11 +42,11 @@ describe Hash do
|
|
39
42
|
it "missing year #=> nil" do
|
40
43
|
{month: "12", day: "31"}.to_date_id.must_equal nil
|
41
44
|
end
|
42
|
-
|
45
|
+
|
43
46
|
it "missing month #=> nil" do
|
44
47
|
{year: "2000", day: "31"}.to_date_id.must_equal nil
|
45
48
|
end
|
46
|
-
|
49
|
+
|
47
50
|
it "missing day #=> nil" do
|
48
51
|
{year: "2000", month: "12"}.to_date_id.must_equal nil
|
49
52
|
end
|
@@ -53,5 +56,3 @@ describe Hash do
|
|
53
56
|
end
|
54
57
|
|
55
58
|
end
|
56
|
-
|
57
|
-
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "simplecov"
|
4
|
+
SimpleCov.start
|
5
|
+
|
6
|
+
require "sixarm_ruby_to_id"
|
4
7
|
|
5
8
|
class Mock
|
6
|
-
def
|
9
|
+
def object_id
|
7
10
|
"123"
|
8
11
|
end
|
9
12
|
end
|
@@ -11,11 +14,17 @@ end
|
|
11
14
|
describe Object do
|
12
15
|
|
13
16
|
describe "#to_i_id" do
|
14
|
-
it "returns #
|
17
|
+
it "returns #object_id.to_i" do
|
15
18
|
x = Mock.new
|
16
19
|
x.to_i_id.must_equal 123
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
|
-
|
23
|
+
describe "#to_i_ids" do
|
24
|
+
it "returns #object_id.to_i list" do
|
25
|
+
x = Mock.new
|
26
|
+
x.to_i_ids.must_equal [123]
|
27
|
+
end
|
28
|
+
end
|
21
29
|
|
30
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "simplecov"
|
4
|
+
SimpleCov.start
|
5
|
+
|
6
|
+
require "sixarm_ruby_to_id"
|
4
7
|
|
5
8
|
describe String do
|
6
9
|
|
@@ -28,7 +31,7 @@ describe String do
|
|
28
31
|
end
|
29
32
|
|
30
33
|
describe "#to_stint_ids" do
|
31
|
-
it "casts me to a list of stint ids" do
|
34
|
+
it "casts me to a list of stint ids" do
|
32
35
|
" 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
36
|
" 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]
|
34
37
|
end
|
@@ -77,5 +80,3 @@ describe String do
|
|
77
80
|
end
|
78
81
|
|
79
82
|
end
|
80
|
-
|
81
|
-
|
metadata
CHANGED
@@ -1,51 +1,143 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sixarm_ruby_to_id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- SixArm
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain:
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIGCTCCA/GgAwIBAgIJAK3igyLv2hNNMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
|
14
|
+
BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
|
15
|
+
c2NvMQ8wDQYDVQQKEwZTaXhBcm0xEzARBgNVBAMTCnNpeGFybS5jb20wHhc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ES/gQPOnvmVkLDGw==
|
46
|
+
-----END CERTIFICATE-----
|
47
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
48
|
+
dependencies:
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: minitest
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 5.7.0
|
56
|
+
- - "<"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '6'
|
59
|
+
type: :development
|
60
|
+
prerelease: false
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 5.7.0
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 10.4.2
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '11'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 10.4.2
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '11'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.10.0
|
96
|
+
- - "<"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '2'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 0.10.0
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '2'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: coveralls
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.8.2
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '2'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.8.2
|
126
|
+
- - "<"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '2'
|
129
|
+
description: ToId converts types to ids and uuids
|
41
130
|
email: sixarm@sixarm.com
|
42
131
|
executables: []
|
43
132
|
extensions: []
|
44
133
|
extra_rdoc_files: []
|
45
134
|
files:
|
46
|
-
- .gemtest
|
47
|
-
-
|
135
|
+
- ".gemtest"
|
136
|
+
- CHANGES.md
|
137
|
+
- CONTRIBUTING.md
|
138
|
+
- LICENSE.md
|
48
139
|
- README.md
|
140
|
+
- Rakefile
|
49
141
|
- VERSION
|
50
142
|
- lib/sixarm_ruby_to_id.rb
|
51
143
|
- lib/sixarm_ruby_to_id/array.rb
|
@@ -64,29 +156,33 @@ files:
|
|
64
156
|
- test/sixarm_ruby_to_id_test/object_test.rb
|
65
157
|
- test/sixarm_ruby_to_id_test/string_test.rb
|
66
158
|
homepage: http://sixarm.com/
|
67
|
-
licenses:
|
159
|
+
licenses:
|
160
|
+
- BSD
|
161
|
+
- GPL
|
162
|
+
- MIT
|
163
|
+
- PAL
|
164
|
+
- Various
|
165
|
+
metadata: {}
|
68
166
|
post_install_message:
|
69
167
|
rdoc_options: []
|
70
168
|
require_paths:
|
71
169
|
- lib
|
72
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
171
|
requirements:
|
75
|
-
- -
|
172
|
+
- - ">="
|
76
173
|
- !ruby/object:Gem::Version
|
77
174
|
version: '0'
|
78
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
176
|
requirements:
|
81
|
-
- -
|
177
|
+
- - ">="
|
82
178
|
- !ruby/object:Gem::Version
|
83
179
|
version: '0'
|
84
180
|
requirements: []
|
85
181
|
rubyforge_project:
|
86
|
-
rubygems_version:
|
182
|
+
rubygems_version: 2.4.8
|
87
183
|
signing_key:
|
88
|
-
specification_version:
|
89
|
-
summary: SixArm.com » Ruby » ToId
|
184
|
+
specification_version: 4
|
185
|
+
summary: SixArm.com » Ruby » ToId
|
90
186
|
test_files:
|
91
187
|
- test/sixarm_ruby_to_id_test.rb
|
92
188
|
- test/sixarm_ruby_to_id_test/array_test.rb
|
metadata.gz.sig
CHANGED
Binary file
|