tod 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +9 -1
- data/lib/tod/conversions.rb +4 -0
- data/lib/tod/version.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/tod/conversion_test.rb +32 -0
- data/tod.gemspec +1 -0
- metadata +26 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e1df7c0f812d7e18d6d9b10c256f2e26e63268c
|
4
|
+
data.tar.gz: f01a512e048fa9087ab1b89376a2f6a49574357f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf81e8e52153b7e894d0a970a88c6da2fe94dbabf984cd289be160b7ab1eb43ce78e6c991c0f833ac25ebc818a7950deae44d19610a1f66081ba1998dae3bbd3
|
7
|
+
data.tar.gz: d6665499e05b78076fab42c5dfe4b67c94750ad71fc722384f51b7c97aad9b6fc78fc3b2e9906d3af273f66c769bdd73bce956cb206f7a4b63209cd8237d43d0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tod (
|
4
|
+
tod (2.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -21,10 +21,17 @@ GEM
|
|
21
21
|
tzinfo (~> 1.1)
|
22
22
|
arel (6.0.0)
|
23
23
|
builder (3.2.2)
|
24
|
+
coderay (1.1.0)
|
24
25
|
i18n (0.7.0)
|
25
26
|
json (1.8.2)
|
27
|
+
method_source (0.8.2)
|
26
28
|
minitest (5.5.1)
|
29
|
+
pry (0.10.1)
|
30
|
+
coderay (~> 1.1.0)
|
31
|
+
method_source (~> 0.8.1)
|
32
|
+
slop (~> 3.4)
|
27
33
|
rake (10.4.2)
|
34
|
+
slop (3.6.0)
|
28
35
|
sqlite3 (1.3.10)
|
29
36
|
thread_safe (0.3.4)
|
30
37
|
tzinfo (1.2.2)
|
@@ -36,6 +43,7 @@ PLATFORMS
|
|
36
43
|
DEPENDENCIES
|
37
44
|
activerecord (>= 3.0.0)
|
38
45
|
minitest
|
46
|
+
pry
|
39
47
|
rake
|
40
48
|
sqlite3
|
41
49
|
tod!
|
data/lib/tod/conversions.rb
CHANGED
@@ -4,6 +4,10 @@ module Tod
|
|
4
4
|
obj_or_string
|
5
5
|
elsif obj_or_string.respond_to?(:to_time_of_day)
|
6
6
|
obj_or_string.to_time_of_day
|
7
|
+
elsif obj_or_string.respond_to?(:hour) && obj_or_string.respond_to?(:min) && obj_or_string.respond_to?(:sec)
|
8
|
+
TimeOfDay.new obj_or_string.hour, obj_or_string.min, obj_or_string.sec
|
9
|
+
elsif obj_or_string.is_a?(Date)
|
10
|
+
TimeOfDay.new 0
|
7
11
|
else
|
8
12
|
TimeOfDay.parse(obj_or_string)
|
9
13
|
end
|
data/lib/tod/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/tod/conversion_test.rb
CHANGED
@@ -29,6 +29,38 @@ describe "TimeOfDay()" do
|
|
29
29
|
assert_equal(tod, Tod::TimeOfDay.new(12, 01, 02))
|
30
30
|
end
|
31
31
|
|
32
|
+
describe "without core extensions" do
|
33
|
+
it "handles Time" do
|
34
|
+
t = Time.new(2014, 2, 27, 12, 01, 02)
|
35
|
+
class <<t
|
36
|
+
undef_method(:to_time_of_day)
|
37
|
+
end
|
38
|
+
tod = Tod::TimeOfDay(t)
|
39
|
+
|
40
|
+
assert_equal(tod, Tod::TimeOfDay.new(12, 01, 02))
|
41
|
+
end
|
42
|
+
|
43
|
+
it "handles Date" do
|
44
|
+
t = Date.new(2014, 2, 27)
|
45
|
+
class <<t
|
46
|
+
undef_method(:to_time_of_day)
|
47
|
+
end
|
48
|
+
tod = Tod::TimeOfDay(t)
|
49
|
+
|
50
|
+
assert_equal(tod, Tod::TimeOfDay.new(0, 0, 0))
|
51
|
+
end
|
52
|
+
|
53
|
+
it "handles DateTime" do
|
54
|
+
t = DateTime.new(2014, 2, 27, 12, 01, 02)
|
55
|
+
class <<t
|
56
|
+
undef_method(:to_time_of_day)
|
57
|
+
end
|
58
|
+
tod = Tod::TimeOfDay(t)
|
59
|
+
|
60
|
+
assert_equal(tod, Tod::TimeOfDay.new(12, 01, 02))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
32
64
|
it "parses string" do
|
33
65
|
t = "12:01:02"
|
34
66
|
tod = Tod::TimeOfDay(t)
|
data/tod.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_development_dependency "rake"
|
19
19
|
s.add_development_dependency "activerecord", ">= 3.0.0"
|
20
20
|
s.add_development_dependency "sqlite3"
|
21
|
+
s.add_development_dependency "pry"
|
21
22
|
|
22
23
|
s.files = `git ls-files`.split("\n")
|
23
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: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Christensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Supplies TimeOfDay and Shift class that includes parsing, strftime, comparison,
|
84
98
|
and arithmetic.
|
85
99
|
email:
|
@@ -143,4 +157,13 @@ rubygems_version: 2.4.5
|
|
143
157
|
signing_key:
|
144
158
|
specification_version: 4
|
145
159
|
summary: Supplies TimeOfDay and Shift class
|
146
|
-
test_files:
|
160
|
+
test_files:
|
161
|
+
- test/support/active_record.rb
|
162
|
+
- test/test_helper.rb
|
163
|
+
- test/tod/conversion_test.rb
|
164
|
+
- test/tod/date_test.rb
|
165
|
+
- test/tod/shift_test.rb
|
166
|
+
- test/tod/time_of_day_serializable_attribute_test.rb
|
167
|
+
- test/tod/time_of_day_test.rb
|
168
|
+
- test/tod/time_of_day_time_zone_with_active_support_test.rb
|
169
|
+
- test/tod/time_test.rb
|