tmuxodoro 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e09e03af89e8b2a3ad8a547245ed87cdaddf2373
4
+ data.tar.gz: 3ab70098e7a9503f31256975bf2220b7e5b0fe87
5
+ SHA512:
6
+ metadata.gz: 49269d25b60572ce93b8788fbf4a30442a909e9b1030ca5cf9e5828ce38e05871e68f7a95842c9023b0bd984d037a7529ee7d40b6bd72fa6bdd5f08c33f89a63
7
+ data.tar.gz: f61d465bd347594aebd83035bb9b5ffcd0bb391e09641fba86c9c2bbe79dac18e1b7820f5d913d56d00691088a3c4073ab4b48427b1fd5301347cecada910166
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ tmuxodoro-*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.4.0
5
+ - 2.3.0
6
+ - 2.0.0
7
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tmuxodoro.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Timur Yanberdin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Tmuxodoro [![Build Status](https://travis-ci.org/mendab1e/tmuxodoro.svg?branch=master)](https://travis-ci.org/mendab1e/tmuxodoro)
2
+
3
+ **Tmuxodoro** is a minimalistic pomodoro timer designed for tmux.
4
+
5
+ It can display how many pomodoros remain
6
+
7
+ <img width="333" alt="screen shot 2017-04-12 at 01 55 05" src="https://cloud.githubusercontent.com/assets/854386/24934268/3875a202-1f23-11e7-9d1f-ed4659727809.png">
8
+
9
+ How much time remains until the end of a pomodoro
10
+
11
+ <img width="318" alt="screen shot 2017-04-12 at 01 55 40" src="https://cloud.githubusercontent.com/assets/854386/24934306/778fcf94-1f23-11e7-8c04-23d3acda1041.png">
12
+
13
+ And how much time remains for a rest
14
+
15
+ <img width="326" alt="screen shot 2017-04-12 at 01 56 04" src="https://cloud.githubusercontent.com/assets/854386/24934341/bb4714a4-1f23-11e7-9bed-9e162a816715.png">
16
+
17
+ tmuxodoro doesn't have any stupid notifications or other distraction sounds.
18
+
19
+
20
+
21
+ ## Installation
22
+
23
+ Check that you have Ruby >= 2.0 installed, then install tmuxodoro:
24
+
25
+ $ gem install tmuxodoro
26
+
27
+ ## Usage
28
+
29
+ You can run tmuxodoro with default configurations (8 tomatoes, 25 minutes per tomato and 5 minutes for a rest):
30
+
31
+ $ tmuxodoro
32
+
33
+ Or you can set configurations with ENV variables:
34
+
35
+ $ env TOMATOES=8 TOMATO_TIME=25 REST_TIME=5 tmuxodoro
36
+
37
+ Actually tmuxodoro is a pomodoro timer with HTTP interface, so you need to configure tmux to make requests via curl and display output to a statusbar.
38
+ Add the following line to `~/.tmux.conf`:
39
+
40
+ set -g status-left ' #(curl localhost:3080) '
41
+
42
+ You can select another port with `ENV['PORT']`, don't forget to change requests in this case.
43
+
44
+ To start a new pomodoro you need to send the following request:
45
+
46
+ $ curl localhost:3080/start
47
+
48
+ Also you can start it from tmux itself. For example, I've bind it to `prefix + p` (p is mnemonic to pomodoro). Add the following line to `~/.tmux.conf`:
49
+
50
+ bind p run-shell "curl localhost:3080/start"
51
+
52
+ To reset pomodoros you need to send the following request:
53
+
54
+ $ curl localhost:3080/restart
55
+
56
+ Similarly to the previous command, you can bind it to an any key and run from tmux.
57
+
58
+ Don't forget ro reload tmux config or restart tmux.
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at
63
+
64
+ https://github.com/mendab1e/tmuxodoro.
65
+
66
+
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tmuxodoro"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/tmuxodoro ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ MINUTE = 60
4
+
5
+ require 'tmuxodoro'
6
+
7
+ tomato_time = ENV['TOMATO_TIME'] ? ENV['TOMATO_TIME'].to_i * MINUTE : nil
8
+ rest_time = ENV['REST_TIME'] ? ENV['REST_TIME'].to_i * MINUTE : nil
9
+ tomatoes = ENV['TOMATOES'] ? ENV['TOMATOES'].to_i : nil
10
+
11
+ port = ENV['PORT'] || 3080
12
+
13
+ Tmuxodoro.run(
14
+ port,
15
+ tomatoes: tomatoes,
16
+ rest_time: rest_time,
17
+ tomato_time: tomato_time
18
+ )
@@ -0,0 +1,48 @@
1
+ class Pomodoro
2
+ MINUTE = 60
3
+
4
+ attr_reader :tomatoes, :tomato_time, :rest_time, :stop_at
5
+
6
+ def initialize(tomatoes: nil, tomato_time: nil, rest_time: nil)
7
+ @tomatoes = tomatoes || 8
8
+ @tomato_time = tomato_time || 25 * MINUTE
9
+ @rest_time = rest_time || 5 * MINUTE
10
+ end
11
+
12
+ def status
13
+ if is_active?
14
+ if work_time?
15
+ "work: #{remaining_work_time} min\n"
16
+ else
17
+ "rest: #{remaining_rest_time} min\n"
18
+ end
19
+ else
20
+ "🍅 #{tomatoes}\n"
21
+ end
22
+ end
23
+
24
+ def start
25
+ @tomatoes -= 1
26
+ @stop_at = Time.now + tomato_time
27
+ end
28
+
29
+ private
30
+
31
+ def is_active?
32
+ stop_at && Time.now < stop_at + rest_time
33
+ end
34
+
35
+ def work_time?
36
+ Time.now < stop_at
37
+ end
38
+
39
+ def remaining_work_time
40
+ return unless stop_at
41
+ ((stop_at - Time.now) / MINUTE).ceil
42
+ end
43
+
44
+ def remaining_rest_time
45
+ return unless stop_at
46
+ ((stop_at + rest_time - Time.now) / MINUTE).ceil
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module Tmuxodoro
2
+ VERSION = "0.1.0"
3
+ end
data/lib/tmuxodoro.rb ADDED
@@ -0,0 +1,31 @@
1
+ require 'tmuxodoro/version'
2
+ require 'tmuxodoro/pomodoro'
3
+ require 'webrick'
4
+
5
+ module Tmuxodoro
6
+ class << self
7
+ def run(port, args = {})
8
+ pomodoro = Pomodoro.new(args)
9
+ server = WEBrick::HTTPServer.new(Port: port)
10
+
11
+ server.mount_proc('/') do |req, resp|
12
+ resp['Content-Type'] = 'text/plain'
13
+ resp.body = pomodoro.status
14
+ end
15
+
16
+ server.mount_proc('/start') do |req, resp|
17
+ pomodoro.start
18
+ resp['Content-Type'] = 'text/plain'
19
+ resp.body = "New tomato has been started, it ends at #{pomodoro.stop_at}.\n"
20
+ end
21
+
22
+ server.mount_proc('/restart') do |req, resp|
23
+ pomodoro = Pomodoro.new(args)
24
+ resp['Content-Type'] = 'text/plain'
25
+ resp.body = "Tomatos have been reset\n"
26
+ end
27
+
28
+ server.start
29
+ end
30
+ end
31
+ end
data/tmuxodoro.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tmuxodoro/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tmuxodoro"
8
+ spec.version = Tmuxodoro::VERSION
9
+ spec.authors = ["Timur Yanberdin"]
10
+ spec.email = ["yanberdint@gmail.com"]
11
+
12
+ spec.summary = "Pomodoro timer for tmux"
13
+ spec.homepage = "https://github.com/mendab1e/tmuxodoro"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "bin"
20
+ spec.executables = "tmuxodoro"
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.13"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "timecop", "~> 0.8"
27
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tmuxodoro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Timur Yanberdin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: timecop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.8'
69
+ description:
70
+ email:
71
+ - yanberdint@gmail.com
72
+ executables:
73
+ - tmuxodoro
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - bin/tmuxodoro
87
+ - lib/tmuxodoro.rb
88
+ - lib/tmuxodoro/pomodoro.rb
89
+ - lib/tmuxodoro/version.rb
90
+ - tmuxodoro.gemspec
91
+ homepage: https://github.com/mendab1e/tmuxodoro
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.5.1
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Pomodoro timer for tmux
115
+ test_files: []