workhours 0.0.2 → 0.1.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: 321ca35606fb53de420ed25f34736e0f7aca8a32
4
- data.tar.gz: 84e19844cdb9972de08e95adfc9e4de2181cd7ea
3
+ metadata.gz: 4afcc2a48122262799dcb7e26fdc3eb35b14bb9f
4
+ data.tar.gz: cacbd1f4c452697d860d3bdb39e48707eb3f0910
5
5
  SHA512:
6
- metadata.gz: e840d6d85afb9756f36f14f421a54018ffe11ecf5326f4c5048b460c9eeb71306ebd4bf032f89b8adff7a2de6db91887174bbb503fa486dbf3397d324bd790df
7
- data.tar.gz: 7d5a03f720181891a80913a5ef3dab1dae890c0adbef8bbf57d1de4c3a455e30659e0ab41702c2d89cf40296b8e052dc12f1246cd030f6ab637b95fabc01137f
6
+ metadata.gz: d08055ca91f5ebd065f653fa153fe9cdcc9779591e496af743a257e21fae6b8eef038fee6426206599143f399c9f36936ba25ab569a32bd7d828ca3f7d9e1280
7
+ data.tar.gz: 25e9d25e4e0406f3a70c5eb34d1d2f063b3da5b3cbc6c819158901ba3fe2d5331d34ae375d515be1888c2b44cdd5bad7678ee6abf3d89075c3e2b2d30a0b51ce
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.1.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workhours (0.0.2)
4
+ workhours (0.1.0)
5
5
  tod
6
6
 
7
7
  GEM
@@ -9,27 +9,28 @@ GEM
9
9
  specs:
10
10
  diff-lcs (1.2.5)
11
11
  docile (1.1.5)
12
- multi_json (1.10.1)
13
- rake (10.3.2)
14
- rspec (3.0.0)
15
- rspec-core (~> 3.0.0)
16
- rspec-expectations (~> 3.0.0)
17
- rspec-mocks (~> 3.0.0)
18
- rspec-core (3.0.3)
19
- rspec-support (~> 3.0.0)
20
- rspec-expectations (3.0.3)
12
+ json (1.8.2)
13
+ rake (10.4.2)
14
+ rspec (3.2.0)
15
+ rspec-core (~> 3.2.0)
16
+ rspec-expectations (~> 3.2.0)
17
+ rspec-mocks (~> 3.2.0)
18
+ rspec-core (3.2.3)
19
+ rspec-support (~> 3.2.0)
20
+ rspec-expectations (3.2.1)
21
21
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.0.0)
23
- rspec-mocks (3.0.3)
24
- rspec-support (~> 3.0.0)
25
- rspec-support (3.0.3)
26
- simplecov (0.9.0)
22
+ rspec-support (~> 3.2.0)
23
+ rspec-mocks (3.2.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.2.0)
26
+ rspec-support (3.2.2)
27
+ simplecov (0.10.0)
27
28
  docile (~> 1.1.0)
28
- multi_json
29
- simplecov-html (~> 0.8.0)
30
- simplecov-html (0.8.0)
31
- timecop (0.7.1)
32
- tod (1.4.0)
29
+ json (~> 1.8)
30
+ simplecov-html (~> 0.10.0)
31
+ simplecov-html (0.10.0)
32
+ timecop (0.7.3)
33
+ tod (2.0.0)
33
34
 
34
35
  PLATFORMS
35
36
  ruby
@@ -16,6 +16,7 @@ module Workhours
16
16
  end
17
17
 
18
18
  def is_inside_range?(tod)
19
+ return true if shift.beginning.second_of_day == 0 && shift.ending.second_of_day == 0
19
20
  shift.include?(tod)
20
21
  end
21
22
 
@@ -56,7 +57,8 @@ module Workhours
56
57
  else
57
58
  if tod.second_of_day == 0 && ending.second_of_day == 0 && is_tomorrow?(time)
58
59
  # 10:00-0:00 is active on 0:00 of next day
59
- true
60
+ # 00:00-0:00 is NOT active on 0:00 of next day
61
+ beginning.second_of_day != 0
60
62
  else
61
63
  false
62
64
  end
@@ -1,3 +1,3 @@
1
1
  module Workhours
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -184,7 +184,6 @@ describe 'Workhours' do
184
184
  week.is_open?(Time.parse('2014-08-04 0:00')).should eq(false)
185
185
  week.is_open?(Time.parse('2014-08-04 12:00')).should eq(true)
186
186
  week.is_open?(Time.parse('2014-08-04 12:01')).should eq(true)
187
- week.is_open?(Time.parse('2014-08-04 12:01')).should eq(true)
188
187
  week.is_open?(Time.parse('2014-08-04 23:00')).should eq(true)
189
188
  week.is_open?(Time.parse('2014-08-05 00:00')).should eq(true)
190
189
  week.is_open?(Time.parse('2014-08-05 03:00')).should eq(true)
@@ -206,6 +205,37 @@ describe 'Workhours' do
206
205
  end
207
206
  end
208
207
 
208
+
209
+ describe 'whole the day' do
210
+ let(:week) { Workhours::Week.new(hours: ['mon 00:00-00:00']) }
211
+
212
+ it '#is_open?' do
213
+ week.is_open?(Time.parse('2014-08-03 10:00')).should eq(false)
214
+ week.is_open?(Time.parse('2014-08-04 00:00')).should eq(true)
215
+ week.is_open?(Time.parse('2014-08-04 12:00')).should eq(true)
216
+ week.is_open?(Time.parse('2014-08-04 12:01')).should eq(true)
217
+ week.is_open?(Time.parse('2014-08-04 23:00')).should eq(true)
218
+ week.is_open?(Time.parse('2014-08-05 00:00')).should eq(false)
219
+ week.is_open?(Time.parse('2014-08-05 03:00')).should eq(false)
220
+ week.is_open?(Time.parse('2014-08-05 04:00')).should eq(false)
221
+ week.is_open?(Time.parse('2014-08-05 04:01')).should eq(false)
222
+ end
223
+
224
+ it '#opens_at' do
225
+ week.opens_at(Time.parse('2014-08-03 10:00')).should eq(Time.parse('2014-08-04 00:00'))
226
+ week.opens_at(Time.parse('2014-08-04 00:00')).should be_nil
227
+ week.opens_at(Time.parse('2014-08-04 16:00')).should be_nil
228
+ week.opens_at(Time.parse('2014-08-04 23:00')).should be_nil
229
+ week.opens_at(Time.parse('2014-08-05 00:00')).should eq(Time.parse('2014-08-11 00:00'))
230
+ week.opens_at(Time.parse('2014-08-05 10:00')).should eq(Time.parse('2014-08-11 00:00'))
231
+ end
232
+
233
+ it '#closes_at' do
234
+ week.closes_at(Time.parse('2014-08-04 14:00')).should eq(Time.parse('2014-08-05 00:00'))
235
+ week.closes_at(Time.parse('2014-08-05 10:00')).should be_nil
236
+ end
237
+ end
238
+
209
239
  it 'fails with no hours' do
210
240
  expect { Workhours::Week.new(week: []) }.to raise_error(Workhours::NoHoursError)
211
241
  end
@@ -231,5 +261,4 @@ describe 'Workhours' do
231
261
  })
232
262
  end
233
263
  end
234
- end
235
-
264
+ 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.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tod
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
+ - ".rspec"
105
106
  - ".ruby-gemset"
106
107
  - ".ruby-version"
107
108
  - ".travis.yml"
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.2.2
142
+ rubygems_version: 2.4.5
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: Gem to calculate buisness hours