cli-pomodoro 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/bin/pom +3 -0
- data/lib/pom.rb +98 -0
- data/lib/pom/version.rb +3 -0
- data/pom.gemspec +19 -0
- data/resources/beep.m4a +0 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Sean Marcia
|
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,52 @@
|
|
1
|
+
# Pomodoro Timer #
|
2
|
+
***
|
3
|
+
|
4
|
+
### *Important Note* ###
|
5
|
+
This pomodoro gem only works on OSX 10.8.1 and later.
|
6
|
+
### Description ###
|
7
|
+
A simple command line tool (optimized for tmux) for mountain line for counting and maintaining your pomodoros.
|
8
|
+
|
9
|
+
### How use it ###
|
10
|
+
First of all, install it...
|
11
|
+
|
12
|
+
gem install cli-pomodoro
|
13
|
+
|
14
|
+
After installing the gem running it is simple:
|
15
|
+
|
16
|
+
$ pom
|
17
|
+
|
18
|
+
The command accepts the following, optional, flags: -t, -l
|
19
|
+
|
20
|
+
Use -t to change the default length of the pomodoro from 25 minutes to the inputted value. For example, the following will change the length of the pomodoros to 20 minutes:
|
21
|
+
|
22
|
+
$ pom -t 20
|
23
|
+
|
24
|
+
Use -l to change the default number of pomodoros that much occur before the user is given a long break. By default every 4 breaks will be a long break of 15 minutes rather than the short break time of 5 minutes. The following will cause long breaks to occur after everything 3rd pomodoro:
|
25
|
+
|
26
|
+
$ pom -l 3
|
27
|
+
|
28
|
+
The following will cause pomodoros to be 3 minutes and a 15 minute break to occur after every second pomodoro:
|
29
|
+
|
30
|
+
$ pom -t 3 -l 2
|
31
|
+
|
32
|
+
### Dependencies ###
|
33
|
+
This gem relies on the `terminal-nofifier` gem for the growl-like system notifications.
|
34
|
+
|
35
|
+
|
36
|
+
### Contributing ###
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
43
|
+
|
44
|
+
### FAQs ###
|
45
|
+
1. How do you change the notification icon? This is an issue for `terminal-notifier` which uses the application's icon for the notifications. You would need to change the Terminal.icns file to your new icon. More information can be found [here](https://github.com/alloy/terminal-notifier/issues/1).
|
46
|
+
2. Why is it a command line tool? I use tmux and found it fits well in one of the terminals.
|
47
|
+
|
48
|
+
|
49
|
+
License
|
50
|
+
-
|
51
|
+
|
52
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/pom
ADDED
data/lib/pom.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "pom/version"
|
4
|
+
require "ostruct"
|
5
|
+
require 'terminal-notifier'
|
6
|
+
|
7
|
+
module Pom
|
8
|
+
|
9
|
+
extend self
|
10
|
+
|
11
|
+
#! /usr/bin/ruby
|
12
|
+
options = ARGV
|
13
|
+
if options.include?('--help') || options.include?('-h')
|
14
|
+
puts "A simple pomodoro timer in ruby."
|
15
|
+
puts "Usage:"
|
16
|
+
puts "$ ruby pomodoro.rb [-l INT --t TIME]"
|
17
|
+
puts "INT: number of pomodoros before long break occurs"
|
18
|
+
puts "TIME: time (in minutes) of a single pomodoro"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
pomodoro_time = 25 # minutes
|
23
|
+
if i = options.index('-t')
|
24
|
+
pomodoro_time = options[i+1].to_i
|
25
|
+
if pomodoro_time == 0
|
26
|
+
puts "Invalid time specified."
|
27
|
+
exit(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@long_interval = 4 # minutes
|
32
|
+
if i = options.index('-l')
|
33
|
+
@long_interval = options[i+1].to_i
|
34
|
+
if @long_interval == 0
|
35
|
+
puts "Invalid interval specified."
|
36
|
+
exit(1)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def beep
|
41
|
+
system "afplay #{File.join(File.dirname(__FILE__),"../resources/beep.m4a")}"
|
42
|
+
end
|
43
|
+
|
44
|
+
notifier = 'terminal-notifier -title Pomodoro -message '
|
45
|
+
pomodoro = OpenStruct.new(:name => 'Pomodoro', :time => pomodoro_time * 60, :message => 'Pomodoro Time is up!', :notifier => notifier)
|
46
|
+
short_break = OpenStruct.new(:name => 'Short break', :time => 5 * 60, :message => 'Pomodoro Break is up!', :notifier => notifier)
|
47
|
+
long_break = OpenStruct.new(:name => 'Long break', :time => 15 * 60, :message => 'Pomodoro Break is up!', :notifier => notifier)
|
48
|
+
|
49
|
+
def start(chunk)
|
50
|
+
puts "\n#{chunk.name}!"
|
51
|
+
puts "started: #{Time.now.strftime('%H:%M')} (duration: #{chunk.time/60}m)"
|
52
|
+
end
|
53
|
+
|
54
|
+
def progress(time, number_of_updates)
|
55
|
+
duration = 1.0 * time / number_of_updates
|
56
|
+
progress_bar = ''
|
57
|
+
|
58
|
+
0.upto(number_of_updates) do |i|
|
59
|
+
percentage = (i * 1.0 / number_of_updates * 100).to_i
|
60
|
+
progress_bar << '|' << '==' * i << ' ' * (number_of_updates - i) << "| #{percentage}%\r"
|
61
|
+
|
62
|
+
print progress_bar
|
63
|
+
$stdout.flush
|
64
|
+
|
65
|
+
sleep duration
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def display_stats
|
70
|
+
puts "\nYou've completed #{@pomodoro_count} full pomodoros."
|
71
|
+
exit 0
|
72
|
+
end
|
73
|
+
|
74
|
+
def long_break_time?
|
75
|
+
@pomodoro_count % @long_interval == 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def finish(chunk)
|
79
|
+
`#{chunk.notifier} "#{chunk.message}"`
|
80
|
+
beep
|
81
|
+
end
|
82
|
+
|
83
|
+
def runit(chunk)
|
84
|
+
start(chunk)
|
85
|
+
progress(chunk.time, 20)
|
86
|
+
finish(chunk)
|
87
|
+
end
|
88
|
+
|
89
|
+
trap('INT') { display_stats }
|
90
|
+
|
91
|
+
@pomodoro_count = 0
|
92
|
+
loop do
|
93
|
+
runit(pomodoro)
|
94
|
+
@pomodoro_count += 1
|
95
|
+
long_break_time? ? runit(long_break) : runit(short_break)
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
data/lib/pom/version.rb
ADDED
data/pom.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pom/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "cli-pomodoro"
|
8
|
+
gem.version = Pom::VERSION
|
9
|
+
gem.authors = ["Sean Marcia"]
|
10
|
+
gem.email = ["sean@cs.uoregon.edu"]
|
11
|
+
gem.description = %q{Pomodoro Time Tracker Command Line App For Mountain Lion}
|
12
|
+
gem.summary = %q{Pomodoro App}
|
13
|
+
gem.homepage = "http://github.com/SeanMarcia/pom"
|
14
|
+
gem.add_dependency("terminal-notifier")
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = ["pom"]
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
data/resources/beep.m4a
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cli-pomodoro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sean Marcia
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: terminal-notifier
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Pomodoro Time Tracker Command Line App For Mountain Lion
|
31
|
+
email:
|
32
|
+
- sean@cs.uoregon.edu
|
33
|
+
executables:
|
34
|
+
- pom
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/pom
|
44
|
+
- lib/pom.rb
|
45
|
+
- lib/pom/version.rb
|
46
|
+
- pom.gemspec
|
47
|
+
- resources/beep.m4a
|
48
|
+
homepage: http://github.com/SeanMarcia/pom
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.24
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Pomodoro App
|
72
|
+
test_files: []
|