business_hours 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/business_hours/day.rb +2 -0
- data/lib/business_hours/version.rb +1 -1
- data/lib/business_hours/week.rb +1 -1
- data/test/test_business_hours.rb +10 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 536e3b9a59f875206a64d5674c42cb42c99d2302
|
4
|
+
data.tar.gz: 1726cd657f953fdcbe831bff9f95bb270b72466e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f026d514d69af817f8afb1147bf2544f54bc402d3999ad0e1f49c62851adfa6b3306b99f04654ee924b2abc5816341aa462c69b12d7c03993fbd923c93fe544c
|
7
|
+
data.tar.gz: db6e060a2541a6794fb44bbad6c342b21be7c3d1f14761b4770186dac11a14b63af4653368622e8c896fb6ce05f1301506878011b406cc5b233cc86f2f90e74d
|
data/README.md
CHANGED
data/lib/business_hours/day.rb
CHANGED
@@ -63,6 +63,8 @@ module BusinessHours
|
|
63
63
|
open = @open_at.change(day: time.day, month: time.month, year: time.year)
|
64
64
|
close = @close_at.change(day: time.day, month: time.month, year: time.year)
|
65
65
|
|
66
|
+
close = close.change(day: close.day + 1) if open > close
|
67
|
+
|
66
68
|
result = !time.between?(open, close)
|
67
69
|
|
68
70
|
if has_breaks?
|
data/lib/business_hours/week.rb
CHANGED
@@ -21,7 +21,7 @@ module BusinessHours
|
|
21
21
|
|
22
22
|
return true if current_day.nil? or current_day.closed? # if there is no data for current day, assume that it's closed all day
|
23
23
|
|
24
|
-
current_time = Time.now
|
24
|
+
current_time = Time.zone.now
|
25
25
|
current_day.closed_at?(current_time)
|
26
26
|
end
|
27
27
|
|
data/test/test_business_hours.rb
CHANGED
@@ -84,4 +84,14 @@ class TestBusinessHours < Test::Unit::TestCase
|
|
84
84
|
|
85
85
|
def test_default_values
|
86
86
|
end
|
87
|
+
|
88
|
+
def test_with_a_next_day
|
89
|
+
hours = BusinessHours::Week.new
|
90
|
+
hours.day(Date::ABBR_DAYNAMES[Date.today.wday]) do
|
91
|
+
open_at '20:00'
|
92
|
+
close_at '01:00'
|
93
|
+
end
|
94
|
+
|
95
|
+
Timecop.travel(Time.zone.now.change(hour: 21, minutes: 00, day: Date.today.day)) { assert_equal hours.closed?, false }
|
96
|
+
end
|
87
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_hours
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kryak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,3 +138,4 @@ specification_version: 4
|
|
138
138
|
summary: Allows easily handle opening hours without take care of time zones
|
139
139
|
test_files:
|
140
140
|
- test/test_business_hours.rb
|
141
|
+
has_rdoc:
|