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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e44aea9efb82d12de3027199cbab0a350208b3d6
4
- data.tar.gz: 04d9092b23ef31966f447e945f907a1b14216d6d
3
+ metadata.gz: 536e3b9a59f875206a64d5674c42cb42c99d2302
4
+ data.tar.gz: 1726cd657f953fdcbe831bff9f95bb270b72466e
5
5
  SHA512:
6
- metadata.gz: 39ac0bf45a06e90e443b3c12e8e47c7b3c53dd82510a0a12ff84981f380e31be7ff682654368f9e8a80f028894f3266f25b0fbf02aeb1c99532248897e4e7564
7
- data.tar.gz: 3a93ced6470b42334f2a63a1dc849ecd2b744839b6ff55ccc10bc6d91d23acc224f026dcb71f53add00fe835fbed1040c3e95be1762da8f529fbe71314893953
6
+ metadata.gz: f026d514d69af817f8afb1147bf2544f54bc402d3999ad0e1f49c62851adfa6b3306b99f04654ee924b2abc5816341aa462c69b12d7c03993fbd923c93fe544c
7
+ data.tar.gz: db6e060a2541a6794fb44bbad6c342b21be7c3d1f14761b4770186dac11a14b63af4653368622e8c896fb6ce05f1301506878011b406cc5b233cc86f2f90e74d
data/README.md CHANGED
@@ -36,7 +36,7 @@ or you can use abbreviation for day name:
36
36
 
37
37
  If there is no information about a day, then we assume that it's closed. Or you can mark day as closed with:
38
38
 
39
- business_hours.days(1) do
39
+ business_hours.day(1) do
40
40
  closed!
41
41
  end
42
42
 
@@ -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?
@@ -1,3 +1,3 @@
1
1
  module BusinessHours
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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
 
@@ -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.1
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: 2013-11-25 00:00:00.000000000 Z
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: