pomodoro_timer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pomodoro_timer.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Hugo Roque
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Pomodoro Timer #
2
+ ***
3
+ ### Description ###
4
+ A simple project to count your pomodoros time.
5
+
6
+ ### How use it ###
7
+ First of all, install it...
8
+ gem install pomodoro-timer
9
+
10
+ After that you can open irb, require and include:
11
+ require 'rubygems'
12
+ require 'pomodoro_timer'
13
+ include PomodoroTimer
14
+
15
+
16
+ Now you have the methods:
17
+ * start: Start one pomodoro.
18
+ * status: Show if you are in break or work time and how much least to end.
19
+ * cancel: Cancel your pomodoro.
20
+
21
+
22
+ ### How it works ###
23
+ First: Calling the start method, your 25 minutes of work will start counting.
24
+ Second: When this time end a ding sound will be played and your 5 minutes of break will starts counting automaticaly.
25
+ Third: When break time ends you have to start another pomodoro manualy, using the start method.
26
+
27
+
28
+ Maybe you will want to ignore the break ding and work a litte more, it's okay, you can cancel the actual pomodoro and when you want take a break you can call the method start passing :break like this...
29
+ start :break
30
+
31
+
32
+ ### Limitations ###
33
+ * Was tested only in ubuntu, and I think that will not work in anothers OSs, because the gem uses the "aplay" built-in command to play the ding.
34
+ * Has no way to pause a pomodoro. (Puporsely)
35
+
36
+ ### About me ###
37
+ * _Name:_ Hugo Roque
38
+ * _Email:_ hugo.roque@caelum.com.br
39
+ * _Twitter:_ http://twitter.com/hugolnx
40
+ * _Blog:_ http://hugolnx.com/
41
+ * _Labs:_ http://lnxlabs.heroku.com/
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/lib/fixnum.rb ADDED
@@ -0,0 +1,5 @@
1
+ class Fixnum
2
+ def minutes
3
+ return self * 60
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module PomodoroTimer
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "pomodoro_timer/version"
2
+
3
+ module PomodoroTimer
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,68 @@
1
+ module PomodoroTimer
2
+ class Pomodoro
3
+ BEEP_SOUND = "resources/ding.wav"
4
+ WORK_TIME = 25.minutes
5
+ BREAK_TIME = 5.minutes
6
+
7
+ def initialize(what)
8
+ @start = Time.now
9
+ @thread = Thread.new do
10
+ @work_progress = Time.now
11
+ if what.to_s != "break"
12
+ puts "It's work time! (#{format(@work_progress)})"
13
+ while @work_progress - @start < WORK_TIME
14
+ @work_progress = Time.now
15
+ sleep 1
16
+ end
17
+ beep
18
+ end
19
+
20
+ puts "It's break time!(#{format(@work_progress)})"
21
+ @break_progress = Time.now
22
+ while @break_progress - @work_progress < BREAK_TIME
23
+ @break_progress = Time.now
24
+ sleep 1
25
+ end
26
+
27
+ puts "Pomodoro finished!(#{format(@break_progress)})"
28
+
29
+ beep
30
+ @finished = true
31
+ end
32
+ return nil
33
+ end
34
+
35
+ def show_status
36
+ if @finished
37
+ puts "It's done"
38
+ elsif @break_progress
39
+ puts "It's break time! (#{format_seconds(BREAK_TIME - (@break_progress-@work_progress))})"
40
+ else
41
+ puts "It's work time! (#{format_seconds(WORK_TIME - (@work_progress-@start))})"
42
+ end
43
+ end
44
+
45
+ def cancel
46
+ @thread.kill
47
+ @finished = true
48
+ end
49
+
50
+ def finished?
51
+ return @finished
52
+ end
53
+
54
+ private
55
+
56
+ def format(time)
57
+ return time.strftime("%H:%M")
58
+ end
59
+
60
+ def format_seconds(seconds)
61
+ return sprintf("%.2d:%.2d",seconds/60, seconds%60)
62
+ end
63
+
64
+ def beep
65
+ system "aplay #{File.join(File.dirname(__FILE__),"../#{BEEP_SOUND}")} --quiet"
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ module PomodoroTimer
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ require 'fixnum'
2
+ require 'pomodoro_timer/pomodoro'
3
+ require 'pomodoro_timer/version'
4
+
5
+ module PomodoroTimer
6
+ extend self
7
+
8
+ def start(what=nil)
9
+ @@pomodoro ||= nil
10
+ if @@pomodoro.nil? || @@pomodoro.finished?
11
+ @@pomodoro = Pomodoro.new(what)
12
+ else
13
+ puts "Exist another pomodoro running!"
14
+ end
15
+
16
+ return nil
17
+ end
18
+
19
+ def cancel
20
+ @@pomodoro.cancel
21
+ end
22
+
23
+ def status
24
+ @@pomodoro.show_status
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/pomodoro_timer/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Hugo Roque"]
6
+ gem.email = ["hugolnx@gmail.com"]
7
+ gem.description = %q{Helps handle your pomodoro time.}
8
+ gem.summary = "pomodoro_timer (#{PomodoroTimer::VERSION})"
9
+ gem.homepage = "https://github.com/hugolnx/pomodoro-timer"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "pomodoro_timer"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = PomodoroTimer::VERSION
17
+ end
Binary file
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pomodoro_timer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hugo Roque
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Helps handle your pomodoro time.
15
+ email:
16
+ - hugolnx@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/fixnum.rb
27
+ - lib/lib/pomodoro_timer.rb
28
+ - lib/lib/pomodoro_timer/version.rb
29
+ - lib/pomodoro_timer.rb
30
+ - lib/pomodoro_timer/pomodoro.rb
31
+ - lib/pomodoro_timer/version.rb
32
+ - pomodoro_timer.gemspec
33
+ - resources/ding.wav
34
+ homepage: https://github.com/hugolnx/pomodoro-timer
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.15
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: pomodoro_timer (0.0.1)
58
+ test_files: []