tod 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +52 -0
- data/README.markdown +28 -3
- data/Rakefile +2 -0
- data/gemfiles/3.0.gemfile +6 -0
- data/gemfiles/3.1.gemfile +6 -0
- data/gemfiles/3.2.gemfile +5 -0
- data/gemfiles/4.0.gemfile +5 -0
- data/lib/tod/time_of_day.rb +12 -0
- data/lib/tod/version.rb +1 -1
- data/test/support/active_record.rb +7 -0
- data/test/test_helper.rb +2 -1
- data/test/tod/time_of_day_serializable_attribute_test.rb +27 -0
- data/tod.gemspec +4 -1
- metadata +59 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b581f923a697d706a4e045117aec261e6d3ed4e9
|
4
|
+
data.tar.gz: 79aee8f84597353593f56ed4df390f173732a356
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 953bbbbda9c23b88959cb9f727edc3a892bb427fc37ab7ac565cc20a61ae5c93f89c160a38f27a9ce4c02fde2b78ee1d955cba5354406fd52fad3e6fa1759c2d
|
7
|
+
data.tar.gz: 8b8241b58dba21e20541ef5b28716562266eec55279ab41f9d7755e1d75e080a71a7e78ec2297b85332687d9dcb568da8a655cadff9e6e6d93b7bd7442fc00b1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tod (1.2.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.13)
|
10
|
+
activesupport (= 3.2.13)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.13)
|
13
|
+
activemodel (= 3.2.13)
|
14
|
+
activesupport (= 3.2.13)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.13)
|
18
|
+
i18n (= 0.6.1)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
arel (3.0.2)
|
21
|
+
bourne (1.4.0)
|
22
|
+
mocha (~> 0.13.2)
|
23
|
+
builder (3.0.4)
|
24
|
+
i18n (0.6.1)
|
25
|
+
metaclass (0.0.1)
|
26
|
+
mocha (0.13.3)
|
27
|
+
metaclass (~> 0.0.1)
|
28
|
+
multi_json (1.7.2)
|
29
|
+
rake (10.0.4)
|
30
|
+
shoulda (3.4.0)
|
31
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
32
|
+
shoulda-matchers (~> 1.0, >= 1.4.1)
|
33
|
+
shoulda-context (1.1.1)
|
34
|
+
shoulda-matchers (1.5.6)
|
35
|
+
activesupport (>= 3.0.0)
|
36
|
+
bourne (~> 1.3)
|
37
|
+
sqlite3 (1.3.7)
|
38
|
+
test-unit (2.5.4)
|
39
|
+
tzinfo (0.3.37)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
activerecord (>= 3.0.0)
|
46
|
+
mocha
|
47
|
+
rake
|
48
|
+
shoulda
|
49
|
+
sqlite3
|
50
|
+
test-unit
|
51
|
+
tod!
|
52
|
+
tzinfo
|
data/README.markdown
CHANGED
@@ -88,18 +88,43 @@ Rails Time Zone Support
|
|
88
88
|
|
89
89
|
If Rails time zone support is loaded, Date#on and TimeOfDay#at will automatically use Time.zone.
|
90
90
|
|
91
|
+
Active Record Serializable Attribute Support
|
92
|
+
=======================
|
93
|
+
TimeOfDay implements a custom serialization contract for activerecord serialize which allows to store TimeOfDay directly
|
94
|
+
in a column of the time type.
|
95
|
+
Example:
|
96
|
+
```ruby
|
97
|
+
class Order < ActiveRecord::Base
|
98
|
+
serialize :time, Tod::TimeOfDay
|
99
|
+
end
|
100
|
+
order = Order.create(time: TimeOfDay.new(9,30))
|
101
|
+
order.time # => 09:30:00
|
102
|
+
```
|
103
|
+
|
104
|
+
Compatibility
|
105
|
+
=============
|
106
|
+
|
107
|
+
[![Build Status](https://travis-ci.org/JackC/tod.png)](https://travis-ci.org/JackC/tod)
|
108
|
+
|
109
|
+
Tod is compatible with Ruby 1.9.3 and 2.0.0 and Rails 3.0, 3.1, 3.2, and 4.0.
|
110
|
+
|
111
|
+
|
91
112
|
History
|
92
113
|
=======
|
93
114
|
|
94
|
-
|
115
|
+
## 1.2.0 (July 16, 2013)
|
116
|
+
|
117
|
+
* Added ActiveRecord TimeOfDay serialization to time column (Maxim-Filimonov)
|
118
|
+
|
119
|
+
## 1.1.1 (April 12, 2013)
|
95
120
|
|
96
121
|
* Added to_i and from_i as aliases of second_of_day and from_second_of_day (Johnny Shields)
|
97
122
|
|
98
|
-
|
123
|
+
## 1.1.0 (February 13, 2013)
|
99
124
|
|
100
125
|
* Added Rails time zone support
|
101
126
|
|
102
|
-
|
127
|
+
## 1.0.0 (December 29, 2010)
|
103
128
|
|
104
129
|
* Initial Release
|
105
130
|
|
data/Rakefile
CHANGED
data/lib/tod/time_of_day.rb
CHANGED
@@ -133,6 +133,18 @@ module Tod
|
|
133
133
|
def self.time_zone
|
134
134
|
(Time.respond_to?(:zone) && Time.zone) || Time
|
135
135
|
end
|
136
|
+
|
137
|
+
def self.dump(time_of_day)
|
138
|
+
time_of_day.to_s
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.load(time)
|
142
|
+
if time.respond_to?(:to_time_of_day)
|
143
|
+
time.to_time_of_day
|
144
|
+
else
|
145
|
+
TimeOfDay.parse(time) if time && !time.empty?
|
146
|
+
end
|
147
|
+
end
|
136
148
|
end
|
137
149
|
end
|
138
150
|
|
data/lib/tod/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','support/active_record'))
|
3
|
+
|
4
|
+
class Order < ActiveRecord::Base
|
5
|
+
serialize :time, TimeOfDay
|
6
|
+
end
|
7
|
+
class TimeOfDayWithActiveRecordSerializableAttribute < Test::Unit::TestCase
|
8
|
+
context "self.dump" do
|
9
|
+
should "be able to set time of day" do
|
10
|
+
Order.create(time: TimeOfDay.new(9, 30))
|
11
|
+
end
|
12
|
+
should "be able to set nil as value" do
|
13
|
+
Order.create(time: nil)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
context "self.load" do
|
17
|
+
should "load set time" do
|
18
|
+
time_of_day = TimeOfDay.new(9, 30)
|
19
|
+
order = Order.create(time: time_of_day)
|
20
|
+
assert_equal order.time, time_of_day
|
21
|
+
end
|
22
|
+
should "return nil if time is not set" do
|
23
|
+
order = Order.create(time: nil)
|
24
|
+
assert_equal order.time, nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/tod.gemspec
CHANGED
@@ -15,7 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_development_dependency "test-unit"
|
16
16
|
s.add_development_dependency "shoulda"
|
17
17
|
s.add_development_dependency "mocha"
|
18
|
-
s.add_development_dependency "
|
18
|
+
s.add_development_dependency "tzinfo"
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "activerecord", ">= 3.0.0"
|
21
|
+
s.add_development_dependency "sqlite3"
|
19
22
|
|
20
23
|
s.files = `git ls-files`.split("\n")
|
21
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Christensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -53,19 +53,61 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: tzinfo
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activerecord
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sqlite3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description: Supplies TimeOfDay class that includes parsing, strftime, comparison,
|
70
112
|
and arithmetic.
|
71
113
|
email:
|
@@ -75,17 +117,26 @@ extensions: []
|
|
75
117
|
extra_rdoc_files: []
|
76
118
|
files:
|
77
119
|
- .gitignore
|
120
|
+
- .travis.yml
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
78
123
|
- MIT-LICENSE
|
79
124
|
- README.markdown
|
80
125
|
- Rakefile
|
126
|
+
- gemfiles/3.0.gemfile
|
127
|
+
- gemfiles/3.1.gemfile
|
128
|
+
- gemfiles/3.2.gemfile
|
129
|
+
- gemfiles/4.0.gemfile
|
81
130
|
- lib/tod.rb
|
82
131
|
- lib/tod/date.rb
|
83
132
|
- lib/tod/time.rb
|
84
133
|
- lib/tod/time_of_day.rb
|
85
134
|
- lib/tod/version.rb
|
135
|
+
- test/support/active_record.rb
|
86
136
|
- test/test_helper.rb
|
87
137
|
- test/tod/a_a_a_time_of_day_time_zone_without_active_support_test.rb
|
88
138
|
- test/tod/date_test.rb
|
139
|
+
- test/tod/time_of_day_serializable_attribute_test.rb
|
89
140
|
- test/tod/time_of_day_test.rb
|
90
141
|
- test/tod/time_of_day_time_zone_with_active_support_test.rb
|
91
142
|
- test/tod/time_test.rb
|
@@ -114,9 +165,12 @@ signing_key:
|
|
114
165
|
specification_version: 4
|
115
166
|
summary: Supplies TimeOfDay class
|
116
167
|
test_files:
|
168
|
+
- test/support/active_record.rb
|
117
169
|
- test/test_helper.rb
|
118
170
|
- test/tod/a_a_a_time_of_day_time_zone_without_active_support_test.rb
|
119
171
|
- test/tod/date_test.rb
|
172
|
+
- test/tod/time_of_day_serializable_attribute_test.rb
|
120
173
|
- test/tod/time_of_day_test.rb
|
121
174
|
- test/tod/time_of_day_time_zone_with_active_support_test.rb
|
122
175
|
- test/tod/time_test.rb
|
176
|
+
has_rdoc:
|