timecrunch 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 144c62889bf37bf6172925300c0fed50724242ff
4
- data.tar.gz: 0c5f7ee862bc6ed03f7d67c4435c246eaf3da2bc
3
+ metadata.gz: cda5feabf774620724c70da507fd770500602da0
4
+ data.tar.gz: 8a4a9e8296adf28759287a1a6f9ae3d404a87ecf
5
5
  SHA512:
6
- metadata.gz: 3b00d7a015e1e824a7630b9aefa690a304bfaa3382ae583c3c8bad3e6dca83b0112b45c071608ba7034868da44c5c5ec264a9f4e6727e4b724191e346dd3cd17
7
- data.tar.gz: 5bf9afd9080455b9e3435d75b7219fc6c61c78f2d8dae4e5d0ecbd20b3804eacd863b30c18a04555a27e6fea379a8947a7afa2f7cd02362793362ec08ddc7fd1
6
+ metadata.gz: 740edf14283e3b7cb2c519eb0b5e7080bbaa5873649e34dc660ef02ff2e7164946b095e9c6a7b47347bcd1535127cb85b6f4c51bd0e71abef5d79e7dd01e7303
7
+ data.tar.gz: 0e98920c4aa6b5b251b36acb2d87785ae69d542a79841ab008926e52057e309fc3ca6964ab67b3df599bdc70fc4f445d198c28234f89acef1ec01b1a7cc15379
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Timecrunch
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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/[my-github-username]/timecrunch/fork )
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
+
@@ -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
- def start(minutes)
8
- Timer.new(minutes.to_i, Notifiers::ConsoleNotifier.new).start!
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
@@ -1,6 +1,6 @@
1
1
  module Timecrunch
2
2
  module Notifiers
3
- class ConsoleNotifier
3
+ class Console
4
4
  def notify!
5
5
  puts "Timer is done!"
6
6
  end
@@ -0,0 +1,11 @@
1
+ require 'terminal-notifier'
2
+
3
+ module Timecrunch
4
+ module Notifiers
5
+ class NotificationCenter
6
+ def notify!
7
+ TerminalNotifier.notify('Timer is done!')
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,13 +1,29 @@
1
1
  module Timecrunch
2
2
  class Timer
3
- def initialize(minutes, notifier)
4
- @minutes = minutes
5
- @notifier = notifier
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(@minutes * 60)
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
@@ -1,3 +1,3 @@
1
1
  module Timecrunch
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/timecrunch.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require "timecrunch/version"
2
2
  require "timecrunch/timer"
3
3
  require "timecrunch/cli"
4
- require "timecrunch/notifiers/console_notifier"
4
+ require "timecrunch/notifiers/console"
5
+ require "timecrunch/notifiers/notification_center"
5
6
 
6
7
  module Timecrunch
7
8
  end
@@ -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::ConsoleNotifier do
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::ConsoleNotifier.new
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 the notifier" do
6
- notifier = double()
7
- timer = Timecrunch::Timer.new(1, notifier)
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.1
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-18 00:00:00.000000000 Z
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/console_notifier.rb
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/notifiers/console_notifier_spec.rb
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/notifiers/console_notifier_spec.rb
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: