muxoro 0.0.1pre3
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.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +58 -0
- data/LICENSE +21 -0
- data/README.md +144 -0
- data/bin/muxoro +19 -0
- data/lib/muxoro/cli.rb +90 -0
- data/lib/muxoro/options_helper.rb +27 -0
- data/lib/muxoro/options_logic/constraints.rb +31 -0
- data/lib/muxoro/options_logic.rb +51 -0
- data/lib/muxoro/version.rb +3 -0
- data/muxoro.gemspec +57 -0
- data/spec/functional/cli/default_spec.rb +34 -0
- data/spec/functional/cli/help_spec.rb +13 -0
- data/spec/functional/cli/time_spec.rb +23 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/tmux_command_expectations.rb +31 -0
- data/spec/unit/options_helper/defaults_spec.rb +27 -0
- data/spec/unit/options_logic/base_spec.rb +48 -0
- data/spec/unit/options_logic/constraints_spec.rb +47 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 240759cd02cc7c51aabefe12da59f8e5ce2ef0cc
|
4
|
+
data.tar.gz: 2b2817340c3acd3ae8e8df353dc736d8ded7d605
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81a673d067afdc62bf763253014aff62463d6cc9eff696d67af8b60f3f3a90d80caffb732c67a63417fec3711480fac1588d3fc3577068032420a0be1ec5a9d4
|
7
|
+
data.tar.gz: 341eeac59738967d47da79597f8b76de9038a16797867d15d920855b6076b7fea49c5359cef69c768a361344e896e1c02115eb8921829e88aa8e7569688119fc
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
.tmux
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
muxoro (0.0.1.pre.pre)
|
5
|
+
daemons (~> 1.1.9)
|
6
|
+
lab42_options (~> 0.4.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
builder (3.2.2)
|
12
|
+
coderay (1.1.0)
|
13
|
+
cucumber (1.3.14)
|
14
|
+
builder (>= 2.1.2)
|
15
|
+
diff-lcs (>= 1.1.3)
|
16
|
+
gherkin (~> 2.12)
|
17
|
+
multi_json (>= 1.7.5, < 2.0)
|
18
|
+
multi_test (>= 0.1.1)
|
19
|
+
daemons (1.1.9)
|
20
|
+
diff-lcs (1.2.5)
|
21
|
+
gherkin (2.12.2)
|
22
|
+
multi_json (~> 1.3)
|
23
|
+
lab42_options (0.4.0)
|
24
|
+
method_source (0.8.2)
|
25
|
+
multi_json (1.9.2)
|
26
|
+
multi_test (0.1.1)
|
27
|
+
pry (0.9.12.6)
|
28
|
+
coderay (~> 1.0)
|
29
|
+
method_source (~> 0.8)
|
30
|
+
slop (~> 3.4)
|
31
|
+
pry-nav (0.2.3)
|
32
|
+
pry (~> 0.9.10)
|
33
|
+
rspec (3.0.0.beta2)
|
34
|
+
rspec-core (= 3.0.0.beta2)
|
35
|
+
rspec-expectations (= 3.0.0.beta2)
|
36
|
+
rspec-mocks (= 3.0.0.beta2)
|
37
|
+
rspec-core (3.0.0.beta2)
|
38
|
+
rspec-support (= 3.0.0.beta2)
|
39
|
+
rspec-expectations (3.0.0.beta2)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (= 3.0.0.beta2)
|
42
|
+
rspec-mocks (3.0.0.beta2)
|
43
|
+
rspec-support (= 3.0.0.beta2)
|
44
|
+
rspec-support (3.0.0.beta2)
|
45
|
+
slop (3.5.0)
|
46
|
+
timecop (0.7.1)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
bundler (~> 1.6.2)
|
53
|
+
cucumber (~> 1.3.14)
|
54
|
+
muxoro!
|
55
|
+
pry (~> 0.9.12)
|
56
|
+
pry-nav (~> 0.2.3)
|
57
|
+
rspec (~> 3.0.0.beta2)
|
58
|
+
timecop (~> 0.7.1)
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Robert Dober
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# muxoro
|
2
|
+
|
3
|
+
|
4
|
+
Pomodoro Timer for Tmux Sessions
|
5
|
+
|
6
|
+
## Status
|
7
|
+
|
8
|
+
### AUAOR
|
9
|
+
|
10
|
+
Alpha Use At Own Risk
|
11
|
+
|
12
|
+
In theory
|
13
|
+
|
14
|
+
```
|
15
|
+
muxoro
|
16
|
+
```
|
17
|
+
|
18
|
+
Will launch a pomodoro timer for all sessions or the current session.
|
19
|
+
|
20
|
+
```
|
21
|
+
muxoro stop
|
22
|
+
```
|
23
|
+
|
24
|
+
Will kill the daemon and reset the status bar in all concerned sessions.
|
25
|
+
|
26
|
+
For more info read on, but very few other features work correctly right now.
|
27
|
+
|
28
|
+
|
29
|
+
## Ridiculously Fast Starting Guide
|
30
|
+
|
31
|
+
```
|
32
|
+
gem install muxoro
|
33
|
+
muxoro
|
34
|
+
```
|
35
|
+
|
36
|
+
If in a tmux session update the current session only. Otherwise updates all tmux sessions'
|
37
|
+
left status with a Pomodoro timer of 25' counting down to 0.
|
38
|
+
This updates the status every minute.
|
39
|
+
|
40
|
+
## Improbably Fast Starting Guide
|
41
|
+
|
42
|
+
|
43
|
+
```
|
44
|
+
muxoro sessions: 0,Mine time:20
|
45
|
+
```
|
46
|
+
|
47
|
+
Updates sessions 0's and Mine's left status with a Pomodoro timer of 20' counting down to 0.
|
48
|
+
This still updates the status every minute.
|
49
|
+
|
50
|
+
|
51
|
+
## Fantastically Fast Starting Guide
|
52
|
+
|
53
|
+
|
54
|
+
```
|
55
|
+
muxoro :help
|
56
|
+
```
|
57
|
+
|
58
|
+
Which gives the following (unless I forgot to copy the latest version's output into the README of course)
|
59
|
+
|
60
|
+
```
|
61
|
+
Coming reallly really soon (before the gem's release in any case)
|
62
|
+
```
|
63
|
+
|
64
|
+
## Boringly Slow Examples
|
65
|
+
|
66
|
+
### Time Span Semantics
|
67
|
+
|
68
|
+
Indicate time spans in minutes (default) or seconds, this concerns the parameters `time`, `interval` and
|
69
|
+
`clearance`
|
70
|
+
|
71
|
+
```
|
72
|
+
muxoro time: 25, intervals: 20, clearance: 100s
|
73
|
+
```
|
74
|
+
|
75
|
+
A pomodoro timer for 25 minutes and 25 intervals (interval times computed to a value greater than one minute
|
76
|
+
are rounded). The interval between expiry and clearance of the status line is 1'40".
|
77
|
+
|
78
|
+
```
|
79
|
+
muxoro time: 20, interval: 3
|
80
|
+
```
|
81
|
+
|
82
|
+
This is ambigous, the implementation can do one of two things here, either (i) have a timer of a duration of
|
83
|
+
21' composed of 7 intervals, or (ii) a timer of 20' composed of 6 intervals of 3' and one last of 2'.
|
84
|
+
In order to avoid this potential ambiguity the following syntax is preferable:
|
85
|
+
|
86
|
+
```
|
87
|
+
muxoro interval: 3, intervals: 8
|
88
|
+
```
|
89
|
+
|
90
|
+
#### Clearance
|
91
|
+
|
92
|
+
By default muxoro will clear the status bar after an additional interval, but the duration of this
|
93
|
+
additional interval can be overridden by the `clearance` parameter.
|
94
|
+
|
95
|
+
The following will create a deafult timer of a duration of 25' and an interval of 1', but with
|
96
|
+
a clearance of 2'.
|
97
|
+
|
98
|
+
```
|
99
|
+
muxoro clearance: 2
|
100
|
+
```
|
101
|
+
|
102
|
+
### Format Semantics
|
103
|
+
|
104
|
+
For now only colors for the final status update (the one counting down to 0) can be given. They default to
|
105
|
+
`bg: red fg: black`.
|
106
|
+
|
107
|
+
```
|
108
|
+
muxoro fg: '#ff00dd', bg: '#ddaacc'
|
109
|
+
```
|
110
|
+
|
111
|
+
As tmux renders by approximating RGB colors to its 256 color map your milage may vary, in this case we will get
|
112
|
+
a pink background with a reddish font.
|
113
|
+
|
114
|
+
One can use color names too of course and set only background or forground.
|
115
|
+
|
116
|
+
```
|
117
|
+
muxoro fg: red
|
118
|
+
```
|
119
|
+
|
120
|
+
|
121
|
+
### Reading Parameters from a Configuration File
|
122
|
+
|
123
|
+
|
124
|
+
Coming Soon
|
125
|
+
|
126
|
+
|
127
|
+
## How it Works and Why
|
128
|
+
|
129
|
+
|
130
|
+
it is that complicated.
|
131
|
+
|
132
|
+
The idea was to create a daemon, which will send tmux configuration messages to all (indicated) sessions. The main reason for that
|
133
|
+
being able to run a pomodoro timer in a tmux session, which itself, is using a Ruby environment (e.g. rvm gemset) that does not
|
134
|
+
contain the _Muxoro_ gem itself.
|
135
|
+
|
136
|
+
However, when run in a tmux session, which is a common use case for folx installing this gem on purpose, the timer affects the
|
137
|
+
current session **only**.
|
138
|
+
|
139
|
+
|
140
|
+
There are for sure better maybe also simpler ways to achieve this.
|
141
|
+
|
142
|
+
## Credits
|
143
|
+
|
144
|
+
Daemoinizing has been a peace of cake thanx to the [daemons](http://daemons.rubyforge.org/) gem.
|
data/bin/muxoro
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ARGV.unshift 'start' if ARGV.first != 'start' && ARGV.first != 'stop'
|
4
|
+
|
5
|
+
|
6
|
+
$:.unshift File.expand_path '../../lib', __FILE__
|
7
|
+
|
8
|
+
require 'muxoro/cli'
|
9
|
+
require 'daemons'
|
10
|
+
|
11
|
+
muxoro = Muxoro::CLI.new.init( ARGV[1..-1] )
|
12
|
+
reset_session = -> {
|
13
|
+
muxoro.reset_sessions
|
14
|
+
}
|
15
|
+
|
16
|
+
|
17
|
+
Daemons.run_proc 'muxoro', stop_proc: reset_session do
|
18
|
+
muxoro.run!
|
19
|
+
end
|
data/lib/muxoro/cli.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'lab42/options'
|
2
|
+
|
3
|
+
module Muxoro
|
4
|
+
class CLI
|
5
|
+
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def init args
|
9
|
+
@sleepy = 60
|
10
|
+
@minutes = 25
|
11
|
+
parser = Lab42::Options.new
|
12
|
+
@options = parser.parse( args )
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset_sessions
|
17
|
+
@open_sessions.each do |s|
|
18
|
+
system %{tmux set-option -qt #{s} status-left "Session: #{session_name s}"}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def run args
|
23
|
+
init args
|
24
|
+
|
25
|
+
if options.help
|
26
|
+
puts 'muxoro [options]'
|
27
|
+
return
|
28
|
+
end
|
29
|
+
run!
|
30
|
+
end
|
31
|
+
|
32
|
+
def run!
|
33
|
+
get_open_sessions
|
34
|
+
run_sessions
|
35
|
+
end_sessions
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def compute_current_session_name
|
40
|
+
session_number = ENV['TMUX'].split(',').last
|
41
|
+
session_list = %x{tmux info}.split(/\n/)
|
42
|
+
index = session_list.find_index{ |line| /\ASessions:/ === line }
|
43
|
+
session_list = session_list.drop index.succ
|
44
|
+
current_session = session_list.find{ |line| /\A #{session_number}:/ === line }
|
45
|
+
current_session_name = current_session.split[1].sub(/:\z/,'')
|
46
|
+
end
|
47
|
+
|
48
|
+
def current_session_name
|
49
|
+
@__current_session_name__ ||=
|
50
|
+
compute_current_session_name
|
51
|
+
end
|
52
|
+
|
53
|
+
def end_sessions
|
54
|
+
@open_sessions.each do |s|
|
55
|
+
system %{tmux set-option -qt #{s} status-left "#[fg=black,bg=red]Session: #{session_name s}|**"}
|
56
|
+
end
|
57
|
+
sleep @sleepy
|
58
|
+
reset_sessions
|
59
|
+
end
|
60
|
+
def get_open_sessions
|
61
|
+
if @options.sessions
|
62
|
+
@open_sessions = @options.sessions.split ','
|
63
|
+
elsif ENV['TMUX']
|
64
|
+
@open_sessions = %w{:}
|
65
|
+
else
|
66
|
+
@open_sessions =
|
67
|
+
%x{tmux ls}
|
68
|
+
.split("\n")
|
69
|
+
.map{|l| l.sub /:.*/, '' }
|
70
|
+
|
71
|
+
raise RuntimeError, 'No tmux seessions running, aborting...' if @open_sessions.empty?
|
72
|
+
$stderr.puts 'Continuing...'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def run_sessions
|
77
|
+
@minutes.downto( 1 ){ |m|
|
78
|
+
@open_sessions.each do |s|
|
79
|
+
system %{tmux set-option -qt #{s} status-left "Session: #{session_name s}|#{m}"}
|
80
|
+
end
|
81
|
+
sleep @sleepy
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def session_name s
|
86
|
+
return s unless s == ":"
|
87
|
+
current_session_name
|
88
|
+
end
|
89
|
+
end # module CLI
|
90
|
+
end # module Muxoro
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Muxoro
|
2
|
+
class OptionsHelper
|
3
|
+
Defaults = {
|
4
|
+
time: 25,
|
5
|
+
interval: 1,
|
6
|
+
intervals: 21
|
7
|
+
}
|
8
|
+
|
9
|
+
Defaults.keys.each do | key |
|
10
|
+
define_method key do
|
11
|
+
__fetch key
|
12
|
+
end
|
13
|
+
define_method "#{key}?" do
|
14
|
+
@options.to_h.has_key? key
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def initialize options=OpenStruct.new
|
20
|
+
@options = options
|
21
|
+
end
|
22
|
+
|
23
|
+
def __fetch key
|
24
|
+
@options.to_h.fetch key, Defaults.fetch( key )
|
25
|
+
end
|
26
|
+
end # class OptionsHelper
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Muxoro
|
2
|
+
class OptionsLogic
|
3
|
+
module Constraints
|
4
|
+
|
5
|
+
def check_constraints!
|
6
|
+
@constraints.each do | constraint |
|
7
|
+
constraint.arity == 1 ? instance_eval( &constraint ) : instance_exec( &constraint )
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def and *conds, &blk
|
12
|
+
conds.each{ |e|
|
13
|
+
return false unless __bool e
|
14
|
+
}
|
15
|
+
blk.() if blk
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def not cond, &blk
|
20
|
+
return false if __bool cond
|
21
|
+
blk.() if blk
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def __bool e
|
27
|
+
Symbol === e ? @values.fetch( e, false ) : e
|
28
|
+
end
|
29
|
+
end # module Constraints
|
30
|
+
end # class OptionsLogic
|
31
|
+
end # module Muxoro
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'options_logic/constraints'
|
2
|
+
|
3
|
+
module Muxoro
|
4
|
+
class OptionsLogic
|
5
|
+
|
6
|
+
include Constraints
|
7
|
+
|
8
|
+
def set_constraints &blk
|
9
|
+
raise ArgumentError, 'no block given' unless blk
|
10
|
+
@constraints << blk
|
11
|
+
self
|
12
|
+
end
|
13
|
+
# Can be called without values just to reset the cache
|
14
|
+
def set_values values=nil
|
15
|
+
invalidate_cache!
|
16
|
+
return unless values
|
17
|
+
raise ArgumentError, "values provided must be a hash" unless Hash === values
|
18
|
+
@values = values
|
19
|
+
check_constraints!
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def get key, *default
|
24
|
+
return @cache[key] if @cache.has_key? key
|
25
|
+
@cache[key] = compute( key, *default )
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def initialize lookup_logic={}
|
30
|
+
@lookup = lookup_logic
|
31
|
+
invalidate_cache!
|
32
|
+
@values = {}
|
33
|
+
@constraints = []
|
34
|
+
end
|
35
|
+
|
36
|
+
def compute key, *default
|
37
|
+
return @values[key] if @values.has_key? key
|
38
|
+
return default.first unless default.empty?
|
39
|
+
# We are here because the cache is empty, and the key is not
|
40
|
+
# defined in the values hash.
|
41
|
+
# If there is no lookup logic we let the KeyError bubble up.
|
42
|
+
default = @lookup.fetch key
|
43
|
+
return default unless Proc === default
|
44
|
+
instance_exec( &default )
|
45
|
+
end
|
46
|
+
|
47
|
+
def invalidate_cache!
|
48
|
+
@cache = {}
|
49
|
+
end
|
50
|
+
end # class OptionsLogic
|
51
|
+
end # module Muxoro
|
data/muxoro.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
base = File.dirname __FILE__
|
3
|
+
$:.unshift File.join( base, 'lib' )
|
4
|
+
|
5
|
+
require 'muxoro/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do | spec |
|
8
|
+
spec.name = 'muxoro'
|
9
|
+
spec.version = Muxoro::VERSION
|
10
|
+
spec.authors = ['Robert Dober']
|
11
|
+
spec.email = %w{ robert.dober@gmail.com }
|
12
|
+
spec.description = %{Launch a Pomodoro Timer from the command line}
|
13
|
+
spec.summary = %{Launch a Pomodoro Timer which updates the status line of all/given tmux sessions with a pomodoro timer}
|
14
|
+
spec.homepage = %{https://github.com/RobertDober/muxoro}
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{\Atest|\Aspec|\Afeatures/})
|
20
|
+
spec.require_paths = %w{lib}
|
21
|
+
|
22
|
+
spec.post_install_message = %q{
|
23
|
+
|
24
|
+
+============================================================================+
|
25
|
+
| |
|
26
|
+
| Attention: This is an alpha quality pre-release, NO WARRANTY WHATSOEVER |
|
27
|
+
| |
|
28
|
+
+============================================================================+
|
29
|
+
|
30
|
+
Thanx for installing muxoro, launch your Pomodoro Timers from any command line
|
31
|
+
on your machine, specify the tmux sessions to show the timers, configure color
|
32
|
+
and intervals, have fun!
|
33
|
+
|
34
|
+
For the impatient, a 25' timer that shows in all tmux sessions or the current
|
35
|
+
session if launched inside a session, can be started via:
|
36
|
+
muxoro
|
37
|
+
|
38
|
+
Stop timer and reset status bar in all concerned sessions via:
|
39
|
+
muxoro stop
|
40
|
+
|
41
|
+
Any questions should be answered in the README https://github.com/RobertDober/muxoro
|
42
|
+
If not, please open an issue.
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
spec.required_rubygems_version = '>= 2.2.2'
|
47
|
+
|
48
|
+
spec.add_dependency 'lab42_options', '~> 0.4'
|
49
|
+
spec.add_dependency 'daemons', '~> 1.1'
|
50
|
+
|
51
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
52
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
53
|
+
spec.add_development_dependency 'cucumber', '~> 1.3'
|
54
|
+
spec.add_development_dependency 'pry', '~> 0.9'
|
55
|
+
spec.add_development_dependency 'pry-nav', '~> 0.2'
|
56
|
+
spec.add_development_dependency 'timecop', '~> 0.7'
|
57
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'muxoro/cli'
|
3
|
+
|
4
|
+
describe Muxoro::CLI do
|
5
|
+
|
6
|
+
context 'system interaction with default usage and no tmux sessions' do
|
7
|
+
before do
|
8
|
+
expect( subject )
|
9
|
+
.to receive( :` )
|
10
|
+
.with( 'tmux ls' )
|
11
|
+
.and_return ''
|
12
|
+
end
|
13
|
+
|
14
|
+
it do
|
15
|
+
expect( ->{ subject.run [] } ).to raise_error( RuntimeError, 'No tmux seessions running, aborting...' )
|
16
|
+
end
|
17
|
+
|
18
|
+
end # context 'system interaction with default usage'
|
19
|
+
|
20
|
+
context 'system interaction with default usage and two tmux sessions' do
|
21
|
+
before do
|
22
|
+
expect( subject ).to receive( :` )
|
23
|
+
.with( 'tmux ls' )
|
24
|
+
.ordered
|
25
|
+
.and_return "0: \ncustom: regrgz?dfez(-ç_çfzefg"
|
26
|
+
|
27
|
+
expect_sleeps seconds: 60, times: 26
|
28
|
+
expect_tmux_commands for_sessions: %w{0 custom}, with_values: 25.downto(1)
|
29
|
+
end
|
30
|
+
it{ subject.run [] }
|
31
|
+
end # context 'system interaction with default usage and two tmux sessions'
|
32
|
+
|
33
|
+
end # describe Muxoro::CLI
|
34
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'muxoro/cli'
|
3
|
+
|
4
|
+
describe Muxoro::CLI do
|
5
|
+
|
6
|
+
context 'No system interaction for help' do
|
7
|
+
before do
|
8
|
+
expect( subject ).not_to receive( :` )
|
9
|
+
end
|
10
|
+
it{ subject.run %w{ :help } }
|
11
|
+
end # context 'No system interaction for help'
|
12
|
+
|
13
|
+
end # describe Muxoro::CLI
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'muxoro/cli'
|
3
|
+
|
4
|
+
# describe Muxoro::CLI do
|
5
|
+
|
6
|
+
# context 'system interaction with time parameters in the current session' do
|
7
|
+
# ENV['TMUX'] = 'Some value'
|
8
|
+
|
9
|
+
# before do
|
10
|
+
# expect( subject ).to_not receive( :` )
|
11
|
+
# .with( 'tmux ls' )
|
12
|
+
|
13
|
+
# expect_sleeps seconds: 20, times: 61
|
14
|
+
# expect_tmux_commands with_values: %w{20'} +
|
15
|
+
# 19.downto(1).to_a.product( [ '40"', '20"', ''] ).map(&:join)
|
16
|
+
# end
|
17
|
+
|
18
|
+
# it{ subject.run %w{ time: 20 interval: 20s } }
|
19
|
+
|
20
|
+
# end # context 'system interaction with default usage and two tmux sessions'
|
21
|
+
|
22
|
+
# end # describe Muxoro::CLI
|
23
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
PROJECT_ROOT = File.expand_path "../..", __FILE__
|
4
|
+
$:.unshift File.join( PROJECT_ROOT, 'lib' )
|
5
|
+
Dir[File.join(PROJECT_ROOT,"spec/support/**/*.rb")].each {|f| require f}
|
6
|
+
|
7
|
+
RSpec.configure do |c|
|
8
|
+
# c.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
c.filter_run wip: true
|
10
|
+
c.run_all_when_everything_filtered = true
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module TmuxCommandExpectations
|
2
|
+
|
3
|
+
def expect_sleeps( seconds: required, times: required )
|
4
|
+
expect( subject ).to receive( :sleep ).with( seconds ).exactly( times ).times
|
5
|
+
end
|
6
|
+
|
7
|
+
def expect_tmux_commands( for_sessions: %w{:}, with_values: values )
|
8
|
+
|
9
|
+
# Countdown messages
|
10
|
+
with_values.each do | value |
|
11
|
+
for_sessions.each do | session |
|
12
|
+
expect( subject ).to receive( :system )
|
13
|
+
.with( %{tmux set-option -qt #{session} status-left "Session: #{session}|#{value}"} )
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# End and Clearing messages
|
19
|
+
for_sessions.each do | session |
|
20
|
+
expect( subject ).to receive( :system )
|
21
|
+
.with( %{tmux set-option -qt #{session} status-left "#[fg=black,bg=red]Session: #{session}|**"} )
|
22
|
+
expect( subject ).to receive( :system )
|
23
|
+
.with( %{tmux set-option -qt #{session} status-left "Session: #{session}"} )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end # module TmuxCommandExpectations
|
28
|
+
|
29
|
+
RSpec.configure do | cfg |
|
30
|
+
cfg.include TmuxCommandExpectations
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'muxoro/options_helper'
|
4
|
+
|
5
|
+
describe Muxoro::OptionsHelper do
|
6
|
+
|
7
|
+
context 'defaults' do
|
8
|
+
subject do
|
9
|
+
described_class.new OpenStruct.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'has a default time' do
|
13
|
+
expect( subject.time ).to eq( 25 )
|
14
|
+
expect( subject.time? ).to eq( false )
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has a default interval' do
|
18
|
+
expect( subject.interval ).to eq( 1 )
|
19
|
+
expect( subject.interval? ).to eq( false )
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has a default intervals' do
|
23
|
+
expect( subject.intervals ).to eq( 1 )
|
24
|
+
expect( subject.intervals? ).to eq( false )
|
25
|
+
end
|
26
|
+
end # context 'defaults'
|
27
|
+
end # descridobe Muxoro::OptionsHelper
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'muxoro/options_logic'
|
4
|
+
|
5
|
+
describe Muxoro::OptionsLogic do
|
6
|
+
context 'simple value logic' do
|
7
|
+
subject do
|
8
|
+
described_class.new( {
|
9
|
+
lhs: 1,
|
10
|
+
rhs: 2,
|
11
|
+
sum: ->{ get( :lhs ) + get( :rhs ) },
|
12
|
+
prod: ->{ get( :sum ) * get( :rhs ) }
|
13
|
+
} )
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with all defaults' do
|
17
|
+
before do
|
18
|
+
subject.set_values {}
|
19
|
+
end
|
20
|
+
it {
|
21
|
+
expect( subject.get( :lhs ) ).to eq( 1 )
|
22
|
+
}
|
23
|
+
it {
|
24
|
+
expect( subject.get( :sum ) ).to eq( 3 )
|
25
|
+
}
|
26
|
+
it {
|
27
|
+
expect( subject.get( :prod ) ).to eq( 6 )
|
28
|
+
}
|
29
|
+
end # context 'with all defaults'
|
30
|
+
|
31
|
+
context 'with some values' do
|
32
|
+
before do
|
33
|
+
subject.set_values rhs: 41, product: 0
|
34
|
+
end
|
35
|
+
it 'lhs is still default' do
|
36
|
+
expect( subject.get( :lhs ) ).to eq( 1 )
|
37
|
+
end
|
38
|
+
it 'but rhs is not' do
|
39
|
+
expect( subject.get( :rhs ) ).to eq( 41 )
|
40
|
+
end
|
41
|
+
it 'influences the computations too' do
|
42
|
+
expect( subject.get( :sum ) ).to eq( 42 )
|
43
|
+
expect( subject.get( :product ) ).to eq( 0 )
|
44
|
+
end
|
45
|
+
end # context 'with some values'
|
46
|
+
|
47
|
+
end # context 'simple value logic'
|
48
|
+
end # describe Muxoro::OptionsLogic
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'muxoro/options_logic'
|
4
|
+
|
5
|
+
def expect_value_of key
|
6
|
+
expect( subject.get key )
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Muxoro::OptionsLogic do
|
10
|
+
|
11
|
+
context 'constraints' do
|
12
|
+
subject do
|
13
|
+
described_class.new( {
|
14
|
+
periods: ->{ get( :duration, 20 ) / get( :period, 5 ) },
|
15
|
+
period: ->{ get( :duration, 20 ) / get( :periods ) },
|
16
|
+
duration: ->{ get( :periods ) * get( :period ) }
|
17
|
+
} ).set_constraints do |c|
|
18
|
+
c.and( :period, :duration, :periods ) do
|
19
|
+
raise ArgumentError, 'xxx'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'no constraint violation' do
|
25
|
+
it 'for periods and duration' do
|
26
|
+
subject.set_values periods: 1, duration: 10
|
27
|
+
expect_value_of( :period ).to eq( 10 )
|
28
|
+
end
|
29
|
+
it 'for period and periods' do
|
30
|
+
subject.set_values periods: 2, period: 5
|
31
|
+
expect_value_of( :duration ).to eq( 10 )
|
32
|
+
end
|
33
|
+
it 'for period and duration' do
|
34
|
+
subject.set_values period: 2, duration: 10
|
35
|
+
expect_value_of( :periods ).to eq( 5 )
|
36
|
+
end
|
37
|
+
end # context 'with all defaults'
|
38
|
+
|
39
|
+
it 'constraint violation' do
|
40
|
+
expect( ->{
|
41
|
+
subject.set_values period: 1, duration: 1, periods: 1
|
42
|
+
} ).to raise_error( ArgumentError, 'xxx' )
|
43
|
+
end # context 'constraint violation'
|
44
|
+
end # context 'constraints'
|
45
|
+
|
46
|
+
|
47
|
+
end # describe Muxoro::OptionsLogic
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: muxoro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1pre3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Dober
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lab42_options
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: daemons
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.9'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.9'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-nav
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.2'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: timecop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.7'
|
125
|
+
description: Launch a Pomodoro Timer from the command line
|
126
|
+
email:
|
127
|
+
- robert.dober@gmail.com
|
128
|
+
executables:
|
129
|
+
- muxoro
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .rspec
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- LICENSE
|
138
|
+
- README.md
|
139
|
+
- bin/muxoro
|
140
|
+
- lib/muxoro/cli.rb
|
141
|
+
- lib/muxoro/options_helper.rb
|
142
|
+
- lib/muxoro/options_logic.rb
|
143
|
+
- lib/muxoro/options_logic/constraints.rb
|
144
|
+
- lib/muxoro/version.rb
|
145
|
+
- muxoro.gemspec
|
146
|
+
- spec/functional/cli/default_spec.rb
|
147
|
+
- spec/functional/cli/help_spec.rb
|
148
|
+
- spec/functional/cli/time_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/support/tmux_command_expectations.rb
|
151
|
+
- spec/unit/options_helper/defaults_spec.rb
|
152
|
+
- spec/unit/options_logic/base_spec.rb
|
153
|
+
- spec/unit/options_logic/constraints_spec.rb
|
154
|
+
homepage: https://github.com/RobertDober/muxoro
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata: {}
|
158
|
+
post_install_message: "\n\n +============================================================================+\n
|
159
|
+
\ | |\n
|
160
|
+
\ | Attention: This is an alpha quality pre-release, NO WARRANTY WHATSOEVER |\n
|
161
|
+
\ | |\n
|
162
|
+
\ +============================================================================+\n\n
|
163
|
+
\ Thanx for installing muxoro, launch your Pomodoro Timers from any command line\n
|
164
|
+
\ on your machine, specify the tmux sessions to show the timers, configure color\n
|
165
|
+
\ and intervals, have fun!\n\n For the impatient, a 25' timer that shows in all
|
166
|
+
tmux sessions or the current\n session if launched inside a session, can be started
|
167
|
+
via:\n muxoro\n\n Stop timer and reset status bar in all concerned sessions
|
168
|
+
via:\n muxoro stop\n\n Any questions should be answered in the README https://github.com/RobertDober/muxoro\n
|
169
|
+
\ If not, please open an issue.\n "
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 2.2.2
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.2.2
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Launch a Pomodoro Timer which updates the status line of all/given tmux sessions
|
189
|
+
with a pomodoro timer
|
190
|
+
test_files:
|
191
|
+
- spec/functional/cli/default_spec.rb
|
192
|
+
- spec/functional/cli/help_spec.rb
|
193
|
+
- spec/functional/cli/time_spec.rb
|
194
|
+
- spec/spec_helper.rb
|
195
|
+
- spec/support/tmux_command_expectations.rb
|
196
|
+
- spec/unit/options_helper/defaults_spec.rb
|
197
|
+
- spec/unit/options_logic/base_spec.rb
|
198
|
+
- spec/unit/options_logic/constraints_spec.rb
|