tod 3.1.0 → 3.1.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 +5 -0
- data/Gemfile.lock +17 -17
- data/README.markdown +14 -2
- data/lib/tod/shift.rb +2 -2
- data/lib/tod/time_of_day_type.rb +1 -1
- data/lib/tod/version.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/tod/shift_test.rb +14 -0
- data/test/tod/time_of_day_attribute_test.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abbaa919b6c5095de1d85a9e4db5da1160d4d80038515366502c2144d007b75
|
4
|
+
data.tar.gz: 87106d404f688c2ba9997b18874172440f34f7bcacfe35f41c693309693c7654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a890e3dc2b7aee24401388d8d85214c01e0f730c0547a61f7c46d9a097dce842fccf2a43836d46e52af3eba87f1df2c9aa2bd13fe6f10f5e780b085e43b9741d
|
7
|
+
data.tar.gz: f6bdb357ba0c50aaba4b30f84038378a5418112776452832b2bfa8a53313975c88ca7caea2cdc8f4701acc7206b55dab19dfd08a3eb32214e3cf53f0fa771760
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,35 +6,35 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activemodel (
|
10
|
-
activesupport (=
|
11
|
-
activerecord (
|
12
|
-
activemodel (=
|
13
|
-
activesupport (=
|
14
|
-
activesupport (
|
9
|
+
activemodel (7.0.5)
|
10
|
+
activesupport (= 7.0.5)
|
11
|
+
activerecord (7.0.5)
|
12
|
+
activemodel (= 7.0.5)
|
13
|
+
activesupport (= 7.0.5)
|
14
|
+
activesupport (7.0.5)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
18
18
|
tzinfo (~> 2.0)
|
19
|
-
zeitwerk (~> 2.3)
|
20
19
|
byebug (11.1.3)
|
21
20
|
coderay (1.1.3)
|
22
|
-
concurrent-ruby (1.
|
23
|
-
i18n (1.
|
21
|
+
concurrent-ruby (1.2.2)
|
22
|
+
i18n (1.14.1)
|
24
23
|
concurrent-ruby (~> 1.0)
|
25
24
|
method_source (1.0.0)
|
26
|
-
|
27
|
-
|
25
|
+
mini_portile2 (2.8.2)
|
26
|
+
minitest (5.18.0)
|
27
|
+
pry (0.14.2)
|
28
28
|
coderay (~> 1.1)
|
29
29
|
method_source (~> 1.0)
|
30
|
-
pry-byebug (3.
|
30
|
+
pry-byebug (3.10.1)
|
31
31
|
byebug (~> 11.0)
|
32
|
-
pry (
|
33
|
-
rake (13.0.
|
34
|
-
sqlite3 (1.
|
35
|
-
|
32
|
+
pry (>= 0.13, < 0.15)
|
33
|
+
rake (13.0.6)
|
34
|
+
sqlite3 (1.6.3)
|
35
|
+
mini_portile2 (~> 2.8.0)
|
36
|
+
tzinfo (2.0.6)
|
36
37
|
concurrent-ruby (~> 1.0)
|
37
|
-
zeitwerk (2.4.2)
|
38
38
|
|
39
39
|
PLATFORMS
|
40
40
|
ruby
|
data/README.markdown
CHANGED
@@ -201,8 +201,8 @@ Overlaps?
|
|
201
201
|
|
202
202
|
Contains?
|
203
203
|
--------------------
|
204
|
-
workday = Shift.new(TimeOfDay.new(9), TimeOfDay.new(17))
|
205
|
-
lunch = Shift.new(TimeOfDay.new(10), TimeOfDay.new(14))
|
204
|
+
workday = Tod::Shift.new(Tod::TimeOfDay.new(9), Tod::TimeOfDay.new(17))
|
205
|
+
lunch = Tod::Shift.new(Tod::TimeOfDay.new(10), Tod::TimeOfDay.new(14))
|
206
206
|
workday.contains?(lunch) # => true
|
207
207
|
lunch.contains?(workday) # => false
|
208
208
|
|
@@ -244,6 +244,18 @@ order = Order.create(time: Tod::TimeOfDay.new(9,30))
|
|
244
244
|
order.time # => 09:30:00
|
245
245
|
```
|
246
246
|
|
247
|
+
In Rails, this can be used with `time_select` in forms like so:
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
f.time_select :time, ignore_date: true
|
251
|
+
```
|
252
|
+
|
253
|
+
Or with **simple_form**:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
f.input :time, as: :time, ignore_date: true
|
257
|
+
```
|
258
|
+
|
247
259
|
MongoDB Support
|
248
260
|
===============
|
249
261
|
|
data/lib/tod/shift.rb
CHANGED
data/lib/tod/time_of_day_type.rb
CHANGED
@@ -4,7 +4,7 @@ module Tod
|
|
4
4
|
if value.is_a? Hash
|
5
5
|
# rails multiparam attribute
|
6
6
|
# get hour, minute and second and construct new TimeOfDay object
|
7
|
-
::Tod::TimeOfDay.new(value[4], value[5], value[6])
|
7
|
+
::Tod::TimeOfDay.new(value[4], value[5], value[6] || 0)
|
8
8
|
else
|
9
9
|
# return nil, if input is not parsable
|
10
10
|
Tod::TimeOfDay(value){}
|
data/lib/tod/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/tod/shift_test.rb
CHANGED
@@ -295,6 +295,13 @@ describe "Shift" do
|
|
295
295
|
shift2 = Tod::Shift.new tod1, tod2, true
|
296
296
|
assert !(shift1 == shift2)
|
297
297
|
end
|
298
|
+
|
299
|
+
it "is false when one side is nil" do
|
300
|
+
tod1 = Tod::TimeOfDay.new 8,30
|
301
|
+
tod2 = Tod::TimeOfDay.new 13,00,30
|
302
|
+
shift = Tod::Shift.new tod1, tod2
|
303
|
+
assert !(shift == nil)
|
304
|
+
end
|
298
305
|
end
|
299
306
|
|
300
307
|
describe "#eql?" do
|
@@ -329,6 +336,13 @@ describe "Shift" do
|
|
329
336
|
shift2 = Tod::Shift.new tod1, tod2, true
|
330
337
|
assert !shift1.eql?(shift2)
|
331
338
|
end
|
339
|
+
|
340
|
+
it "is false when one side is nil" do
|
341
|
+
tod1 = Tod::TimeOfDay.new 8,30
|
342
|
+
tod2 = Tod::TimeOfDay.new 13,00,30
|
343
|
+
shift = Tod::Shift.new tod1, tod2
|
344
|
+
assert !shift.eql?(nil )
|
345
|
+
end
|
332
346
|
end
|
333
347
|
|
334
348
|
describe "#hash" do
|
@@ -24,6 +24,11 @@ describe "TimeOfDay with ActiveRecord Attribute" do
|
|
24
24
|
assert_equal Tod::TimeOfDay.new(8,6,5), order.time
|
25
25
|
end
|
26
26
|
|
27
|
+
it "works with multiparam time arguments without seconds" do
|
28
|
+
order = Order.create!({"time(4i)" => "8", "time(5i)" => "6"})
|
29
|
+
assert_equal Tod::TimeOfDay.new(8,6,0), order.time
|
30
|
+
end
|
31
|
+
|
27
32
|
it "should not raise Exception on access of unparsable values" do
|
28
33
|
order = Order.new(time: 'unparsable')
|
29
34
|
order.time
|
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: 3.1.
|
4
|
+
version: 3.1.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:
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
153
|
+
rubygems_version: 3.4.1
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Supplies TimeOfDay and Shift class
|