timecrunch 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cda5feabf774620724c70da507fd770500602da0
4
- data.tar.gz: 8a4a9e8296adf28759287a1a6f9ae3d404a87ecf
3
+ metadata.gz: e17b40eee0c7fb33bd24f4436f3b96993f7ea5d7
4
+ data.tar.gz: 65ef081ded359d4de5759173321e910c347037dc
5
5
  SHA512:
6
- metadata.gz: 740edf14283e3b7cb2c519eb0b5e7080bbaa5873649e34dc660ef02ff2e7164946b095e9c6a7b47347bcd1535127cb85b6f4c51bd0e71abef5d79e7dd01e7303
7
- data.tar.gz: 0e98920c4aa6b5b251b36acb2d87785ae69d542a79841ab008926e52057e309fc3ca6964ab67b3df599bdc70fc4f445d198c28234f89acef1ec01b1a7cc15379
6
+ metadata.gz: 3c55c321ca80dac2c6acd99273a1e814036f10d6e306b7bceebec46b16c5bacefc4682a910faa4b27964223c8d4802c9ef85dc61341a41d64d3183d1da328314
7
+ data.tar.gz: 773ecae2c960eafb504db058b9798f51990b617da07d0f4201f87bcfd74ce57c22b59202e988185d6c44b85ae24dca2a31862e4f57b9dd1339850bd13c672adc
@@ -3,6 +3,7 @@ require "timecrunch/timer"
3
3
  require "timecrunch/cli"
4
4
  require "timecrunch/notifiers/console"
5
5
  require "timecrunch/notifiers/notification_center"
6
+ require "timecrunch/notifiers/beep"
6
7
 
7
8
  module Timecrunch
8
9
  end
@@ -6,12 +6,14 @@ module Timecrunch
6
6
  desc "start MINUTES", "Starts a new timer for MINUTES"
7
7
  option :s, :banner => "seconds"
8
8
  option :growl, :type => :boolean, :banner => "notification center"
9
+ option :beep, :type => :boolean, :banner => "beep when timer is done"
9
10
  def start(minutes=0)
10
11
  seconds = options[:s].nil? ? 0 : options[:s].to_i
11
12
  minutes = minutes.to_i
12
13
  timer = Timer.new(minutes: minutes, seconds: seconds)
13
14
  timer.notifiers << Notifiers::Console.new
14
15
  timer.notifiers << Notifiers::NotificationCenter.new if options[:growl]
16
+ timer.notifiers << Notifiers::Beep.new if options[:beep]
15
17
  timer.start!
16
18
  end
17
19
  end
@@ -0,0 +1,9 @@
1
+ module Timecrunch
2
+ module Notifiers
3
+ class Beep
4
+ def notify!
5
+ print "\a"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Timecrunch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -22,18 +22,33 @@ describe "CLI" do
22
22
  end
23
23
  end
24
24
 
25
- context "when the growl command is added" do
26
- it "should send a console notification and a growl notification" do
27
- timer = instance_double("Timer", notifiers: [])
28
- console = double()
29
- growl = double()
25
+ describe "specifying notifiers" do
26
+ let(:timer) { instance_double("Timer", notifiers: []) }
27
+ let(:console) { double() }
28
+ let(:notifier) { double() }
29
+
30
+ before do
30
31
  allow(Timecrunch::Notifiers::Console).to receive(:new) { console }
31
- allow(Timecrunch::Notifiers::NotificationCenter).to receive(:new) { growl }
32
32
  expect(Timecrunch::Timer).to receive(:new) { timer }
33
-
34
33
  expect(timer).to receive(:start!)
35
- Timecrunch::CLI.start(["start", "--growl"])
36
- expect(timer.notifiers).to eq [console, growl]
34
+ end
35
+
36
+ context "when the growl command is added" do
37
+ it "should send a console notification and a growl notification" do
38
+ allow(Timecrunch::Notifiers::NotificationCenter).to receive(:new) {
39
+ notifier
40
+ }
41
+ Timecrunch::CLI.start(["start", "--growl"])
42
+ expect(timer.notifiers).to eq [console, notifier]
43
+ end
44
+ end
45
+
46
+ context "when the beep command is added" do
47
+ it "should send a console notification and beep" do
48
+ allow(Timecrunch::Notifiers::Beep).to receive(:new) { notifier }
49
+ Timecrunch::CLI.start(["start", "--beep"])
50
+ expect(timer.notifiers).to eq [console, notifier]
51
+ end
37
52
  end
38
53
  end
39
54
  end
@@ -0,0 +1,15 @@
1
+ require 'timecrunch'
2
+
3
+ describe Timecrunch::Notifiers::Beep do
4
+ describe "#notify!" do
5
+ before do
6
+ $stdout = StringIO.new
7
+ end
8
+
9
+ it "should display output" do
10
+ notifier = Timecrunch::Notifiers::Beep.new
11
+ notifier.notify!
12
+ expect($stdout.string).to match("\a")
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timecrunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Keathley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2014-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -103,11 +103,13 @@ files:
103
103
  - bin/tc
104
104
  - lib/timecrunch.rb
105
105
  - lib/timecrunch/cli.rb
106
+ - lib/timecrunch/notifiers/beep.rb
106
107
  - lib/timecrunch/notifiers/console.rb
107
108
  - lib/timecrunch/notifiers/notification_center.rb
108
109
  - lib/timecrunch/timer.rb
109
110
  - lib/timecrunch/version.rb
110
111
  - spec/integration/cli_spec.rb
112
+ - spec/notifiers/beep_spec.rb
111
113
  - spec/notifiers/console_spec.rb
112
114
  - spec/notifiers/notification_center_spec.rb
113
115
  - spec/timer_spec.rb
@@ -138,6 +140,7 @@ specification_version: 4
138
140
  summary: A timer for timing things that need timing
139
141
  test_files:
140
142
  - spec/integration/cli_spec.rb
143
+ - spec/notifiers/beep_spec.rb
141
144
  - spec/notifiers/console_spec.rb
142
145
  - spec/notifiers/notification_center_spec.rb
143
146
  - spec/timer_spec.rb