time_until_break 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/time_until_break +1 -1
- data/lib/time_until_break/version.rb +1 -1
- data/lib/time_until_break.rb +14 -2
- data/spec/time_until_break_spec.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e15dbc1f2395361fc9a3b20734d72c9cc08ef7e1
|
4
|
+
data.tar.gz: 209cd9860c8e5855eafcaa56ebb7b0c539a885ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baee29464232487b9999f4ecfa775dec9cc6fb2d7c33f995aa9ad23555def591cb57813cb50b463f7624d23a140bf23b8508a4e86ab2adca7da78042bc9311cc
|
7
|
+
data.tar.gz: 07789e2d383c2004f23bd43a5d1cbe8e6ed77cd02e626e8bbbd05fda97de0df1c7b60c30727aed800c4369d31123875464e392e926aa67989e6f5e6b4c224fd6
|
data/bin/time_until_break
CHANGED
data/lib/time_until_break.rb
CHANGED
@@ -9,15 +9,19 @@ class TimeUntilBreak
|
|
9
9
|
@break_time = Time.parse(break_time)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def is_a_weekday
|
13
13
|
has_break_been? ? missed_break : time_until_break
|
14
14
|
end
|
15
15
|
|
16
|
+
def is_a_weekend
|
17
|
+
say_something("It's the weekend you silly billy.")
|
18
|
+
end
|
19
|
+
|
16
20
|
def time_until_break
|
17
21
|
seconds = @break_time.to_i - current_time.to_i
|
18
22
|
hours = (seconds/(60*60))
|
19
23
|
minutes = ((seconds - (hours*60*60))/60)
|
20
|
-
say_something("#{hours} hours, #{minutes} minutes")
|
24
|
+
say_something("#{hours} hours, #{minutes} minutes until the Mandatory Break.")
|
21
25
|
end
|
22
26
|
|
23
27
|
def has_break_been?
|
@@ -35,4 +39,12 @@ class TimeUntilBreak
|
|
35
39
|
def say_something(string)
|
36
40
|
%x(say "#{string}")
|
37
41
|
end
|
42
|
+
|
43
|
+
def is_it_the_weekend?
|
44
|
+
["Saturday", "Sunday"].include?(current_time.strftime("%A"))
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_me
|
48
|
+
is_it_the_weekend? ? is_a_weekend : is_a_weekday
|
49
|
+
end
|
38
50
|
end
|
@@ -29,8 +29,18 @@ describe TimeUntilBreak do
|
|
29
29
|
|
30
30
|
it 'can calculate how long until the next break in hours and minutes' do
|
31
31
|
Delorean.time_travel_to(Time.utc(2014,11,17,10,36))
|
32
|
-
expect(time).to receive(:`).with('say "6 hours, 9 minutes"')
|
32
|
+
expect(time).to receive(:`).with('say "6 hours, 9 minutes until the Mandatory Break."')
|
33
33
|
time.message
|
34
34
|
end
|
35
35
|
|
36
|
+
it 'knows if it is not the weekend' do
|
37
|
+
Delorean.time_travel_to(Time.utc(2014,11,21,10,36))
|
38
|
+
expect(time.is_it_the_weekend?).to be false
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'knows if it is the weekend' do
|
42
|
+
Delorean.time_travel_to(Time.utc(2014,11,22,10,36))
|
43
|
+
expect(time.is_it_the_weekend?).to be true
|
44
|
+
end
|
45
|
+
|
36
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_until_break
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Giles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|