pigeon_hole 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pigeon_hole/json_date_time.rb +4 -17
  3. data/lib/pigeon_hole/monster-vim-2016-07-25-16-44-46.rb +29 -0
  4. data/lib/pigeon_hole/monster-vim-2016-07-25-16-44-47.rb +29 -0
  5. data/lib/pigeon_hole/monster-vim-2016-07-25-16-44-58.rb +41 -0
  6. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-02.rb +41 -0
  7. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-08.rb +41 -0
  8. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-09.rb +41 -0
  9. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-10.rb +41 -0
  10. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-35.rb +29 -0
  11. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-36.rb +29 -0
  12. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-37.rb +29 -0
  13. data/lib/pigeon_hole/monster-vim-2016-07-25-16-47-38.rb +29 -0
  14. data/lib/pigeon_hole/monster-vim-2016-07-26-10-09-11.rb +41 -0
  15. data/lib/pigeon_hole/monster-vim-2016-07-26-10-09-41.rb +34 -0
  16. data/lib/pigeon_hole/monster-vim-2016-07-26-10-09-42.rb +34 -0
  17. data/lib/pigeon_hole/monster-vim-2016-07-26-10-11-26.rb +35 -0
  18. data/lib/pigeon_hole/monster-vim-2016-07-26-10-15-33.rb +39 -0
  19. data/lib/pigeon_hole/monster-vim-2016-07-26-10-15-46.rb +40 -0
  20. data/lib/pigeon_hole/monster-vim-2016-07-26-10-15-57.rb +37 -0
  21. data/lib/pigeon_hole/monster-vim-2016-07-26-10-16-03.rb +27 -0
  22. data/lib/pigeon_hole/monster-vim-2016-07-26-10-16-04.rb +27 -0
  23. data/lib/pigeon_hole/monster-vim-2016-07-26-10-16-05.rb +27 -0
  24. data/lib/pigeon_hole/monster-vim-2016-07-26-10-17-22.rb +28 -0
  25. data/lib/pigeon_hole/monster-vim-2016-07-26-10-17-23.rb +28 -0
  26. data/lib/pigeon_hole/monster-vim-2016-07-26-10-19-14.rb +28 -0
  27. data/lib/pigeon_hole/monster-vim-2016-07-26-10-20-50.rb +28 -0
  28. data/lib/pigeon_hole/monster-vim-2016-07-26-10-20-52.rb +28 -0
  29. data/lib/pigeon_hole/monster-vim-2016-07-26-10-20-53.rb +28 -0
  30. data/lib/pigeon_hole/monster-vim-2016-07-26-10-26-57.rb +42 -0
  31. data/lib/pigeon_hole/monster-vim-2016-07-26-10-26-58.rb +42 -0
  32. data/lib/pigeon_hole/monster-vim-2016-07-26-10-27-58.rb +42 -0
  33. data/lib/pigeon_hole/monster-vim-2016-07-26-10-27-59.rb +42 -0
  34. data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-40.rb +42 -0
  35. data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-41.rb +42 -0
  36. data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-42.rb +42 -0
  37. data/lib/pigeon_hole/monster-vim-2016-07-26-10-33-53.rb +42 -0
  38. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-07.rb +42 -0
  39. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-08.rb +42 -0
  40. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-09.rb +42 -0
  41. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-20.rb +44 -0
  42. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-21.rb +44 -0
  43. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-22.rb +44 -0
  44. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-23.rb +44 -0
  45. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-24.rb +44 -0
  46. data/lib/pigeon_hole/monster-vim-2016-07-26-10-37-25.rb +44 -0
  47. data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-26.rb +53 -0
  48. data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-27.rb +53 -0
  49. data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-28.rb +53 -0
  50. data/lib/pigeon_hole/monster-vim-2016-07-26-10-38-29.rb +53 -0
  51. data/lib/pigeon_hole/monster-vim-2016-07-26-10-39-14.rb +53 -0
  52. data/lib/pigeon_hole/typed_json.rb +13 -0
  53. data/spec/integration_spec.rb +18 -0
  54. data/spec/monster-vim-2016-07-26-10-29-02.rb +117 -0
  55. data/spec/monster-vim-2016-07-26-10-29-53.rb +118 -0
  56. metadata +55 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f679f4b70108c6d3d567f1905462749de53dd26
4
- data.tar.gz: c98c767931a8f0e1799e7db0d743c484ac46abf7
3
+ metadata.gz: 6d01a12f251e39f29b4e12db0d70149bd0b49d4c
4
+ data.tar.gz: 092d50e556f776111d5aa7726883a344d61e8b6d
5
5
  SHA512:
6
- metadata.gz: 7fa933c8432ae976cc51a96f9ca01355d9ccdece601844411207752f629cb5a31fc89337827c91944426dd5b2e971d1351e44131185f09bc046eeedc00ca9e49
7
- data.tar.gz: d3384729d4a8a7bdd0cf82a6099fea598fdfb62da7fea3e66dc7a4e0242c203b43e9db9539aaf721c101bebd4124a2088acc14f66d9efe8cf4d7f8969d2149f6
6
+ metadata.gz: 65d283f300b2a7d8bae948e4fdf547965cd292e6b945ffd17a7ebc9db0dd0f1af29491e4ece99161861b3be610d108343b5df233aa5998b772f4e373715a1c16
7
+ data.tar.gz: fd3f11d35299c79dfeffed5b945491cdfeab16a7470be28f394d12179becb2b9f2926e251a1ecaf705fec9c32603d595605baef1040f1ab0f88333da7117ce29
@@ -4,15 +4,9 @@ module PigeonHole
4
4
  # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
5
5
  # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
6
6
  def self.json_create(object)
7
- args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
8
- of_a, of_b = object['of'].split('/')
9
- if of_b and of_b != '0'
10
- args << DateTime.send(:Rational, of_a.to_i, of_b.to_i)
11
- else
12
- args << of_a
13
- end
14
- args << object['sg']
15
- DateTime.civil(*args)
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
16
10
  end
17
11
 
18
12
  # Returns a hash, that will be turned into a JSON object and represent this
@@ -20,14 +14,7 @@ module PigeonHole
20
14
  def as_json(*)
21
15
  {
22
16
  JSON.create_id => self.class.name,
23
- 'y' => year,
24
- 'm' => month,
25
- 'd' => day,
26
- 'H' => hour,
27
- 'M' => min,
28
- 'S' => sec,
29
- 'of' => offset.to_s,
30
- 'sg' => start,
17
+ 'ms' => (to_time.tv_sec * 1000) + (to_time.usec / 1000),
31
18
  }
32
19
  end
33
20
 
@@ -0,0 +1,29 @@
1
+ module PigeonHole
2
+ class JSONDate < SimpleDelegator
3
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
4
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
5
+ def self.json_create(object)
6
+ Date.civil(*object.values_at('y', 'm', 'd', 'sg')).
7
+ end
8
+
9
+ #alias start sg unless method_defined?(:start)
10
+
11
+ # Returns a hash, that will be turned into a JSON object and represent this
12
+ # object.
13
+ def as_json(*)
14
+ {
15
+ JSON.create_id => self.class.name,
16
+ 'y' => year,
17
+ 'm' => month,
18
+ 'd' => day,
19
+ 'sg' => start,
20
+ }
21
+ end
22
+
23
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
24
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module PigeonHole
2
+ class JSONDate < SimpleDelegator
3
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
4
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
5
+ def self.json_create(object)
6
+ Date.civil(*object.values_at('y', 'm', 'd', 'sg')).utc
7
+ end
8
+
9
+ #alias start sg unless method_defined?(:start)
10
+
11
+ # Returns a hash, that will be turned into a JSON object and represent this
12
+ # object.
13
+ def as_json(*)
14
+ {
15
+ JSON.create_id => self.class.name,
16
+ 'y' => year,
17
+ 'm' => month,
18
+ 'd' => day,
19
+ 'sg' => start,
20
+ }
21
+ end
22
+
23
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
24
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
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
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
8
+ of_a, of_b = object['of'].split('/')
9
+ if of_b and of_b != '0'
10
+ args << DateTime.send(:Rational, of_a.to_i, of_b.to_i)
11
+ else
12
+ args << of_a
13
+ end
14
+ args << object['sg']
15
+ DateTime.civil(*args).ut
16
+ end
17
+
18
+ # Returns a hash, that will be turned into a JSON object and represent this
19
+ # object.
20
+ def as_json(*)
21
+ {
22
+ JSON.create_id => self.class.name,
23
+ 'y' => year,
24
+ 'm' => month,
25
+ 'd' => day,
26
+ 'H' => hour,
27
+ 'M' => min,
28
+ 'S' => sec,
29
+ 'of' => offset.to_s,
30
+ 'sg' => start,
31
+ }
32
+ end
33
+
34
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
35
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
36
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
37
+ def to_json(*args)
38
+ as_json.to_json(*args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
8
+ of_a, of_b = object['of'].split('/')
9
+ if of_b and of_b != '0'
10
+ args << DateTime.send(:Rational, of_a.to_i, of_b.to_i)
11
+ else
12
+ args << of_a
13
+ end
14
+ args << object['sg']
15
+ DateTime.civil(*args).
16
+ end
17
+
18
+ # Returns a hash, that will be turned into a JSON object and represent this
19
+ # object.
20
+ def as_json(*)
21
+ {
22
+ JSON.create_id => self.class.name,
23
+ 'y' => year,
24
+ 'm' => month,
25
+ 'd' => day,
26
+ 'H' => hour,
27
+ 'M' => min,
28
+ 'S' => sec,
29
+ 'of' => offset.to_s,
30
+ 'sg' => start,
31
+ }
32
+ end
33
+
34
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
35
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
36
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
37
+ def to_json(*args)
38
+ as_json.to_json(*args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
8
+ of_a, of_b = object['of'].split('/')
9
+ if of_b and of_b != '0'
10
+ args << DateTime.send(:Rational, of_a.to_i, of_b.to_i)
11
+ else
12
+ args << of_a
13
+ end
14
+ args << object['sg']
15
+ DateTime.civil(*args).new_
16
+ end
17
+
18
+ # Returns a hash, that will be turned into a JSON object and represent this
19
+ # object.
20
+ def as_json(*)
21
+ {
22
+ JSON.create_id => self.class.name,
23
+ 'y' => year,
24
+ 'm' => month,
25
+ 'd' => day,
26
+ 'H' => hour,
27
+ 'M' => min,
28
+ 'S' => sec,
29
+ 'of' => offset.to_s,
30
+ 'sg' => start,
31
+ }
32
+ end
33
+
34
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
35
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
36
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
37
+ def to_json(*args)
38
+ as_json.to_json(*args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
8
+ of_a, of_b = object['of'].split('/')
9
+ if of_b and of_b != '0'
10
+ args << DateTime.send(:Rational, of_a.to_i, of_b.to_i)
11
+ else
12
+ args << of_a
13
+ end
14
+ args << object['sg']
15
+ DateTime.civil(*args).new_off
16
+ end
17
+
18
+ # Returns a hash, that will be turned into a JSON object and represent this
19
+ # object.
20
+ def as_json(*)
21
+ {
22
+ JSON.create_id => self.class.name,
23
+ 'y' => year,
24
+ 'm' => month,
25
+ 'd' => day,
26
+ 'H' => hour,
27
+ 'M' => min,
28
+ 'S' => sec,
29
+ 'of' => offset.to_s,
30
+ 'sg' => start,
31
+ }
32
+ end
33
+
34
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
35
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
36
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
37
+ def to_json(*args)
38
+ as_json.to_json(*args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
8
+ of_a, of_b = object['of'].split('/')
9
+ if of_b and of_b != '0'
10
+ args << DateTime.send(:Rational, of_a.to_i, of_b.to_i)
11
+ else
12
+ args << of_a
13
+ end
14
+ args << object['sg']
15
+ DateTime.civil(*args).new_offset
16
+ end
17
+
18
+ # Returns a hash, that will be turned into a JSON object and represent this
19
+ # object.
20
+ def as_json(*)
21
+ {
22
+ JSON.create_id => self.class.name,
23
+ 'y' => year,
24
+ 'm' => month,
25
+ 'd' => day,
26
+ 'H' => hour,
27
+ 'M' => min,
28
+ 'S' => sec,
29
+ 'of' => offset.to_s,
30
+ 'sg' => start,
31
+ }
32
+ end
33
+
34
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
35
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
36
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
37
+ def to_json(*args)
38
+ as_json.to_json(*args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ module PigeonHole
2
+ class JSONDate < SimpleDelegator
3
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
4
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
5
+ def self.json_create(object)
6
+ Date.civil(*object.values_at('y', 'm', 'd', 'sg')).
7
+ end
8
+
9
+ #alias start sg unless method_defined?(:start)
10
+
11
+ # Returns a hash, that will be turned into a JSON object and represent this
12
+ # object.
13
+ def as_json(*)
14
+ {
15
+ JSON.create_id => self.class.name,
16
+ 'y' => year,
17
+ 'm' => month,
18
+ 'd' => day,
19
+ 'sg' => start,
20
+ }
21
+ end
22
+
23
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
24
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module PigeonHole
2
+ class JSONDate < SimpleDelegator
3
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
4
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
5
+ def self.json_create(object)
6
+ Date.civil(*object.values_at('y', 'm', 'd', 'sg')).ne
7
+ end
8
+
9
+ #alias start sg unless method_defined?(:start)
10
+
11
+ # Returns a hash, that will be turned into a JSON object and represent this
12
+ # object.
13
+ def as_json(*)
14
+ {
15
+ JSON.create_id => self.class.name,
16
+ 'y' => year,
17
+ 'm' => month,
18
+ 'd' => day,
19
+ 'sg' => start,
20
+ }
21
+ end
22
+
23
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
24
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module PigeonHole
2
+ class JSONDate < SimpleDelegator
3
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
4
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
5
+ def self.json_create(object)
6
+ Date.civil(*object.values_at('y', 'm', 'd', 'sg')).new_off
7
+ end
8
+
9
+ #alias start sg unless method_defined?(:start)
10
+
11
+ # Returns a hash, that will be turned into a JSON object and represent this
12
+ # object.
13
+ def as_json(*)
14
+ {
15
+ JSON.create_id => self.class.name,
16
+ 'y' => year,
17
+ 'm' => month,
18
+ 'd' => day,
19
+ 'sg' => start,
20
+ }
21
+ end
22
+
23
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
24
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module PigeonHole
2
+ class JSONDate < SimpleDelegator
3
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
4
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
5
+ def self.json_create(object)
6
+ Date.civil(*object.values_at('y', 'm', 'd', 'sg')).new_offset
7
+ end
8
+
9
+ #alias start sg unless method_defined?(:start)
10
+
11
+ # Returns a hash, that will be turned into a JSON object and represent this
12
+ # object.
13
+ def as_json(*)
14
+ {
15
+ JSON.create_id => self.class.name,
16
+ 'y' => year,
17
+ 'm' => month,
18
+ 'd' => day,
19
+ 'sg' => start,
20
+ }
21
+ end
22
+
23
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
24
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
+ end
28
+ end
29
+ end