pigeon_hole 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pigeon_hole.rb +11 -12
- data/lib/pigeon_hole/json_date.rb +9 -20
- data/lib/pigeon_hole/json_symbol.rb +8 -14
- data/lib/pigeon_hole/json_time.rb +9 -16
- data/lib/pigeon_hole/typed_json.rb +68 -30
- data/spec/integration_spec.rb +22 -6
- data/spec/spec_helper.rb +2 -16
- metadata +4 -75
- data/lib/pigeon_hole/json_date_time.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-44-46.rb +0 -29
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-44-47.rb +0 -29
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-44-58.rb +0 -41
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-02.rb +0 -41
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-08.rb +0 -41
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-09.rb +0 -41
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-10.rb +0 -41
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-35.rb +0 -29
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-36.rb +0 -29
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-37.rb +0 -29
- data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-38.rb +0 -29
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-09-11.rb +0 -41
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-09-41.rb +0 -34
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-09-42.rb +0 -34
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-11-26.rb +0 -35
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-15-33.rb +0 -39
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-15-46.rb +0 -40
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-15-57.rb +0 -37
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-16-03.rb +0 -27
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-16-04.rb +0 -27
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-16-05.rb +0 -27
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-17-22.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-17-23.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-19-14.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-20-50.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-20-52.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-20-53.rb +0 -28
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-26-57.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-26-58.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-27-58.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-27-59.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-40.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-41.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-42.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-53.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-07.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-08.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-09.rb +0 -42
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-20.rb +0 -44
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-21.rb +0 -44
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-22.rb +0 -44
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-23.rb +0 -44
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-24.rb +0 -44
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-25.rb +0 -44
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-26.rb +0 -53
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-27.rb +0 -53
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-28.rb +0 -53
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-29.rb +0 -53
- data/lib/pigeon_hole/monster-vim-2016-07-26-10-39-14.rb +0 -53
- data/spec/monster-vim-2016-07-26-10-29-02.rb +0 -117
- data/spec/monster-vim-2016-07-26-10-29-53.rb +0 -118
- data/spec/monster-vim-2016-07-26-12-05-32.rb +0 -117
- data/spec/monster-vim-2016-07-26-12-05-33.rb +0 -117
- data/spec/monster-vim-2016-07-26-12-05-34.rb +0 -117
- data/spec/monster-vim-2016-07-26-12-05-35.rb +0 -117
- data/spec/monster-vim-2016-07-26-12-06-22.rb +0 -33
- data/spec/monster-vim-2016-07-26-12-06-32.rb +0 -33
- data/spec/monster-vim-2016-07-26-12-06-33.rb +0 -33
- data/spec/monster-vim-2016-07-26-12-06-34.rb +0 -33
@@ -1,28 +0,0 @@
|
|
1
|
-
module PigeonHole
|
2
|
-
class JSONDateTime < SimpleDelegator
|
3
|
-
# Deserializes JSON string by converting year <tt>y</tt>, month <tt>m</tt>,
|
4
|
-
# day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
|
5
|
-
# offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
|
6
|
-
def self.json_create(object)
|
7
|
-
ms_since_epoc = object['ms'].to_i
|
8
|
-
seconds, fragment = ms_since_epoc.divmod(1000)
|
9
|
-
Time.at(seconds, fragment * 1000).utc.to_datetime
|
10
|
-
end
|
11
|
-
|
12
|
-
# Returns a hash, that will be turned into a JSON object and represent this
|
13
|
-
# object.
|
14
|
-
def as_json(*)
|
15
|
-
{
|
16
|
-
JSON.create_id => self.class.name,
|
17
|
-
'ms' => (to_time.tv_sec * 1000) + (to_time.usec / 1000),
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
# Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
|
22
|
-
# day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
|
23
|
-
# offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
|
24
|
-
def to_json(*args)
|
25
|
-
as_json.to_json(*args)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.ea
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v. { |av| each_with_parent(av) }
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.ma { |av| each_with_parent(av) }
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.amp
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.m
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.ma
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.map { |av| map_to_json(av) }.to_a
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.map { |av| map_to_json(av) map_to_json(av) }.
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PigeonHole
|
4
|
-
class TypedJSON
|
5
|
-
def self.generate(obj, *args)
|
6
|
-
hash_dup = each_with_parent(obj)
|
7
|
-
JSON.generate(hash_dup, *args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.map_to_json(obj)
|
11
|
-
case obj
|
12
|
-
when Time
|
13
|
-
JSONTime.new(obj)
|
14
|
-
when DateTime
|
15
|
-
JSONDateTime.new(obj)
|
16
|
-
when Date
|
17
|
-
JSONDate.new(obj)
|
18
|
-
when Symbol
|
19
|
-
JSONSymbol.new(obj)
|
20
|
-
else
|
21
|
-
obj
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.each_with_parent(hash, result=nil)
|
26
|
-
duplicated_hash = {} || result
|
27
|
-
|
28
|
-
hash.each do |k, v|
|
29
|
-
case v
|
30
|
-
when Hash
|
31
|
-
duplicated_hash[k] = each_with_parent(v, duplicated_hash)
|
32
|
-
when Array
|
33
|
-
duplicated_hash[k] = v.map { |av| map_to_json(av) map_to_json(av) }.to_
|
34
|
-
else
|
35
|
-
duplicated_hash[k] = map_to_json(v)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
duplicated_hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|