pompom 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.travis.yml +10 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/bin/pompom +23 -0
- data/lib/pompom.rb +233 -0
- data/man/pompom.1 +32 -0
- data/man/pompom.1.ronn +33 -0
- data/pompom.gemspec +84 -0
- data/test/helper.rb +16 -0
- data/test/test_asciifier.rb +18 -0
- data/test/test_pomodoro.rb +52 -0
- data/test/test_pompom.rb +19 -0
- data/test/test_view.rb +21 -0
- metadata +178 -0
data/.document
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "ffi-ncurses"
|
4
|
+
gem "artii"
|
5
|
+
gem "trollop"
|
6
|
+
gem "sequel"
|
7
|
+
gem "sqlite3"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "minitest", ">= 0"
|
13
|
+
gem "yard", "~> 0.7"
|
14
|
+
gem "bundler"
|
15
|
+
gem "jeweler", "~> 1.8.3"
|
16
|
+
gem "ronn"
|
17
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Roland Swingler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= pompom
|
2
|
+
|
3
|
+
A command line pomodoro timer.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install pompom
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
pompom -m "Thing I'm working on"
|
12
|
+
|
13
|
+
See the man page with gem-man for more information, or
|
14
|
+
|
15
|
+
pompom --help
|
16
|
+
|
17
|
+
== Contributing to pompom
|
18
|
+
|
19
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
20
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
21
|
+
* Fork the project.
|
22
|
+
* Start a feature/bugfix branch.
|
23
|
+
* Commit and push until you are happy with your contribution.
|
24
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
25
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
26
|
+
|
27
|
+
== Copyright
|
28
|
+
|
29
|
+
Copyright (c) 2012 Roland Swingler. See LICENSE.txt for
|
30
|
+
further details.
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "pompom"
|
18
|
+
gem.homepage = "http://github.com/knaveofdiamonds/pompom"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A command line pomodoro timer}
|
21
|
+
gem.description = %Q{A command line pomodoro timer}
|
22
|
+
gem.email = "roland.swingler@gmail.com"
|
23
|
+
gem.authors = ["Roland Swingler"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'yard'
|
38
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/pompom
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/pompom.rb")
|
3
|
+
require 'trollop'
|
4
|
+
|
5
|
+
opts = Trollop.options do
|
6
|
+
banner "A simple command line pomodoro timer, that can log your work."
|
7
|
+
opt :message, "What you're working on this pomodoro", :type => :string
|
8
|
+
opt :time, "The time in seconds", :default => 1500, :type => :int
|
9
|
+
opt :log, "Where to log work", :default => "~/.pompom/worklog", :type => :string
|
10
|
+
end
|
11
|
+
|
12
|
+
if opts[:message].nil?
|
13
|
+
opts[:no_log] = true
|
14
|
+
end
|
15
|
+
application = Pompom::Application.new(opts)
|
16
|
+
|
17
|
+
trap("SIGINT") do
|
18
|
+
application.cleanup
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
application.run
|
23
|
+
|
data/lib/pompom.rb
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
require 'ffi-ncurses'
|
2
|
+
require 'artii'
|
3
|
+
require 'sequel'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module Pompom
|
7
|
+
def self.format_time(number)
|
8
|
+
minutes = number / 60
|
9
|
+
seconds = number % 60
|
10
|
+
sprintf("%02d:%02d", minutes, seconds)
|
11
|
+
end
|
12
|
+
|
13
|
+
class Application
|
14
|
+
attr_reader :worklog
|
15
|
+
|
16
|
+
def initialize(options)
|
17
|
+
@options = options
|
18
|
+
if options[:no_log]
|
19
|
+
@worklog = NullWorkLog.new
|
20
|
+
else
|
21
|
+
@worklog = Worklog.new(options[:log])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
new_pomodoro do |pomodoro|
|
27
|
+
@worklog.start pomodoro
|
28
|
+
pomodoro.tick until pomodoro.finished?
|
29
|
+
end
|
30
|
+
play_sound
|
31
|
+
end
|
32
|
+
|
33
|
+
def cleanup
|
34
|
+
@worklog.finish_early
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# There has to be a better way of playing sounds through ruby...
|
40
|
+
# This will only work if you have sox installed (or a command
|
41
|
+
# named /usr/bin/play) and a sound named sound.wav in your
|
42
|
+
# ~/.pompom directory.
|
43
|
+
def play_sound
|
44
|
+
if File.exists?(File.expand_path("~/.pompom/sound.wav")) && File.exists?("/usr/bin/play")
|
45
|
+
`play -q ~/.pompom/sound.wav`
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def new_pomodoro
|
50
|
+
pomodoro = Pomodoro.new(@options[:time], @options[:message])
|
51
|
+
view = View.new(NCursesScreen.new)
|
52
|
+
pomodoro.add_observer(view)
|
53
|
+
|
54
|
+
view.run { yield pomodoro }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Worklog
|
59
|
+
def initialize(path)
|
60
|
+
@path = File.expand_path(path)
|
61
|
+
@directory = File.dirname(@path)
|
62
|
+
end
|
63
|
+
|
64
|
+
def start(pomodoro)
|
65
|
+
ensure_present
|
66
|
+
@id = @db[:pomodoros].insert(:started_at => Time.now, :message => pomodoro.message, :finished_early => false)
|
67
|
+
end
|
68
|
+
|
69
|
+
def finish_early
|
70
|
+
@db[:pomodoros].where(:id => @id).update(:finished_early => true)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def ensure_present
|
76
|
+
if File.exists?(@path)
|
77
|
+
@db = Sequel.sqlite(@path)
|
78
|
+
else
|
79
|
+
FileUtils.mkdir_p(@directory) unless File.exists?(@directory)
|
80
|
+
@db = Sequel.sqlite(@path)
|
81
|
+
@db.create_table :pomodoros do
|
82
|
+
primary_key :id
|
83
|
+
Time :started_at
|
84
|
+
String :message
|
85
|
+
TrueClass :finished_early
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class NullWorkLog
|
92
|
+
def start(pomodoro)
|
93
|
+
end
|
94
|
+
|
95
|
+
def finish_early
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class Pomodoro
|
100
|
+
attr_reader :time_remaining, :message
|
101
|
+
attr_writer :system_clock
|
102
|
+
|
103
|
+
def initialize(time_remaining=1500, message=nil)
|
104
|
+
@time_remaining = time_remaining
|
105
|
+
@message = message
|
106
|
+
@system_clock = Kernel
|
107
|
+
@observers = []
|
108
|
+
@finished_early = true
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_observer(object)
|
112
|
+
@observers << object
|
113
|
+
end
|
114
|
+
|
115
|
+
def tick
|
116
|
+
@system_clock.sleep 1
|
117
|
+
@time_remaining -= 1
|
118
|
+
@finished_early = false if @time_remaining == 0
|
119
|
+
notify_observers
|
120
|
+
end
|
121
|
+
|
122
|
+
def finish!
|
123
|
+
@time_remaining = 0
|
124
|
+
notify_observers
|
125
|
+
end
|
126
|
+
|
127
|
+
def finished_early?
|
128
|
+
@finished_early
|
129
|
+
end
|
130
|
+
|
131
|
+
def finished?
|
132
|
+
@time_remaining < 1
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def notify_observers
|
138
|
+
@observers.each {|o| o.update(self) }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class View
|
143
|
+
attr_writer :asciifier
|
144
|
+
|
145
|
+
def initialize(screen)
|
146
|
+
@screen = screen
|
147
|
+
@asciifier = Asciifier.new
|
148
|
+
end
|
149
|
+
|
150
|
+
def run(&block)
|
151
|
+
@screen.run(&block)
|
152
|
+
end
|
153
|
+
|
154
|
+
def update(pomodoro)
|
155
|
+
@screen.display format_for_screen(pomodoro.time_remaining), color(pomodoro), blink(pomodoro)
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def color(pomodoro)
|
161
|
+
if pomodoro.time_remaining > 60
|
162
|
+
:green
|
163
|
+
elsif pomodoro.time_remaining > 15
|
164
|
+
:yellow
|
165
|
+
else
|
166
|
+
:red
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def blink(pomodoro)
|
171
|
+
pomodoro.time_remaining < 5
|
172
|
+
end
|
173
|
+
|
174
|
+
def format_for_screen(time)
|
175
|
+
@asciifier.asciify(Pompom.format_time(time))
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
class Asciifier
|
180
|
+
def initialize
|
181
|
+
@asciifier = Artii::Base.new
|
182
|
+
end
|
183
|
+
|
184
|
+
def asciify(text)
|
185
|
+
result = @asciifier.asciify(text).split("\n")
|
186
|
+
# Fix kerning for when 2nd character of minutes is a 4. This fix
|
187
|
+
# should really be moved back upstream to the figlet font.
|
188
|
+
result[3].sub!(/_\| /, '_|')
|
189
|
+
result.join("\n")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
class NCursesScreen
|
194
|
+
include FFI::NCurses
|
195
|
+
|
196
|
+
def run
|
197
|
+
begin
|
198
|
+
initscr
|
199
|
+
cbreak
|
200
|
+
noecho
|
201
|
+
start_color
|
202
|
+
init_pair(1, COLOR_GREEN, COLOR_BLACK)
|
203
|
+
init_pair(2, COLOR_YELLOW, COLOR_BLACK)
|
204
|
+
init_pair(3, COLOR_RED, COLOR_BLACK)
|
205
|
+
curs_set 0
|
206
|
+
yield
|
207
|
+
ensure
|
208
|
+
endwin
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def display(str, color=:green, blinking=false)
|
213
|
+
clear
|
214
|
+
text_style = blinking ? A_BLINK : A_NORMAL
|
215
|
+
attr_set text_style, color_pair_mapping[color], nil
|
216
|
+
|
217
|
+
y, x = getmaxyx(stdscr)
|
218
|
+
|
219
|
+
lines = str.split("\n")
|
220
|
+
padding = (x - lines.first.size) / 2
|
221
|
+
((y - lines.size - 1) / 2).times { addstr("\n") }
|
222
|
+
lines.each do |line|
|
223
|
+
addstr(" " * padding)
|
224
|
+
addstr(line + "\n")
|
225
|
+
end
|
226
|
+
refresh
|
227
|
+
end
|
228
|
+
|
229
|
+
def color_pair_mapping
|
230
|
+
{:green => 1,:yellow => 2,:red => 3 }
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
data/man/pompom.1
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
+
.
|
4
|
+
.TH "POMPOM" "1" "May 2012" "" ""
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBpompom\fR \- a comand line pomodoro timer
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBpompom\fR [\-m \fImessage\fR] [\-l \fIpath\fR] [\-t \fIseconds\fR]
|
11
|
+
.
|
12
|
+
.SH "DESCRIPTION"
|
13
|
+
\fBPompom\fR runs a terminal\-based pomodoro timer, and can log the work you do in each pomodoro\.
|
14
|
+
.
|
15
|
+
.SH "OPTIONS"
|
16
|
+
.
|
17
|
+
.IP "\(bu" 4
|
18
|
+
\fB\-m\fR, \fB\-\-message\fR: The message you want logged for the work you are doing\. If no message is given, then nothing will be logged
|
19
|
+
.
|
20
|
+
.IP "\(bu" 4
|
21
|
+
\fB\-l\fR, \fB\-\-log\fR: The log location\. By default this will be stored in your home directory at ~/\.pompom/worklog
|
22
|
+
.
|
23
|
+
.IP "\(bu" 4
|
24
|
+
\fB\-t\fR, \fB\-\-time\fR The time in seconds the timer should run for\. By default 1500, (25 minutes)\.
|
25
|
+
.
|
26
|
+
.IP "" 0
|
27
|
+
.
|
28
|
+
.P
|
29
|
+
Pompom will play a sound at the end of a pomodoro if you have the play utility installed (provided by the sox package, at least on Ubuntu), and a file named ~/\.pompom/sound\.wav
|
30
|
+
.
|
31
|
+
.SH "COPYRIGHT"
|
32
|
+
Pompom is Copyright (C) 2012 Roland Swingler \fIhttp://github\.com/knaveofdiamonds\fR
|
data/man/pompom.1.ronn
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
pompom(1) -- a comand line pomodoro timer
|
2
|
+
=========================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
`pompom` [-m <message>] [-l <path>] [-t <seconds>]
|
7
|
+
|
8
|
+
## DESCRIPTION
|
9
|
+
|
10
|
+
**Pompom** runs a terminal-based pomodoro timer, and can log the work
|
11
|
+
you do in each pomodoro.
|
12
|
+
|
13
|
+
## OPTIONS
|
14
|
+
|
15
|
+
* `-m`, `--message`:
|
16
|
+
The message you want logged for the work you are doing. If
|
17
|
+
no message is given, then nothing will be logged
|
18
|
+
|
19
|
+
* `-l`, `--log`:
|
20
|
+
The log location. By default this will be stored in your
|
21
|
+
home directory at ~/.pompom/worklog
|
22
|
+
|
23
|
+
* `-t`, `--time`
|
24
|
+
The time in seconds the timer should run for. By default
|
25
|
+
1500, (25 minutes).
|
26
|
+
|
27
|
+
Pompom will play a sound at the end of a pomodoro if you have the play
|
28
|
+
utility installed (provided by the sox package, at least on Ubuntu),
|
29
|
+
and a file named ~/.pompom/sound.wav
|
30
|
+
|
31
|
+
## COPYRIGHT
|
32
|
+
|
33
|
+
Pompom is Copyright (C) 2012 Roland Swingler <http://github.com/knaveofdiamonds>
|
data/pompom.gemspec
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pompom}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Roland Swingler}]
|
12
|
+
s.date = %q{2012-05-09}
|
13
|
+
s.description = %q{A command line pomodoro timer}
|
14
|
+
s.email = %q{roland.swingler@gmail.com}
|
15
|
+
s.executables = [%q{pompom}]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".travis.yml",
|
23
|
+
"Gemfile",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/pompom",
|
29
|
+
"lib/pompom.rb",
|
30
|
+
"man/pompom.1",
|
31
|
+
"man/pompom.1.ronn",
|
32
|
+
"pompom.gemspec",
|
33
|
+
"test/helper.rb",
|
34
|
+
"test/test_asciifier.rb",
|
35
|
+
"test/test_pomodoro.rb",
|
36
|
+
"test/test_pompom.rb",
|
37
|
+
"test/test_view.rb"
|
38
|
+
]
|
39
|
+
s.homepage = %q{http://github.com/knaveofdiamonds/pompom}
|
40
|
+
s.licenses = [%q{MIT}]
|
41
|
+
s.require_paths = [%q{lib}]
|
42
|
+
s.rubygems_version = %q{1.8.6}
|
43
|
+
s.summary = %q{A command line pomodoro timer}
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<ffi-ncurses>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<artii>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<trollop>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<sequel>, [">= 0"])
|
53
|
+
s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<minitest>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
56
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
58
|
+
s.add_development_dependency(%q<ronn>, [">= 0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<ffi-ncurses>, [">= 0"])
|
61
|
+
s.add_dependency(%q<artii>, [">= 0"])
|
62
|
+
s.add_dependency(%q<trollop>, [">= 0"])
|
63
|
+
s.add_dependency(%q<sequel>, [">= 0"])
|
64
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
65
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
66
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
67
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
69
|
+
s.add_dependency(%q<ronn>, [">= 0"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<ffi-ncurses>, [">= 0"])
|
73
|
+
s.add_dependency(%q<artii>, [">= 0"])
|
74
|
+
s.add_dependency(%q<trollop>, [">= 0"])
|
75
|
+
s.add_dependency(%q<sequel>, [">= 0"])
|
76
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
77
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
78
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
79
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
80
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
81
|
+
s.add_dependency(%q<ronn>, [">= 0"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/spec'
|
11
|
+
require 'minitest/autorun'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
|
+
require 'pompom'
|
16
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Pompom::Asciifier do
|
4
|
+
before do
|
5
|
+
@asciifier = Pompom::Asciifier.new
|
6
|
+
end
|
7
|
+
|
8
|
+
# i.e. fix line 4:
|
9
|
+
# ___ _ _ __ ___
|
10
|
+
# |__ \| || | __ |/ _ \
|
11
|
+
# ) | || |__) | | | |
|
12
|
+
# / /|__ _| | | | | |
|
13
|
+
# / /_ | | _| | |_| |
|
14
|
+
# |____| |_|(_)_|\___/
|
15
|
+
it "fixes the problem with figlet font kerning" do
|
16
|
+
@asciifier.asciify("24:10").must_equal [" ___ _ _ __ ___ ", " |__ \\| || | __ |/ _ \\ ", " ) | || |__) | | | |", " / /|__ _|| | | | |", " / /_ | | _| | |_| |", " |____| |_|(_)_|\\___/ ", " ", " "].join("\n")
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Pompom::Pomodoro do
|
4
|
+
before do
|
5
|
+
@pomodoro = Pompom::Pomodoro.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "starts with 25 minutes remaining by default" do
|
9
|
+
@pomodoro.time_remaining.must_equal 1500
|
10
|
+
end
|
11
|
+
|
12
|
+
it "reduces the time remaining by one when tick is called" do
|
13
|
+
Kernel.stub(:sleep, nil) do
|
14
|
+
original_time = @pomodoro.time_remaining
|
15
|
+
@pomodoro.tick
|
16
|
+
@pomodoro.time_remaining.must_equal original_time - 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "asks the system clock to sleep for 1 second when tick is called" do
|
21
|
+
clock = MiniTest::Mock.new
|
22
|
+
clock.expect(:sleep, nil, [1])
|
23
|
+
@pomodoro.system_clock = clock
|
24
|
+
@pomodoro.tick
|
25
|
+
clock.verify
|
26
|
+
end
|
27
|
+
|
28
|
+
it "notifies observers of the time remaining when tick is called" do
|
29
|
+
Kernel.stub(:sleep, nil) do
|
30
|
+
observer = MiniTest::Mock.new
|
31
|
+
observer.expect(:update, nil, [@pomodoro])
|
32
|
+
@pomodoro.add_observer(observer)
|
33
|
+
@pomodoro.tick
|
34
|
+
observer.verify
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be finished when the time remaining is 0" do
|
39
|
+
Pompom::Pomodoro.new(0).finished?.must_equal true
|
40
|
+
Pompom::Pomodoro.new(-1).finished?.must_equal true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a message" do
|
44
|
+
Pompom::Pomodoro.new(0, "Some testing").message.must_equal "Some testing"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "can be finished early" do
|
48
|
+
@pomodoro.finish!
|
49
|
+
@pomodoro.time_remaining.must_equal 0
|
50
|
+
@pomodoro.finished_early?.must_equal true
|
51
|
+
end
|
52
|
+
end
|
data/test/test_pompom.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe "Pompom helper methods" do
|
4
|
+
it "should format 0 as 00:00" do
|
5
|
+
Pompom.format_time(0).must_equal "00:00"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should format 1 second as 00:01" do
|
9
|
+
Pompom.format_time(1).must_equal "00:01"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "formats 60 seconds as 01:00" do
|
13
|
+
Pompom.format_time(60).must_equal "01:00"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "formats 61 seconds as 01:01" do
|
17
|
+
Pompom.format_time(61).must_equal "01:01"
|
18
|
+
end
|
19
|
+
end
|
data/test/test_view.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Pompom::View do
|
4
|
+
before do
|
5
|
+
@screen = MiniTest::Mock.new
|
6
|
+
@view = Pompom::View.new(@screen)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should display an asciified time on the screen when updated" do
|
10
|
+
asciifier = MiniTest::Mock.new
|
11
|
+
asciifier.expect(:asciify, "foo", ["00:01"])
|
12
|
+
@view.asciifier = asciifier
|
13
|
+
@screen.expect(:display, nil, ["foo", :red, true])
|
14
|
+
pomodoro = Pompom::Pomodoro.new(1)
|
15
|
+
|
16
|
+
@view.update(pomodoro)
|
17
|
+
|
18
|
+
@screen.verify
|
19
|
+
asciifier.verify
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pompom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Roland Swingler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-09 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi-ncurses
|
16
|
+
requirement: &26377040 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *26377040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: artii
|
27
|
+
requirement: &26376400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *26376400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: trollop
|
38
|
+
requirement: &26375720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *26375720
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sequel
|
49
|
+
requirement: &26375060 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *26375060
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: sqlite3
|
60
|
+
requirement: &26374420 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *26374420
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: &26373740 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *26373740
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: yard
|
82
|
+
requirement: &26371020 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.7'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *26371020
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: bundler
|
93
|
+
requirement: &26370440 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *26370440
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: jeweler
|
104
|
+
requirement: &26369860 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.8.3
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *26369860
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: ronn
|
115
|
+
requirement: &26369160 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *26369160
|
124
|
+
description: A command line pomodoro timer
|
125
|
+
email: roland.swingler@gmail.com
|
126
|
+
executables:
|
127
|
+
- pompom
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files:
|
130
|
+
- LICENSE.txt
|
131
|
+
- README.rdoc
|
132
|
+
files:
|
133
|
+
- .document
|
134
|
+
- .travis.yml
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.rdoc
|
138
|
+
- Rakefile
|
139
|
+
- VERSION
|
140
|
+
- bin/pompom
|
141
|
+
- lib/pompom.rb
|
142
|
+
- man/pompom.1
|
143
|
+
- man/pompom.1.ronn
|
144
|
+
- pompom.gemspec
|
145
|
+
- test/helper.rb
|
146
|
+
- test/test_asciifier.rb
|
147
|
+
- test/test_pomodoro.rb
|
148
|
+
- test/test_pompom.rb
|
149
|
+
- test/test_view.rb
|
150
|
+
homepage: http://github.com/knaveofdiamonds/pompom
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - ! '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
segments:
|
164
|
+
- 0
|
165
|
+
hash: -4127764749183117098
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 1.8.6
|
175
|
+
signing_key:
|
176
|
+
specification_version: 3
|
177
|
+
summary: A command line pomodoro timer
|
178
|
+
test_files: []
|