workhours 0.2.1 → 0.3.0

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: 6d67eead1df1869383adbbfee6573fed2b608d90
4
- data.tar.gz: 7a24c465191919e9565d5a65d43f7af9286ba565
3
+ metadata.gz: c13794a7efa155f6b58365e1ac7c55154d37eadb
4
+ data.tar.gz: dd978edda30b697364ec7702b0a9f23f9a950c1d
5
5
  SHA512:
6
- metadata.gz: e0afdb28e9b70515ba5492cbf7853bf510289d71dd119042166ee5289d5efc2b869833512d4ba505f67e61f603de1f05359784738553634d38c44257eb802de5
7
- data.tar.gz: 1a53f9dc9acb22a73a2d5ad3b11d9e6d3e1f88c91efbeacabe79f609b6ddc232e115ad08391bd4d2242ea057902efcc8bb2bab19652efd91fdd0ad85cefabb59
6
+ metadata.gz: b4ad3b956e319ec98a3feb9bfc56d86683264c64eabb7c680475383a2b8514d1146e6ea34f61112686b68dde20672f7f10e125d7299e97887d3e0b305644302d
7
+ data.tar.gz: d9076d26a16d63ca77db016ee75b6f7e6ad55324a6b7d32be362a0de17ad9eba01b5eb291eb012d5c588f38a1e73425d04c10a0768ed3a3387395f3138d6f0a2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workhours (0.2.1)
4
+ workhours (0.3.0)
5
5
  tod (~> 2.0)
6
6
 
7
7
  GEM
@@ -10,26 +10,26 @@ GEM
10
10
  diff-lcs (1.2.5)
11
11
  docile (1.1.5)
12
12
  json (1.8.3)
13
- rake (10.4.2)
14
- rspec (3.3.0)
15
- rspec-core (~> 3.3.0)
16
- rspec-expectations (~> 3.3.0)
17
- rspec-mocks (~> 3.3.0)
18
- rspec-core (3.3.1)
19
- rspec-support (~> 3.3.0)
20
- rspec-expectations (3.3.0)
13
+ rake (10.5.0)
14
+ rspec (3.4.0)
15
+ rspec-core (~> 3.4.0)
16
+ rspec-expectations (~> 3.4.0)
17
+ rspec-mocks (~> 3.4.0)
18
+ rspec-core (3.4.3)
19
+ rspec-support (~> 3.4.0)
20
+ rspec-expectations (3.4.0)
21
21
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.3.0)
23
- rspec-mocks (3.3.1)
22
+ rspec-support (~> 3.4.0)
23
+ rspec-mocks (3.4.1)
24
24
  diff-lcs (>= 1.2.0, < 2.0)
25
- rspec-support (~> 3.3.0)
26
- rspec-support (3.3.0)
27
- simplecov (0.10.0)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-support (3.4.1)
27
+ simplecov (0.11.2)
28
28
  docile (~> 1.1.0)
29
29
  json (~> 1.8)
30
30
  simplecov-html (~> 0.10.0)
31
31
  simplecov-html (0.10.0)
32
- timecop (0.7.4)
32
+ timecop (0.8.0)
33
33
  tod (2.0.2)
34
34
 
35
35
  PLATFORMS
@@ -44,4 +44,4 @@ DEPENDENCIES
44
44
  workhours!
45
45
 
46
46
  BUNDLED WITH
47
- 1.10.5
47
+ 1.11.2
@@ -1,3 +1,3 @@
1
1
  module Workhours
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -34,7 +34,11 @@ module Workhours
34
34
  beginning = Tod::TimeOfDay.parse(times[0])
35
35
  ending = Tod::TimeOfDay.parse(times[1])
36
36
  if ending < beginning
37
- [Workhours::Period.new(pr[0], times[0], "0:00"), Workhours::Period.new(Workhours.next_day(pr[0]), "0:00", times[1])]
37
+ if ending.second_of_day == 0
38
+ Workhours::Period.new(pr[0], times[0], "0:00")
39
+ else
40
+ [Workhours::Period.new(pr[0], times[0], "0:00"), Workhours::Period.new(Workhours.next_day(pr[0]), "0:00", times[1])]
41
+ end
38
42
  else
39
43
  Workhours::Period.new(pr[0], times[0], times[1])
40
44
  end
@@ -107,6 +107,30 @@ describe 'Workhours' do
107
107
  week.hours_overlap?.should eq(false)
108
108
  end
109
109
 
110
+ describe 'with closing time at 0:00' do
111
+ let(:week) { Workhours::Week.new(hours: ['mon 12:00-0:00']) }
112
+ it 'is open on monday at given hours' do
113
+ week.is_open?(Time.parse('2014-08-04 10:00')).should eq(false)
114
+ week.is_open?(Time.parse('2014-08-04 10:00')).should eq(false)
115
+ week.is_open?(Time.parse('2014-08-04 11:59')).should eq(false)
116
+ week.is_open?(Time.parse('2014-08-04 12:00')).should eq(true)
117
+ week.is_open?(Time.parse('2014-08-04 12:01')).should eq(true)
118
+ week.is_open?(Time.parse('2014-08-04 15:00')).should eq(true)
119
+ week.is_open?(Time.parse('2014-08-04 15:01')).should eq(true)
120
+ week.is_open?(Time.parse('2014-08-04 16:00')).should eq(true)
121
+ week.is_open?(Time.parse('2014-08-04 16:01')).should eq(true)
122
+ week.is_open?(Time.parse('2014-08-04 23:59')).should eq(true)
123
+ week.is_open?(Time.parse('2014-08-05 0:00')).should eq(true)
124
+ week.is_open?(Time.parse('2014-08-05 0:01')).should eq(false)
125
+ week.is_open?(Time.parse('2014-08-05 1:01')).should eq(false)
126
+ week.is_open?(Time.parse('2014-08-05 15:00')).should eq(false)
127
+ week.is_open?(Time.parse('2014-08-05 23:59')).should eq(false)
128
+ week.is_open?(Time.parse('2014-08-06 15:30')).should eq(false)
129
+ week.is_open?(Time.parse('2014-08-06 16:00')).should eq(false)
130
+ end
131
+
132
+ end
133
+
110
134
  describe 'with mon and two periods' do
111
135
  let(:week) { Workhours::Week.new(hours: ['mon 12:00-15:00', 'mon 15:00-16:00']) }
112
136
 
@@ -271,4 +295,4 @@ describe 'Workhours' do
271
295
 
272
296
  end
273
297
  end
274
- end
298
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workhours
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tod
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.4.5
142
+ rubygems_version: 2.4.5.1
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Gem to calculate buisness hours