tamarillo 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/README.md +20 -27
- data/bin/tam +62 -2
- data/lib/tamarillo/controller.rb +3 -1
- data/lib/tamarillo/tomato.rb +6 -2
- data/lib/tamarillo/version.rb +1 -1
- data/spec/lib/tamarillo/controller_spec.rb +17 -0
- data/spec/lib/tamarillo/tomato_spec.rb +17 -1
- data/tamarillo.gemspec +2 -1
- metadata +17 -17
data/CHANGES
CHANGED
data/README.md
CHANGED
@@ -29,55 +29,48 @@ can.
|
|
29
29
|
|
30
30
|
## Examples
|
31
31
|
|
32
|
-
These examples are just thought experiments, this interface has not been
|
33
|
-
implemented yet.
|
34
|
-
|
35
32
|
### Starting and stopping a tomato
|
36
33
|
|
37
34
|
```
|
38
35
|
$ tam start
|
39
|
-
>
|
36
|
+
> Pomodoro started, about 25 minutes.
|
40
37
|
|
41
38
|
$ tam stop
|
42
|
-
>
|
43
|
-
|
44
|
-
$ tam pause
|
45
|
-
> tomato paused around ~16m
|
46
|
-
|
47
|
-
$ tam interrupt
|
48
|
-
> tomato interrupted around ~14m
|
39
|
+
> Pomorodo stopped, around 17 minutes.
|
49
40
|
```
|
50
41
|
|
51
42
|
### Status of current tomato
|
52
43
|
|
53
44
|
```
|
54
45
|
$ tam status
|
55
|
-
>
|
46
|
+
> About 19 minutes.
|
56
47
|
|
57
|
-
$ tam
|
58
|
-
>
|
59
|
-
|
60
|
-
$ tam status --full
|
61
|
-
> active 19:21
|
48
|
+
$ tam status --prompt
|
49
|
+
> 19:21 1161 1500
|
62
50
|
```
|
63
51
|
|
64
52
|
### Configuration
|
65
53
|
|
66
54
|
```
|
67
|
-
$ tam config
|
68
|
-
>
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
>
|
55
|
+
$ tam config
|
56
|
+
> --
|
57
|
+
> duration: 25
|
58
|
+
> notifier: bell
|
59
|
+
|
60
|
+
$ tam config duration=10
|
61
|
+
> --
|
62
|
+
> duration: 10
|
63
|
+
> notifier: bell
|
64
|
+
|
65
|
+
$ tam config notifier=growl
|
66
|
+
> --
|
67
|
+
> duration: 10
|
68
|
+
> notifier: growl
|
75
69
|
```
|
76
70
|
|
77
71
|
|
78
72
|
## Future ideas
|
79
73
|
|
80
74
|
* task management, tomatoes are assigned to a task
|
81
|
-
* daemon process for monitoring the current tomato
|
82
|
-
* notification helper app for various environments
|
83
75
|
* instaweb view of history
|
76
|
+
* helpers for shell and prompt integration
|
data/bin/tam
CHANGED
@@ -1,4 +1,64 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
4
|
+
|
5
|
+
gem 'gli', '~>1.6.0'
|
6
|
+
require 'gli'
|
7
|
+
require 'tamarillo'
|
8
|
+
|
9
|
+
# Setup paths
|
10
|
+
path = ENV['TAMARILLO_PATH']
|
11
|
+
path ||= ENV['HOME'] + '/.tamarillo'
|
12
|
+
tamarillo_path = Pathname.new(File.expand_path(path))
|
13
|
+
config_path = tamarillo_path.join('config.yml')
|
14
|
+
|
15
|
+
# Setup environment
|
16
|
+
config = Tamarillo::Config.load(config_path)
|
17
|
+
storage = Tamarillo::Storage.new(tamarillo_path, config)
|
18
|
+
controller = Tamarillo::Controller.new(config, storage)
|
19
|
+
|
20
|
+
include GLI
|
21
|
+
|
22
|
+
program_desc "Command line pomodoro timer."
|
23
|
+
version Tamarillo::VERSION
|
24
|
+
|
25
|
+
desc "Status of the current pomodoro."
|
26
|
+
command :status do |c|
|
27
|
+
c.desc 'Format status for display in prompt.'
|
28
|
+
c.switch [:p, :prompt]
|
29
|
+
|
30
|
+
c.action do |global_options, options, args|
|
31
|
+
format = options[:prompt] ? Tamarillo::Formats::PROMPT : Tamarillo::Formats::HUMAN
|
32
|
+
status = controller.status(format)
|
33
|
+
printf "%s\n", status unless status.nil? || status.empty?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Start a new pomodoro."
|
38
|
+
command :start do |c|
|
39
|
+
c.action do |global_options, options, args|
|
40
|
+
if tomato = controller.start_new_tomato
|
41
|
+
printf "Started new pomodoro, about %d minutes.\n", tomato.approx_minutes_remaining
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Stops the current pomodoro."
|
47
|
+
command :stop do |c|
|
48
|
+
c.action do |global_options, options, args|
|
49
|
+
if tomato = controller.interrupt_current_tomato
|
50
|
+
printf "Pomodoro stopped, about %d minutes.\n", tomato.approx_minutes_remaining
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "View and update the configuration."
|
56
|
+
command :config do |c|
|
57
|
+
c.action do |global_options, options, args|
|
58
|
+
params = Hash[args.map { |pair| pair.split('=', 2) }]
|
59
|
+
controller.update_config(params)
|
60
|
+
print controller.config.to_yaml
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
exit run(ARGV)
|
data/lib/tamarillo/controller.rb
CHANGED
@@ -47,10 +47,12 @@ module Tamarillo
|
|
47
47
|
stop_monitor
|
48
48
|
|
49
49
|
tomato = @storage.latest
|
50
|
-
return if tomato.nil?
|
50
|
+
return if tomato.nil? || tomato.interrupted?
|
51
51
|
|
52
52
|
tomato.interrupt!
|
53
53
|
@storage.write_tomato(tomato)
|
54
|
+
|
55
|
+
tomato
|
54
56
|
end
|
55
57
|
|
56
58
|
# Public: Returns the current config.
|
data/lib/tamarillo/tomato.rb
CHANGED
@@ -43,12 +43,16 @@ module Tamarillo
|
|
43
43
|
|
44
44
|
# Public: Returns the number of seconds until completion.
|
45
45
|
def remaining
|
46
|
-
return 0 if @interrupted
|
47
|
-
|
48
46
|
d = @duration - @clock.elapsed
|
49
47
|
d > 0 ? d : 0
|
50
48
|
end
|
51
49
|
|
50
|
+
# Public: Returns the approximate number of minutes until
|
51
|
+
# completetion.
|
52
|
+
def approx_minutes_remaining
|
53
|
+
(remaining / 60.0).round.to_i
|
54
|
+
end
|
55
|
+
|
52
56
|
# Public: Returns the number of seconds elapsed since start.
|
53
57
|
def elapsed
|
54
58
|
@clock.elapsed
|
data/lib/tamarillo/version.rb
CHANGED
@@ -85,6 +85,7 @@ describe Tamarillo::Controller do
|
|
85
85
|
|
86
86
|
it "interrupts the current tomato" do
|
87
87
|
tomato = double('tomato')
|
88
|
+
tomato.stub(:interrupted?) { false }
|
88
89
|
tomato.should_receive(:interrupt!)
|
89
90
|
storage.stub(:write_tomato)
|
90
91
|
storage.should_receive(:latest).and_return(tomato)
|
@@ -98,14 +99,30 @@ describe Tamarillo::Controller do
|
|
98
99
|
.should_not raise_error(NoMethodError)
|
99
100
|
end
|
100
101
|
|
102
|
+
it "returns nil if the tomato is already interrupted" do
|
103
|
+
tomato = double('tomato')
|
104
|
+
tomato.stub(:interrupted?) { true }
|
105
|
+
storage.stub(:latest => tomato)
|
106
|
+
subject.interrupt_current_tomato.should be_nil
|
107
|
+
end
|
108
|
+
|
101
109
|
it "writes the tomato" do
|
102
110
|
tomato = double('tomato')
|
111
|
+
tomato.stub(:interrupted?) { false }
|
103
112
|
tomato.stub(:interrupt!)
|
104
113
|
storage.stub(:latest => tomato)
|
105
114
|
storage.should_receive(:write_tomato).with(tomato)
|
106
115
|
|
107
116
|
subject.interrupt_current_tomato
|
108
117
|
end
|
118
|
+
|
119
|
+
it "returns the interrupted tomato" do
|
120
|
+
tomato = double('tomato').as_null_object
|
121
|
+
tomato.stub(:interrupted?) { false }
|
122
|
+
storage.stub(:latest => tomato, :write_tomato => nil)
|
123
|
+
|
124
|
+
subject.interrupt_current_tomato.should == tomato
|
125
|
+
end
|
109
126
|
end
|
110
127
|
|
111
128
|
describe "#config" do
|
@@ -71,7 +71,23 @@ describe Tomato do
|
|
71
71
|
subject.interrupt!
|
72
72
|
end
|
73
73
|
|
74
|
-
its(:remaining) { should ==
|
74
|
+
its(:remaining) { should == 25.minutes }
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "approximate time remaining" do
|
80
|
+
let(:clock) { stub(:elapsed => elapsed) }
|
81
|
+
subject { Tomato.new(10.minutes, clock) }
|
82
|
+
|
83
|
+
context "when more than 30 seconds between minutes" do
|
84
|
+
let(:elapsed) { 5.minutes + 10.seconds }
|
85
|
+
its(:approx_minutes_remaining) { should == 5 }
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when less than 30 seconds between minutes" do
|
89
|
+
let(:elapsed) { 5.minutes + 50.seconds }
|
90
|
+
its(:approx_minutes_remaining) { should == 4 }
|
75
91
|
end
|
76
92
|
end
|
77
93
|
|
data/tamarillo.gemspec
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require File.expand_path('../lib/tamarillo/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
+
|
5
6
|
gem.name = "tamarillo"
|
6
7
|
gem.version = Tamarillo::VERSION
|
7
8
|
gem.authors = ["Tim Uruski"]
|
@@ -21,6 +22,6 @@ Gem::Specification.new do |gem|
|
|
21
22
|
gem.add_development_dependency 'rspec', '~> 2.9.0'
|
22
23
|
gem.add_development_dependency 'timecop', '~> 0.3.5'
|
23
24
|
|
24
|
-
gem.add_runtime_dependency 'gli', '~>
|
25
|
+
gem.add_runtime_dependency 'gli', '~> 1.6.0'
|
25
26
|
|
26
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tamarillo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aruba
|
16
|
-
requirement: &
|
16
|
+
requirement: &70093955101400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.11
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70093955101400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: active_support
|
27
|
-
requirement: &
|
27
|
+
requirement: &70093955068320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70093955068320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakefs
|
38
|
-
requirement: &
|
38
|
+
requirement: &70093938686480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.4.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70093938686480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70093938600700 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.9.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70093938600700
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: timecop
|
60
|
-
requirement: &
|
60
|
+
requirement: &70093937676840 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,18 +65,18 @@ dependencies:
|
|
65
65
|
version: 0.3.5
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70093937676840
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: gli
|
71
|
-
requirement: &
|
71
|
+
requirement: &70093937644740 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 1.6.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70093937644740
|
80
80
|
description: Manage pomodoros from the command-line.
|
81
81
|
email:
|
82
82
|
- timuruski@gmail.com
|
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
segments:
|
144
144
|
- 0
|
145
|
-
hash:
|
145
|
+
hash: 3768224559069028415
|
146
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
147
|
none: false
|
148
148
|
requirements:
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
segments:
|
153
153
|
- 0
|
154
|
-
hash:
|
154
|
+
hash: 3768224559069028415
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
157
|
rubygems_version: 1.8.11
|