muxoro 0.0.1pre8 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cc5b60bd8786f3e20497355361a93ce7ca226d4
4
- data.tar.gz: d8cf5fbf4acfebe34b9068482efeb8e7e6e6fbcc
3
+ metadata.gz: 3af9fdf1e6c9afc1df32a58a822d017728a8709e
4
+ data.tar.gz: c0f0ae9858c406575ff90b02a69d1c545d120a42
5
5
  SHA512:
6
- metadata.gz: 0fc8b4a464dcd5c6d1f7bbd6b642b0a0b651df40d0c968920766e91b56234dc6d062d15c61fbc53d493d9593659a061b374649d85eb269f94da1faa71b11f529
7
- data.tar.gz: f61f588273d759a361a9fac3d39f593d2857eae577b2d910c2f04d21d7d9fe00887a3b82e4f391dc0c3968fe8512c47f8f6de8d8fe2ff806eb1f176cffbc1e39
6
+ metadata.gz: 802fad3ee58caad476c66b0f0fdb9f698c7c9a0909384733d6940e20b20b5a5a8c8450a597ca5aa06c5e90b4006e972578c944dbd2540446c26205e203adb896
7
+ data.tar.gz: 7051419c2602fdf78aaba96687c4be2a494f16b7b0c97e63d2b32c0879ff335fd5c5b0868e87d0e09fe4bc8257a0f11af45f59ede46082f461bfc176c1fb2e12
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.2@Muxoro
data/.tmux.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'lab42/tmux/auto_import'
2
+
3
+ def vi base_dir='.', colorscheme: nil, cmds: [], &block
4
+ new_window "vi_#{base_dir}" do
5
+ send_keys "vi #{base_dir}"
6
+ cmds = cmds.push ":colorscheme #{colorscheme}" if colorscheme
7
+ cmds.each do | cmd |
8
+ sleep 0.1
9
+ send_keys ":#{cmd}"
10
+ end
11
+ block.() if block
12
+ end
13
+ end
14
+
15
+ config do
16
+ pre_wait_interval 0.1
17
+ post_wait_interval 0.1
18
+ wait_timeout 4
19
+ verbose true
20
+ end
21
+ new_session 'Muxoro' do
22
+ after_new_window do
23
+ # send_keys 'rvm use @Lab42Core --create'
24
+ end
25
+ vi colorscheme: :morning
26
+ vi 'lib', colorscheme: :solarized, cmds: ['set background=dark']
27
+ new_window 'spec'
28
+ vi 'spec', colorscheme: 'solarized'
29
+ # wait_for "up a dir" do # 2B replaced by wait_for_NERDTree
30
+ # send_keys_raw 'C-w', 'l' # 2B replaced with vi_move_pane_right
31
+ # send_keys ':e proud.md'
32
+ # send_keys ':so proud.vim'
33
+ # send_keys_raw 'ziG'
34
+ # end
35
+ vi 'demo', colorscheme: 'maroloccio'
36
+ new_window 'qed'
37
+ new_window 'console' do
38
+ send_keys 'bundle exec pry'
39
+ end
40
+ new_window 'chex'
41
+ end
data/Gemfile.lock CHANGED
@@ -1,48 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- muxoro (0.0.1pre8)
5
- daemons (~> 1.1)
6
- lab42_options (~> 0.4)
4
+ muxoro (0.1.0)
5
+ daemons (~> 1.2)
6
+ lab42_core (~> 0.3)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- byebug (3.1.2)
12
- columnize (~> 0.8)
13
- debugger-linecache (~> 1.2)
14
11
  coderay (1.1.0)
15
- columnize (0.8.9)
16
- daemons (1.1.9)
17
- debugger-linecache (1.2.0)
12
+ daemons (1.2.3)
18
13
  diff-lcs (1.2.5)
19
- lab42_options (0.4.0)
14
+ forwarder2 (0.2.0)
15
+ lab42_core (0.3.3)
16
+ forwarder2 (~> 0.2)
20
17
  method_source (0.8.2)
21
- pry (0.9.12.6)
22
- coderay (~> 1.0)
23
- method_source (~> 0.8)
18
+ pry (0.10.1)
19
+ coderay (~> 1.1.0)
20
+ method_source (~> 0.8.1)
24
21
  slop (~> 3.4)
25
- pry-nav (0.2.3)
26
- pry (~> 0.9.10)
27
- rspec (2.14.1)
28
- rspec-core (~> 2.14.0)
29
- rspec-expectations (~> 2.14.0)
30
- rspec-mocks (~> 2.14.0)
31
- rspec-core (2.14.8)
32
- rspec-expectations (2.14.5)
33
- diff-lcs (>= 1.1.3, < 2.0)
34
- rspec-mocks (2.14.6)
35
- slop (3.5.0)
36
- timecop (0.7.1)
22
+ pry-nav (0.2.4)
23
+ pry (>= 0.9.10, < 0.11.0)
24
+ rspec (3.3.0)
25
+ rspec-core (~> 3.3.0)
26
+ rspec-expectations (~> 3.3.0)
27
+ rspec-mocks (~> 3.3.0)
28
+ rspec-core (3.3.2)
29
+ rspec-support (~> 3.3.0)
30
+ rspec-expectations (3.3.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.3.0)
33
+ rspec-mocks (3.3.2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.3.0)
36
+ rspec-support (3.3.0)
37
+ slop (3.6.0)
38
+ timecop (0.8.0)
37
39
 
38
40
  PLATFORMS
39
41
  ruby
40
42
 
41
43
  DEPENDENCIES
42
- bundler (~> 1.6)
43
- byebug (~> 3.1)
44
+ bundler (~> 1.10)
44
45
  muxoro!
45
- pry (~> 0.9)
46
+ pry (~> 0.10)
46
47
  pry-nav (~> 0.2)
47
- rspec (~> 2.14)
48
- timecop (~> 0.7)
48
+ rspec (~> 3.3)
49
+ timecop (~> 0.8)
50
+
51
+ BUNDLED WITH
52
+ 1.10.6
data/README.md CHANGED
@@ -1,29 +1,35 @@
1
1
  # muxoro
2
2
 
3
3
 
4
- Pomodoro Timer for Tmux Sessions
4
+ Pomodoro Timer for The Current Tmux Session
5
5
 
6
- ## Status
6
+ ## Usage
7
7
 
8
- ### AUAOR
9
8
 
10
- Alpha Use At Own Risk
9
+ ```
10
+ muxoro
11
+ ```
11
12
 
12
- In theory
13
+ Will launch a pomodoro timer with default behavior.
14
+
15
+ In other words it is the same as
13
16
 
14
17
  ```
15
- muxoro
18
+ muxoro time:25 sleep_interval:60 short_sleep_interval:10 orange_zone:300 red_zone:60 red_bg:black red_fg:red orange_bg:'#ffdd22' orange_fg:black
16
19
  ```
20
+ In order to get that stuff explained
17
21
 
18
- Will launch a pomodoro timer for all sessions or the current session.
22
+ ```
23
+ muxoro :help
24
+ ```
19
25
 
20
26
  ```
21
27
  muxoro stop
22
28
  ```
23
29
 
24
- Will kill the daemon and reset the status bar in all concerned sessions.
30
+ Will kill the daemon and reset the status bar.
31
+
25
32
 
26
- For more info read on, but very few other features work correctly right now.
27
33
 
28
34
 
29
35
  ## Ridiculously Fast Starting Guide
data/bin/muxoro CHANGED
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  args = ARGV.dup
4
- if %w{start stop}.include? ARGV.first
5
- args.shift
6
- else
7
- ARGV.unshift 'start'
8
- end
9
-
4
+ ARGV.unshift 'start' if ( args & %w{start stop status restart :help :fg} ).empty?
5
+
10
6
 
11
- $:.unshift File.expand_path '../../lib', __FILE__
12
7
 
13
- require 'muxoro/cli'
14
- require 'daemons'
8
+ require_relative '../lib/muxoro/cli'
15
9
 
16
- muxoro = Muxoro::CLI.new.init( args )
10
+ muxoro = Muxoro::CLI.new.init args
17
11
  reset_session = -> {
18
- muxoro.reset_sessions
12
+ muxoro.reset
19
13
  }
20
-
21
14
 
22
- Daemons.run_proc 'muxoro', stop_proc: reset_session do
23
- muxoro.run!
15
+ exit -1 if muxoro.help
16
+
17
+ if args.include? ':fg'
18
+ muxoro.run! %x{tmux display-message -p '#S'}
19
+ else
20
+ require 'daemons'
21
+ Daemons.run_proc 'muxoro', stop_proc: reset_session do
22
+ muxoro.run! %x{tmux display-message -p '#S'}
23
+ end
24
24
  end
data/lib/muxoro/cli.rb CHANGED
@@ -1,94 +1,132 @@
1
- require 'lab42/options'
2
-
1
+ # require 'logger'
2
+ require 'lab42/core'
3
+ require_relative 'tmux'
3
4
  module Muxoro
4
5
  class CLI
5
6
 
6
- attr_reader :options
7
+ attr_reader :help_asked, :time, :sleep_interval, :short_sleep_interval, :orange_zone, :red_zone, :red_bg, :orange_bg, :red_fg,:orange_fg
7
8
 
8
- def init args
9
- @sleepy = 60
10
- parser = Lab42::Options.new time: 25
11
- @options = parser.parse( args )
12
- @minutes = options.time.to_i
13
- if options.help
14
- puts 'muxoro [options]'
15
- puts "version: #{Muxoro::VERSION}"
16
- @norun = true
17
- elsif options.version
18
- puts "version: #{Muxoro::VERSION}"
19
- @norun = true
20
- end
21
- self
9
+ attr_reader :tmux
10
+
11
+ def help
12
+ return nil unless help_asked
13
+ $stderr.puts help_text
14
+ true
22
15
  end
23
16
 
24
- def reset_sessions
25
- @open_sessions.each do |s|
26
- system %{tmux set-option -qt #{s} status-left "Session: #{session_name s}"}
27
- end
17
+ def init args
18
+ @help_asked = args.include? ":help"
19
+ @time = get_int_from( args, 'time:', 25 ) * 60
20
+ @sleep_interval = get_int_from args, 'sleep_interval:', 60
21
+ @short_sleep_interval = get_int_from args, 'short_sleep_interval:', 10
22
+ @orange_zone = get_int_from args, 'orange_zone:', 300
23
+ @red_zone = get_int_from args, 'red_zone:',60
24
+ @red_bg = get_str_from args, 'red_bg:', 'red'
25
+ @orange_bg = get_str_from args, 'orange_bg:', '#882288'
26
+ @red_fg = get_str_from args, 'red_fg:', 'black'
27
+ @orange_fg = get_str_from args, 'orange_fg:', 'green'
28
+
29
+ # @logger = Logger.new File.expand_local_path{ %W{ .. .. log #{self.class.name.split("::").last}.log} }
30
+ # log "#{inspect} initialized"
31
+ self
28
32
  end
29
33
 
30
- def run args
31
- init args
32
- run!
34
+ def reset
35
+ tmux.set_left_status fg: 'cyan', time: '', bg: '#222222'
33
36
  end
34
37
 
35
- def run!
36
- return if @norun
37
- get_open_sessions
38
- run_sessions
39
- end_sessions
38
+ def run! session_name
39
+ # log ">>>run!"
40
+ @tmux = Tmux.new session_name # , @logger
41
+ # log "tmux created"
42
+ loop do
43
+ set_current_status
44
+ break if finished?
45
+ wait_tick
46
+ end
47
+ reset
40
48
  end
41
49
 
42
50
  private
43
- def compute_current_session_name
44
- session_number = ENV['TMUX'].split(',').last
45
- session_list = %x{tmux info}.split(/\n/)
46
- index = session_list.find_index{ |line| /\ASessions:/ === line }
47
- session_list = session_list.drop index.succ
48
- current_session = session_list.find{ |line| /\A #{session_number}:/ === line }
49
- current_session_name = current_session.split[1].sub(/:\z/,'')
51
+ def current_background
52
+ if red_zone?
53
+ red_bg
54
+ elsif orange_zone?
55
+ orange_bg
56
+ else
57
+ '#333333'
58
+ end
59
+ end
60
+ def current_foreground
61
+ if red_zone?
62
+ red_fg
63
+ elsif orange_zone?
64
+ orange_fg
65
+ else
66
+ 'cyan'
67
+ end
68
+ end
69
+ def current_time
70
+ time <= 60 ? "#{time}s" : "#{time/60}m"
50
71
  end
51
72
 
52
- def current_session_name
53
- @__current_session_name__ ||=
54
- compute_current_session_name
73
+ def finished?
74
+ time < 0
75
+ end
76
+ def get_int_from args, val, default
77
+ get_from( args, val, default ).to_i
78
+ end
79
+ def get_str_from args, val, default
80
+ get_from( args, val, default ).to_s
81
+ end
82
+ def get_from args, val, default
83
+ rgx = %r{\A#{val}}
84
+ args = args.grep rgx
85
+ return default if args.empty?
86
+ args.first.sub rgx, ''
55
87
  end
56
88
 
57
- def end_sessions
58
- @open_sessions.each do |s|
59
- system %{tmux set-option -qt #{s} status-left "#[fg=black,bg=red]Session: #{session_name s}|**"}
60
- end
61
- sleep @sleepy
62
- reset_sessions
63
- end
64
- def get_open_sessions
65
- if @options.sessions
66
- @open_sessions = @options.sessions.split ','
67
- elsif ENV['TMUX']
68
- @open_sessions = %w{:}
69
- else
70
- @open_sessions =
71
- %x{tmux ls}
72
- .split("\n")
73
- .map{|l| l.sub /:.*/, '' }
89
+ def help_text
90
+ <<-EOS
74
91
 
75
- raise RuntimeError, 'No tmux seessions running, aborting...' if @open_sessions.empty?
76
- $stderr.puts 'Continuing...'
77
- end
92
+ args are #{inspect}
93
+
94
+ -----------------------------------------------------------------------------------
95
+
96
+ muxoro [params]
97
+ stop stops the current muxoro timer and resets the session's display
98
+ :help shows this message and exits
99
+
100
+ All other parameters start a new muxoro timer daemon with the following behavior
101
+
102
+ time: in minutes defaults to 25
103
+ sleep_interval: updates in seconds defaults to 60
104
+ short_sleep_interval: updates in seconds in the red_zone defaults to 10
105
+ orange_zone: orange display of timer
106
+ red_zone: time left in seconds in which timer is displayed in red
107
+ oraneg_bg: defaults to '#ffdd22'
108
+ red_bg: defaults to 'red'
109
+ EOS
78
110
  end
79
111
 
80
- def run_sessions
81
- @minutes.downto( 1 ){ |m|
82
- @open_sessions.each do |s|
83
- system %{tmux set-option -qt #{s} status-left "Session: #{session_name s}|#{m}"}
84
- end
85
- sleep @sleepy
86
- }
112
+ def log msg
113
+ @logger.info msg if @logger
114
+ end
115
+ def orange_zone?
116
+ time <= orange_zone
117
+ end
118
+ def red_zone?
119
+ time <= red_zone
120
+ end
121
+ def set_current_status
122
+ # log ">>>#{__method__} bg: #{current_background}"
123
+ tmux.set_left_status bg: current_background, time: "[#{current_time}]", fg: current_foreground
87
124
  end
88
125
 
89
- def session_name s
90
- return s unless s == ":"
91
- current_session_name
126
+ def wait_tick
127
+ sleep_time = red_zone? ? short_sleep_interval : sleep_interval
128
+ @time -= sleep_time
129
+ sleep sleep_time
92
130
  end
93
- end # module CLI
131
+ end # class CLI
94
132
  end # module Muxoro
@@ -0,0 +1,32 @@
1
+ module Muxoro
2
+ class Tmux
3
+
4
+ attr_reader :current_session
5
+
6
+ def set_left_status fg: nil, time: '', bg: 'grey'
7
+ style = "bg=#{bg}"
8
+ style = "fg=#{fg},#{style}" if fg
9
+ tmux *%W{set-option -qt #{current_session} status-left-style #{style}}
10
+ tmux *(%W{set-option -qt #{current_session} status-left} + ["Session: #{current_session} #{time}".strip.inspect])
11
+ end
12
+
13
+ private
14
+ def initialize session_name, logger=nil
15
+ @current_session = session_name.chomp
16
+ @logger = logger
17
+ log "initialized"
18
+ end
19
+
20
+ def log *msg
21
+ return unless @logger
22
+ @logger.info "#{msg.join " "}"
23
+ end
24
+
25
+ def tmux *args
26
+ log "tmux", *args
27
+ system %{tmux #{args.join(' ')}}
28
+ end
29
+
30
+
31
+ end # class Tmux
32
+ end # module Muxoro
@@ -1,3 +1,3 @@
1
1
  module Muxoro
2
- VERSION = '0.0.1pre8'
2
+ VERSION = '0.1.0'
3
3
  end # module Muxoro
data/muxoro.gemspec CHANGED
@@ -19,39 +19,15 @@ Gem::Specification.new do | spec |
19
19
  spec.test_files = spec.files.grep(%r{\Atest|\Aspec|\Afeatures/})
20
20
  spec.require_paths = %w{lib}
21
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
22
 
46
23
  spec.required_rubygems_version = '>= 2.2.2'
47
24
 
48
- spec.add_dependency 'lab42_options', '~> 0.4'
49
- spec.add_dependency 'daemons', '~> 1.1'
25
+ spec.add_dependency 'daemons', '~> 1.2'
26
+ # spec.add_dependency 'lab42_core', '~> 0.3'
50
27
 
51
- spec.add_development_dependency 'bundler', '~> 1.6'
52
- spec.add_development_dependency 'rspec', '~> 2.14'
53
- spec.add_development_dependency 'pry', '~> 0.9'
28
+ spec.add_development_dependency 'bundler', '~> 1.10'
29
+ spec.add_development_dependency 'rspec', '~> 3.3'
30
+ spec.add_development_dependency 'pry', '~> 0.10'
54
31
  spec.add_development_dependency 'pry-nav', '~> 0.2'
55
- spec.add_development_dependency 'timecop', '~> 0.7'
56
- spec.add_development_dependency 'byebug', '~> 3.1'
32
+ spec.add_development_dependency 'timecop', '~> 0.8'
57
33
  end
metadata CHANGED
@@ -1,127 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muxoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1pre8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: daemons
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - ~>
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '1.1'
19
+ version: '1.2'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ~>
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '1.1'
26
+ version: '1.2'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ~>
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '1.6'
33
+ version: '1.10'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ~>
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '1.6'
40
+ version: '1.10'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ~>
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '2.14'
47
+ version: '3.3'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ~>
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '2.14'
54
+ version: '3.3'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pry
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ~>
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '0.9'
61
+ version: '0.10'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ~>
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '0.9'
68
+ version: '0.10'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: pry-nav
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ~>
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
75
  version: '0.2'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ~>
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0.2'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: timecop
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: '0.7'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: '0.7'
111
- - !ruby/object:Gem::Dependency
112
- name: byebug
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ~>
87
+ - - "~>"
116
88
  - !ruby/object:Gem::Version
117
- version: '3.1'
89
+ version: '0.8'
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
- - - ~>
94
+ - - "~>"
123
95
  - !ruby/object:Gem::Version
124
- version: '3.1'
96
+ version: '0.8'
125
97
  description: Launch a Pomodoro Timer from the command line
126
98
  email:
127
99
  - robert.dober@gmail.com
@@ -130,69 +102,42 @@ executables:
130
102
  extensions: []
131
103
  extra_rdoc_files: []
132
104
  files:
133
- - .gitignore
134
- - .rspec
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".ruby-version"
108
+ - ".tmux.rb"
135
109
  - Gemfile
136
110
  - Gemfile.lock
137
111
  - LICENSE
138
112
  - README.md
139
113
  - bin/muxoro
140
114
  - lib/muxoro/cli.rb
141
- - lib/muxoro/options_helper.rb
142
- - lib/muxoro/options_logic.rb
143
- - lib/muxoro/options_logic/constraints.rb
115
+ - lib/muxoro/tmux.rb
144
116
  - lib/muxoro/version.rb
145
117
  - 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
118
  homepage: https://github.com/RobertDober/muxoro
155
119
  licenses:
156
120
  - MIT
157
121
  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 "
122
+ post_install_message:
170
123
  rdoc_options: []
171
124
  require_paths:
172
125
  - lib
173
126
  required_ruby_version: !ruby/object:Gem::Requirement
174
127
  requirements:
175
- - - '>='
128
+ - - ">="
176
129
  - !ruby/object:Gem::Version
177
130
  version: '0'
178
131
  required_rubygems_version: !ruby/object:Gem::Requirement
179
132
  requirements:
180
- - - '>='
133
+ - - ">="
181
134
  - !ruby/object:Gem::Version
182
135
  version: 2.2.2
183
136
  requirements: []
184
137
  rubyforge_project:
185
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.4.6
186
139
  signing_key:
187
140
  specification_version: 4
188
141
  summary: Launch a Pomodoro Timer which updates the status line of all/given tmux sessions
189
142
  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
143
+ test_files: []
@@ -1,27 +0,0 @@
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
@@ -1,51 +0,0 @@
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
@@ -1,31 +0,0 @@
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
@@ -1,34 +0,0 @@
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 '', :wip 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
-
@@ -1,13 +0,0 @@
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
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,13 +0,0 @@
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
- require 'ostruct'
7
-
8
- RSpec.configure do |c|
9
- # c.treat_symbols_as_metadata_keys_with_true_values = true
10
- c.filter_run wip: true
11
- c.run_all_when_everything_filtered = true
12
- end
13
-
@@ -1,31 +0,0 @@
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
@@ -1,27 +0,0 @@
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
@@ -1,48 +0,0 @@
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
@@ -1,47 +0,0 @@
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