workhours 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +21 -20
- data/lib/workhours/period.rb +3 -1
- data/lib/workhours/version.rb +1 -1
- data/spec/workhours_spec.rb +32 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4afcc2a48122262799dcb7e26fdc3eb35b14bb9f
|
4
|
+
data.tar.gz: cacbd1f4c452697d860d3bdb39e48707eb3f0910
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d08055ca91f5ebd065f653fa153fe9cdcc9779591e496af743a257e21fae6b8eef038fee6426206599143f399c9f36936ba25ab569a32bd7d828ca3f7d9e1280
|
7
|
+
data.tar.gz: 25e9d25e4e0406f3a70c5eb34d1d2f063b3da5b3cbc6c819158901ba3fe2d5331d34ae375d515be1888c2b44cdd5bad7678ee6abf3d89075c3e2b2d30a0b51ce
|
data/.rspec
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
workhours (0.0
|
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
|
-
|
13
|
-
rake (10.
|
14
|
-
rspec (3.
|
15
|
-
rspec-core (~> 3.
|
16
|
-
rspec-expectations (~> 3.
|
17
|
-
rspec-mocks (~> 3.
|
18
|
-
rspec-core (3.
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-expectations (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.
|
23
|
-
rspec-mocks (3.
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
simplecov-html (~> 0.
|
30
|
-
simplecov-html (0.
|
31
|
-
timecop (0.7.
|
32
|
-
tod (
|
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
|
data/lib/workhours/period.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/workhours/version.rb
CHANGED
data/spec/workhours_spec.rb
CHANGED
@@ -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
|
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:
|
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.
|
142
|
+
rubygems_version: 2.4.5
|
142
143
|
signing_key:
|
143
144
|
specification_version: 4
|
144
145
|
summary: Gem to calculate buisness hours
|