time_clock 0.0.8 → 0.0.9
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/README.md +5 -0
- data/lib/time_clock/version.rb +1 -1
- data/spec/lib/time_clock/comparison_spec.rb +7 -1
- data/spec/lib/time_clock/core_ext/time_spec.rb +3 -3
- data/spec/lib/time_clock/shift_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7f53e39fd6b0983fb1ef1160404c5b62f8f4579
|
4
|
+
data.tar.gz: f605aae5a633817add00a0dea3d9f10809495235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0958f60c49ddfaa9a32f44847ca5a039998e0298b84fa1767843f72f7781fb8da78420c64d1f95fbed3c7a6e2b31b42a0f4fe0e38e8fbae52565aeeddc88ba
|
7
|
+
data.tar.gz: 911952184951a469b02cde5ccbdc3df29de5fd4994b6b14ace64507882b19d8afd9602b151fbe8c07d98350395ac99a5388287a5a671dd6b912c662a161a44e1
|
data/README.md
CHANGED
@@ -13,6 +13,11 @@ Once you've set a default calendar, any `Time` instance will have a few helpful
|
|
13
13
|
Time.now.business_hours_until(Time.now + 1.day)
|
14
14
|
=> 12
|
15
15
|
|
16
|
+
Also, `Date` and `Time` instances will have a method that calculates how many work dates there are between two times or dates.
|
17
|
+
|
18
|
+
Date.today.business_days_until(Date.today)
|
19
|
+
=> 1
|
20
|
+
|
16
21
|
You can also make custom calendars for each calculation (see Calendars section for details).
|
17
22
|
|
18
23
|
**Things you may like about this library:**
|
data/lib/time_clock/version.rb
CHANGED
@@ -36,10 +36,16 @@ module TimeClock
|
|
36
36
|
end
|
37
37
|
|
38
38
|
context "when there is no default calendar and none is provided" do
|
39
|
+
before do
|
40
|
+
@old_default_calendar = TimeClock.default_calendar
|
41
|
+
TimeClock.default_calendar = nil
|
42
|
+
end
|
39
43
|
it "should raise an error on initialization" do
|
40
|
-
TimeClock.stub(:default_calendar) { nil }
|
41
44
|
expect{described_class.new(start_time, end_time)}.to raise_error Comparison::NilCalendarError
|
42
45
|
end
|
46
|
+
after do
|
47
|
+
TimeClock.default_calendar = @old_default_calendar
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
51
|
context "when calculating seconds between" do
|
@@ -11,13 +11,13 @@ describe Time do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should calculate business minutes until" do
|
14
|
-
Time.
|
14
|
+
expect_any_instance_of(Time).to receive(:business_seconds_until).and_return(60)
|
15
15
|
expect(subject.business_minutes_until(end_time)).to eq 1
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should calculate business hours until" do
|
19
|
-
Time.
|
19
|
+
expect_any_instance_of(Time).to receive(:business_seconds_until).and_return(3500)
|
20
20
|
expect(subject.business_hours_until(end_time)).to eq 1
|
21
21
|
end
|
22
22
|
|
23
|
-
end
|
23
|
+
end
|
@@ -30,10 +30,10 @@ module TimeClock
|
|
30
30
|
let(:overlapping_shift) { Shift.new(Time.new(2013,8,19,5), Time.new(2013,8,19,10)) }
|
31
31
|
let(:non_overlapping_shift) { Shift.new(Time.new(2013,8,18,5), Time.new(2013,8,18,10)) }
|
32
32
|
it "should know when it does" do
|
33
|
-
expect(overlapping_shift.overlaps?(subject)).to
|
33
|
+
expect(overlapping_shift.overlaps?(subject)).to eq true
|
34
34
|
end
|
35
35
|
it "should know when it doesn't" do
|
36
|
-
expect(non_overlapping_shift.overlaps?(subject)).to_not
|
36
|
+
expect(non_overlapping_shift.overlaps?(subject)).to_not eq true
|
37
37
|
end
|
38
38
|
it "should calculate the overlapping seconds when there is an overlap" do
|
39
39
|
expect(overlapping_shift.overlapping_seconds(subject)).to eq 4 * 60 * 60
|
@@ -45,4 +45,4 @@ module TimeClock
|
|
45
45
|
|
46
46
|
|
47
47
|
end
|
48
|
-
end
|
48
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_clock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- barelyknown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.4.5
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: Calculate the business time for a period of time.
|