pomo-ruby 0.0.3
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.
- data/README.rdoc +11 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/bin/pomo-ruby +2 -0
- data/lib/core/cycle_runner.rb +42 -0
- data/lib/core/input_validator.rb +17 -0
- data/lib/core/timer.rb +50 -0
- data/lib/gui/button_cancel.rb +17 -0
- data/lib/gui/button_start.rb +47 -0
- data/lib/gui/panel.rb +29 -0
- data/lib/gui/progress_bar.rb +8 -0
- data/lib/gui/text_field.rb +18 -0
- data/lib/gui/window.rb +58 -0
- data/lib/images/tomato.ico +0 -0
- data/lib/images/tomato.jpg +0 -0
- data/lib/images/tomato.png +0 -0
- data/lib/pomo_ruby.rb +14 -0
- data/pomo-ruby.gemspec +56 -0
- metadata +84 -0
data/README.rdoc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
=Pomo-ruby
|
2
|
+
Pomo-ruby is an standalone application written in Ruby/GTK with simple GUI to manage your time based on the Pomodoro technique.
|
3
|
+
It was developed under the need of an application as such for GNU/Linux.
|
4
|
+
|
5
|
+
=Install on Ubuntu / Linux
|
6
|
+
|
7
|
+
sudo aptitude install libgtk2-ruby
|
8
|
+
sudo gem install pomo-ruby
|
9
|
+
|
10
|
+
=Running
|
11
|
+
pomo-ruby
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "pomo-ruby"
|
5
|
+
gemspec.summary = "A simple application to run your Pomodoros in linux writen in GTK."
|
6
|
+
gemspec.description = "Pomo-ruby is an standalone application written in Ruby/GTK with simple GUI to manage your time based on the Pomodoro technique."
|
7
|
+
|
8
|
+
gemspec.email = "pedro.capaca@gmail.com"
|
9
|
+
gemspec.homepage = "http://github.com/capaca/pomo-ruby"
|
10
|
+
gemspec.authors = ["Pedro Dias"]
|
11
|
+
end
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
14
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.3
|
data/bin/pomo-ruby
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class CycleRunner
|
2
|
+
|
3
|
+
def initialize cycles, pomodoro_time, pause_time, break_time
|
4
|
+
@timer_pomodoro = Timer.new pomodoro_time
|
5
|
+
@timer_pause = Timer.new pause_time
|
6
|
+
@timer_break = Timer.new break_time
|
7
|
+
@cycles = cycles
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
@thread = Thread.new do
|
12
|
+
begin
|
13
|
+
@cycles.times do |i|
|
14
|
+
Window.instance.pop_up
|
15
|
+
@timer_pomodoro.run
|
16
|
+
|
17
|
+
if i + 1 != @cycles
|
18
|
+
Window.instance.panel.button_start.label = "Time for a litle pause..."
|
19
|
+
Window.instance.pop_up
|
20
|
+
@timer_pause.run
|
21
|
+
end
|
22
|
+
end
|
23
|
+
Window.instance.panel.button_start.label = "Now it's time to rest..."
|
24
|
+
Window.instance.pop_up
|
25
|
+
@timer_break.run
|
26
|
+
rescue => e
|
27
|
+
puts e
|
28
|
+
Thread.stop
|
29
|
+
end
|
30
|
+
Window.instance.pop_up
|
31
|
+
Window.instance.panel.button_start.enable
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
@thread.kill
|
38
|
+
Window.instance.panel.button_start.enable
|
39
|
+
Window.instance.panel.progress_bar.text = "Canceled"
|
40
|
+
Window.instance.panel.progress_bar.fraction = 0
|
41
|
+
end
|
42
|
+
end
|
data/lib/core/timer.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
class Timer
|
2
|
+
|
3
|
+
# Initialize de timer informing how much time it must take in SECONDS
|
4
|
+
def initialize duration
|
5
|
+
@duration = duration
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
@now = Time.now.to_i
|
10
|
+
@future = @now + @duration
|
11
|
+
|
12
|
+
while @now < @future
|
13
|
+
@now = Time.now.to_i
|
14
|
+
Window.instance.panel.progress_bar.fraction = fraction
|
15
|
+
Window.instance.panel.progress_bar.text = "Remaining time: #{remaining_time}"
|
16
|
+
sleep 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def diference
|
21
|
+
@future - @now
|
22
|
+
end
|
23
|
+
|
24
|
+
def fraction
|
25
|
+
diference.to_f/@duration
|
26
|
+
end
|
27
|
+
|
28
|
+
def minutes
|
29
|
+
(diference/60).to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
def seconds
|
33
|
+
seconds = (diference % 60).to_i
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_leadind_zero integer
|
37
|
+
if integer.to_s.length == 1
|
38
|
+
return "0#{integer}"
|
39
|
+
end
|
40
|
+
|
41
|
+
integer.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def remaining_time
|
45
|
+
minutes_str = add_leadind_zero minutes
|
46
|
+
seconds_str = add_leadind_zero seconds
|
47
|
+
"#{minutes_str}:#{seconds_str}"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ButtonCancel < Gtk::Button
|
2
|
+
|
3
|
+
def initialize text
|
4
|
+
super text
|
5
|
+
|
6
|
+
@text = text
|
7
|
+
add_click_event
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def add_click_event
|
13
|
+
self.signal_connect "clicked" do
|
14
|
+
Window.instance.panel.button_start.runner.stop
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class ButtonStart < Gtk::Button
|
2
|
+
|
3
|
+
attr_reader :runner
|
4
|
+
|
5
|
+
def initialize text
|
6
|
+
super text
|
7
|
+
|
8
|
+
@text = text
|
9
|
+
add_click_event
|
10
|
+
end
|
11
|
+
|
12
|
+
def disable text
|
13
|
+
self.sensitive = false
|
14
|
+
self.label = text
|
15
|
+
end
|
16
|
+
|
17
|
+
def enable
|
18
|
+
self.sensitive = true
|
19
|
+
self.label = @text
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def add_click_event
|
25
|
+
self.signal_connect "clicked" do
|
26
|
+
cycles = break_time = Window.instance.panel.tf_cycles.text.to_i
|
27
|
+
|
28
|
+
pomodoro_time = Window.instance.panel.tf_pomodoro.text.to_i
|
29
|
+
pomodoro_time *= 60
|
30
|
+
|
31
|
+
pause_time = Window.instance.panel.tf_pause.text.to_i
|
32
|
+
pause_time *= 60
|
33
|
+
|
34
|
+
break_time = Window.instance.panel.tf_pause.text.to_i
|
35
|
+
break_time *= 60
|
36
|
+
|
37
|
+
unless InputValidator.validate pomodoro_time, pause_time, break_time, cycles
|
38
|
+
Window.instance.show_warning_dialog "Please, inform valid data for the pomodoro cycle."
|
39
|
+
else
|
40
|
+
disable "Running pomodoro..."
|
41
|
+
|
42
|
+
@runner = CycleRunner.new cycles, pomodoro_time, pause_time, break_time
|
43
|
+
@runner.run
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/gui/panel.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
class Panel < Gtk::VBox
|
2
|
+
|
3
|
+
attr_reader :tf_pomodoro, :tf_pause, :tf_break, :tf_cycles,
|
4
|
+
:hb_start, :progress_bar, :button_start
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super true, 2
|
8
|
+
|
9
|
+
@tf_pomodoro = TextField.new "Pomodoro time: ", "25"
|
10
|
+
@tf_pause = TextField.new "Pause time: ", "5"
|
11
|
+
@tf_break = TextField.new "Break time: ", "30"
|
12
|
+
@tf_cycles = TextField.new "How many pomodoros until break? ", "2"
|
13
|
+
@hb_buttons = Gtk::HBox.new true, 10
|
14
|
+
@button_start = ButtonStart.new "Start!"
|
15
|
+
@button_cancel = ButtonCancel.new "Cancel"
|
16
|
+
@progress_bar = ProgressBar.new
|
17
|
+
|
18
|
+
@hb_buttons.add @button_start
|
19
|
+
@hb_buttons.add @button_cancel
|
20
|
+
|
21
|
+
self.add @tf_pomodoro
|
22
|
+
self.add @tf_pause
|
23
|
+
self.add @tf_break
|
24
|
+
self.add @tf_cycles
|
25
|
+
self.add @hb_buttons
|
26
|
+
self.add @progress_bar
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class TextField < Gtk::HBox
|
2
|
+
|
3
|
+
def initialize label_text, value
|
4
|
+
super true, 10
|
5
|
+
|
6
|
+
@label = Gtk::Label.new label_text
|
7
|
+
@entry = Gtk::Entry.new
|
8
|
+
@entry.text = value
|
9
|
+
|
10
|
+
self.add @label
|
11
|
+
self.add @entry
|
12
|
+
end
|
13
|
+
|
14
|
+
def text
|
15
|
+
@entry.text
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/gui/window.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class Window < Gtk::Window
|
2
|
+
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
attr_reader :panel
|
6
|
+
|
7
|
+
def initialize title = "Pomo-ruby"
|
8
|
+
super
|
9
|
+
|
10
|
+
@panel = Panel.new
|
11
|
+
|
12
|
+
self.add panel
|
13
|
+
self.show_all
|
14
|
+
self.title = title
|
15
|
+
self.allow_grow = false
|
16
|
+
self.window_position = Gtk::Window::POS_CENTER_ALWAYS
|
17
|
+
|
18
|
+
icon_path = File.dirname(__FILE__)+"/../images/tomato.png"
|
19
|
+
|
20
|
+
self.icon = Gdk::Pixbuf.new icon_path
|
21
|
+
|
22
|
+
add_close_event
|
23
|
+
end
|
24
|
+
|
25
|
+
def pop_up
|
26
|
+
self.keep_above = true
|
27
|
+
self.keep_above = false
|
28
|
+
end
|
29
|
+
|
30
|
+
def show_warning_dialog message
|
31
|
+
dialog = create_warning_dialog message
|
32
|
+
dialog.run
|
33
|
+
dialog.destroy
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def create_warning_dialog message
|
39
|
+
dialog = Gtk::MessageDialog.new(
|
40
|
+
self,
|
41
|
+
Gtk::Dialog::MODAL,
|
42
|
+
Gtk::MessageDialog::WARNING,
|
43
|
+
Gtk::MessageDialog::BUTTONS_CLOSE,
|
44
|
+
message
|
45
|
+
)
|
46
|
+
|
47
|
+
dialog.window_position = Gtk::Window::POS_CENTER_ALWAYS
|
48
|
+
dialog
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_close_event
|
52
|
+
self.signal_connect "destroy" do
|
53
|
+
puts "Exiting pomo-ruby..."
|
54
|
+
Gtk.main_quit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
data/lib/pomo_ruby.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'gtk2'
|
3
|
+
require 'core/timer'
|
4
|
+
require 'core/cycle_runner'
|
5
|
+
require 'core/input_validator'
|
6
|
+
require 'gui/button_start'
|
7
|
+
require 'gui/button_cancel'
|
8
|
+
require 'gui/text_field'
|
9
|
+
require 'gui/panel'
|
10
|
+
require 'gui/window'
|
11
|
+
require 'gui/progress_bar'
|
12
|
+
|
13
|
+
window = Window.instance
|
14
|
+
Gtk.main
|
data/pomo-ruby.gemspec
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pomo-ruby}
|
8
|
+
s.version = "0.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Pedro Dias"]
|
12
|
+
s.date = %q{2010-10-23}
|
13
|
+
s.default_executable = %q{pomo-ruby}
|
14
|
+
s.description = %q{Pomo-ruby is an standalone application written in Ruby/GTK with simple GUI to manage your time based on the Pomodoro technique.}
|
15
|
+
s.email = %q{pedro.capaca@gmail.com}
|
16
|
+
s.executables = ["pomo-ruby"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"bin/pomo-ruby",
|
25
|
+
"lib/core/cycle_runner.rb",
|
26
|
+
"lib/core/input_validator.rb",
|
27
|
+
"lib/core/timer.rb",
|
28
|
+
"lib/gui/button_cancel.rb",
|
29
|
+
"lib/gui/button_start.rb",
|
30
|
+
"lib/gui/panel.rb",
|
31
|
+
"lib/gui/progress_bar.rb",
|
32
|
+
"lib/gui/text_field.rb",
|
33
|
+
"lib/gui/window.rb",
|
34
|
+
"lib/images/tomato.ico",
|
35
|
+
"lib/images/tomato.jpg",
|
36
|
+
"lib/images/tomato.png",
|
37
|
+
"lib/pomo_ruby.rb",
|
38
|
+
"pomo-ruby.gemspec"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/capaca/pomo-ruby}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.3.7}
|
44
|
+
s.summary = %q{A simple application to run your Pomodoros in linux writen in GTK.}
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
else
|
52
|
+
end
|
53
|
+
else
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pomo-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pedro Dias
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-23 00:00:00 -02:00
|
19
|
+
default_executable: pomo-ruby
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Pomo-ruby is an standalone application written in Ruby/GTK with simple GUI to manage your time based on the Pomodoro technique.
|
23
|
+
email: pedro.capaca@gmail.com
|
24
|
+
executables:
|
25
|
+
- pomo-ruby
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- README.rdoc
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- bin/pomo-ruby
|
35
|
+
- lib/core/cycle_runner.rb
|
36
|
+
- lib/core/input_validator.rb
|
37
|
+
- lib/core/timer.rb
|
38
|
+
- lib/gui/button_cancel.rb
|
39
|
+
- lib/gui/button_start.rb
|
40
|
+
- lib/gui/panel.rb
|
41
|
+
- lib/gui/progress_bar.rb
|
42
|
+
- lib/gui/text_field.rb
|
43
|
+
- lib/gui/window.rb
|
44
|
+
- lib/images/tomato.ico
|
45
|
+
- lib/images/tomato.jpg
|
46
|
+
- lib/images/tomato.png
|
47
|
+
- lib/pomo_ruby.rb
|
48
|
+
- pomo-ruby.gemspec
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/capaca/pomo-ruby
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options:
|
55
|
+
- --charset=UTF-8
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.7
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: A simple application to run your Pomodoros in linux writen in GTK.
|
83
|
+
test_files: []
|
84
|
+
|