tacgo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tacgo +44 -12
  3. data/tacgo.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 046eae30a45b2fa4a4e9a489e6de11557a493ec8
4
- data.tar.gz: d41a0b23e5571125542ad5c8c6382d882953ad0e
3
+ metadata.gz: 72112fda85742ac175d7809c27f0568c5221555e
4
+ data.tar.gz: dd860e32dbd0a0414d64d64b7067f459a6e0335f
5
5
  SHA512:
6
- metadata.gz: 1da183586fa8a54b1e722429d980edf93e0df778a89f2d81f62efd99f9ff9b067e72f232dee42fa0b3754e73710ec2dea61e5ceb3fbb57e37e1bbd64720cdb90
7
- data.tar.gz: 002a24f516df83e5745b698b2555f36777d912adf74113ddaced9e13dda66c9709f20c0fc8ebe1d395c9738e137475d00a718ae4d3828172195af54a826c7cc2
6
+ metadata.gz: ad40617d73679ca7f4f3002570f1f709e42fe171be4532c16f56f01d97056a9070e32f90cc241c74047f6909a90b8f796567950410863ad111db9b00c712e0a0
7
+ data.tar.gz: c44089ba2aa0bba5584f9368eab9813d667f3cd68b6f854e931c76072a857e1eb6137a6cac1a1111d386c4152ebcb77f899777c9371d81802dc56049b7a6a2d6
data/bin/tacgo CHANGED
@@ -38,7 +38,33 @@ Task = Struct.new(:id, :label) do
38
38
  end
39
39
  end
40
40
 
41
- Pomodoro = Struct.new(:task, :started, :completed) do
41
+ Pomodoro = Struct.new(:task, :duration, :started, :completed) do
42
+ attr_accessor :restarted, :canceled
43
+
44
+ def initialize(task = nil, duration = 25 * 60, started = nil, completed = nil)
45
+ super task, duration, started, completed
46
+ end
47
+
48
+ def active?
49
+ canceled.nil? and progress < duration
50
+ end
51
+
52
+ def canceled?
53
+ !canceled.nil?
54
+ end
55
+
56
+ def progress
57
+ [ Time.now - (restarted || started), duration ].min
58
+ end
59
+
60
+ def restart
61
+ self.restarted = Time.now
62
+ end
63
+
64
+ def cancel
65
+ self.canceled = Time.now
66
+ end
67
+
42
68
  def start(store)
43
69
  self.started = Time.now
44
70
  store.transaction do
@@ -61,21 +87,27 @@ def start
61
87
  task = fetch_top_task
62
88
  pomodoro = Pomodoro.new(task)
63
89
  pomodoro.start(store)
64
-
65
- duration = 25 * 60
66
- progress = ProgressBar.create(title: task.label[0..40], total: duration)
90
+ progress = ProgressBar.create(title: task.label[0..40],
91
+ total: pomodoro.duration,
92
+ format: '%t: |%B| %p%%')
67
93
 
68
94
  Thread.abort_on_exception = true
69
- Thread.new(pomodoro, duration, progress) do |pomodoro, duration, progress|
70
- while (now = Time.now) < pomodoro.started + duration
71
- progress.progress = now - pomodoro.started
72
- sleep 1
95
+ Thread.new(pomodoro, progress) do |pomodoro, progress|
96
+ $stdin.echo = false
97
+ Signal.trap('INT') { pomodoro.cancel }
98
+ Signal.trap('QUIT') { pomodoro.restart }
99
+
100
+ while pomodoro.active?
101
+ progress.progress = pomodoro.progress
102
+ sleep 0.1
73
103
  end
74
- end.join
75
- progress.finish
76
104
 
77
- pomodoro.complete(store)
78
- `osascript -e 'display notification "Pomodoro complete" with title "Pomodoro complete" sound name "Glass"'`
105
+ unless pomodoro.canceled?
106
+ progress.finish
107
+ pomodoro.complete store
108
+ `osascript -e 'display notification "Pomodoro complete" with title "Pomodoro complete" sound name "Glass"'`
109
+ end
110
+ end.join
79
111
  end
80
112
 
81
113
  def store
data/tacgo.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'tacgo'
3
- spec.version = '0.0.2'
3
+ spec.version = '0.0.3'
4
4
  spec.summary = 'Taco and Pomodoro'
5
5
  spec.description = 'Time and track pomodori against the top task in Taco'
6
6
  spec.authors = ['Larry Marburger']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tacgo
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
  - Larry Marburger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize