timecrunch 0.0.1 → 0.0.2
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 +6 -3
- data/lib/timecrunch/cli.rb +9 -2
- data/lib/timecrunch/notifiers/{console_notifier.rb → console.rb} +1 -1
- data/lib/timecrunch/notifiers/notification_center.rb +11 -0
- data/lib/timecrunch/timer.rb +21 -5
- data/lib/timecrunch/version.rb +1 -1
- data/lib/timecrunch.rb +2 -1
- data/spec/integration/cli_spec.rb +40 -0
- data/spec/notifiers/{console_notifier_spec.rb → console_spec.rb} +2 -2
- data/spec/notifiers/notification_center_spec.rb +11 -0
- data/spec/timer_spec.rb +14 -3
- data/timecrunch.gemspec +2 -0
- metadata +25 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cda5feabf774620724c70da507fd770500602da0
|
4
|
+
data.tar.gz: 8a4a9e8296adf28759287a1a6f9ae3d404a87ecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 740edf14283e3b7cb2c519eb0b5e7080bbaa5873649e34dc660ef02ff2e7164946b095e9c6a7b47347bcd1535127cb85b6f4c51bd0e71abef5d79e7dd01e7303
|
7
|
+
data.tar.gz: 0e98920c4aa6b5b251b36acb2d87785ae69d542a79841ab008926e52057e309fc3ca6964ab67b3df599bdc70fc4f445d198c28234f89acef1ec01b1a7cc15379
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Timecrunch
|
2
2
|
|
3
|
-
|
3
|
+
A simple timer app.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,12 +18,15 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
If you just want to start a timer you can run:
|
22
|
+
|
23
|
+
$ tc start MINUTES
|
22
24
|
|
23
25
|
## Contributing
|
24
26
|
|
25
|
-
1. Fork it ( https://github.com/
|
27
|
+
1. Fork it ( https://github.com/spyc3r/timecrunch/fork )
|
26
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
31
|
5. Create a new Pull Request
|
32
|
+
|
data/lib/timecrunch/cli.rb
CHANGED
@@ -4,8 +4,15 @@ module Timecrunch
|
|
4
4
|
class CLI < Thor
|
5
5
|
|
6
6
|
desc "start MINUTES", "Starts a new timer for MINUTES"
|
7
|
-
|
8
|
-
|
7
|
+
option :s, :banner => "seconds"
|
8
|
+
option :growl, :type => :boolean, :banner => "notification center"
|
9
|
+
def start(minutes=0)
|
10
|
+
seconds = options[:s].nil? ? 0 : options[:s].to_i
|
11
|
+
minutes = minutes.to_i
|
12
|
+
timer = Timer.new(minutes: minutes, seconds: seconds)
|
13
|
+
timer.notifiers << Notifiers::Console.new
|
14
|
+
timer.notifiers << Notifiers::NotificationCenter.new if options[:growl]
|
15
|
+
timer.start!
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
data/lib/timecrunch/timer.rb
CHANGED
@@ -1,13 +1,29 @@
|
|
1
1
|
module Timecrunch
|
2
2
|
class Timer
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
attr_accessor :notifiers
|
4
|
+
|
5
|
+
def initialize(times, *notifiers)
|
6
|
+
@times = times
|
7
|
+
@notifiers = notifiers
|
6
8
|
end
|
7
9
|
|
8
10
|
def start!
|
9
|
-
sleep(
|
10
|
-
@notifier.notify!
|
11
|
+
sleep(total_time)
|
12
|
+
@notifiers.each { |notifier| notifier.notify! }
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def total_time
|
18
|
+
minutes + seconds
|
19
|
+
end
|
20
|
+
|
21
|
+
def minutes
|
22
|
+
@times.fetch(:minutes) { 0 } * 60
|
23
|
+
end
|
24
|
+
|
25
|
+
def seconds
|
26
|
+
@times.fetch(:seconds) { 0 }
|
11
27
|
end
|
12
28
|
end
|
13
29
|
end
|
data/lib/timecrunch/version.rb
CHANGED
data/lib/timecrunch.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'timecrunch'
|
2
|
+
|
3
|
+
describe "CLI" do
|
4
|
+
describe "start command" do
|
5
|
+
context "when a start time is provided" do
|
6
|
+
it "should wait for that amount of minutes" do
|
7
|
+
timer = instance_double("Timer", notifiers: [])
|
8
|
+
allow(Timecrunch::Timer).to receive(:new).with(hash_including(minutes: 1)) { timer }
|
9
|
+
expect(timer).to receive(:start!)
|
10
|
+
|
11
|
+
Timecrunch::CLI.start(["start", "1"])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "the seconds parameter is added" do
|
16
|
+
it "should wait for that many seconds" do
|
17
|
+
timer = instance_double("Timer", notifiers: [])
|
18
|
+
expect(Timecrunch::Timer).to receive(:new).with(hash_including seconds: 3) { timer }
|
19
|
+
expect(timer).to receive(:start!)
|
20
|
+
|
21
|
+
Timecrunch::CLI.start(["start", "-s", "3"])
|
22
|
+
end
|
23
|
+
end
|
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()
|
30
|
+
allow(Timecrunch::Notifiers::Console).to receive(:new) { console }
|
31
|
+
allow(Timecrunch::Notifiers::NotificationCenter).to receive(:new) { growl }
|
32
|
+
expect(Timecrunch::Timer).to receive(:new) { timer }
|
33
|
+
|
34
|
+
expect(timer).to receive(:start!)
|
35
|
+
Timecrunch::CLI.start(["start", "--growl"])
|
36
|
+
expect(timer.notifiers).to eq [console, growl]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'timecrunch'
|
2
2
|
|
3
|
-
describe Timecrunch::Notifiers::
|
3
|
+
describe Timecrunch::Notifiers::Console do
|
4
4
|
describe "#notify!" do
|
5
5
|
before do
|
6
6
|
$stdout = StringIO.new
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should display output" do
|
10
|
-
notifier = Timecrunch::Notifiers::
|
10
|
+
notifier = Timecrunch::Notifiers::Console.new
|
11
11
|
notifier.notify!
|
12
12
|
expect($stdout.string).to match("Timer is done!")
|
13
13
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'timecrunch'
|
2
|
+
|
3
|
+
describe Timecrunch::Notifiers::NotificationCenter do
|
4
|
+
describe "#notify!" do
|
5
|
+
it "should send a notify message to terminal notifier" do
|
6
|
+
notifier = Timecrunch::Notifiers::NotificationCenter.new
|
7
|
+
expect(TerminalNotifier).to receive(:notify).with("Timer is done!")
|
8
|
+
notifier.notify!
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/timer_spec.rb
CHANGED
@@ -2,10 +2,21 @@ require 'timecrunch'
|
|
2
2
|
|
3
3
|
describe Timecrunch::Timer do
|
4
4
|
describe "#call" do
|
5
|
-
it "should call
|
6
|
-
|
7
|
-
timer = Timecrunch::Timer.new(1,
|
5
|
+
it "should call all notifiers" do
|
6
|
+
notifiers = [double(), double()]
|
7
|
+
timer = Timecrunch::Timer.new({minutes: 1}, notifiers)
|
8
|
+
timer.notifiers << double()
|
8
9
|
expect(timer).to receive(:sleep).with(60)
|
10
|
+
timer.notifiers.each do |notifier|
|
11
|
+
expect(notifier).to receive(:notify!)
|
12
|
+
end
|
13
|
+
timer.start!
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should add second to the time if specified" do
|
17
|
+
notifier = double()
|
18
|
+
timer = Timecrunch::Timer.new({seconds: 5}, notifier)
|
19
|
+
expect(timer).to receive(:sleep).with(5)
|
9
20
|
expect(notifier).to receive(:notify!)
|
10
21
|
timer.start!
|
11
22
|
end
|
data/timecrunch.gemspec
CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Chris Keathley"]
|
10
10
|
spec.email = ["spyc3r@gmail.com"]
|
11
11
|
spec.summary = %q{A timer for timing things that need timing}
|
12
|
+
spec.description = %q{A basic timing application you can use from the command line}
|
12
13
|
spec.homepage = "https://github.com/spyc3r/timecrunch"
|
13
14
|
spec.license = "MIT"
|
14
15
|
|
@@ -18,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
18
19
|
spec.require_paths = ["lib"]
|
19
20
|
|
20
21
|
spec.add_runtime_dependency "thor", "0.19.0"
|
22
|
+
spec.add_runtime_dependency "terminal-notifier", "1.6.1"
|
21
23
|
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
25
|
spec.add_development_dependency "rake", "~> 10.3", ">= 10.3.2"
|
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.
|
4
|
+
version: 0.0.2
|
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-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.19.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-notifier
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +86,7 @@ dependencies:
|
|
72
86
|
- - ~>
|
73
87
|
- !ruby/object:Gem::Version
|
74
88
|
version: '3.0'
|
75
|
-
description:
|
89
|
+
description: A basic timing application you can use from the command line
|
76
90
|
email:
|
77
91
|
- spyc3r@gmail.com
|
78
92
|
executables:
|
@@ -89,10 +103,13 @@ files:
|
|
89
103
|
- bin/tc
|
90
104
|
- lib/timecrunch.rb
|
91
105
|
- lib/timecrunch/cli.rb
|
92
|
-
- lib/timecrunch/notifiers/
|
106
|
+
- lib/timecrunch/notifiers/console.rb
|
107
|
+
- lib/timecrunch/notifiers/notification_center.rb
|
93
108
|
- lib/timecrunch/timer.rb
|
94
109
|
- lib/timecrunch/version.rb
|
95
|
-
- spec/
|
110
|
+
- spec/integration/cli_spec.rb
|
111
|
+
- spec/notifiers/console_spec.rb
|
112
|
+
- spec/notifiers/notification_center_spec.rb
|
96
113
|
- spec/timer_spec.rb
|
97
114
|
- timecrunch.gemspec
|
98
115
|
homepage: https://github.com/spyc3r/timecrunch
|
@@ -120,6 +137,7 @@ signing_key:
|
|
120
137
|
specification_version: 4
|
121
138
|
summary: A timer for timing things that need timing
|
122
139
|
test_files:
|
123
|
-
- spec/
|
140
|
+
- spec/integration/cli_spec.rb
|
141
|
+
- spec/notifiers/console_spec.rb
|
142
|
+
- spec/notifiers/notification_center_spec.rb
|
124
143
|
- spec/timer_spec.rb
|
125
|
-
has_rdoc:
|