lab42_tmux2 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7158e6273257e1c421f16fea52c591747202982d
4
- data.tar.gz: b85ee0e8e196f7c01ad3abb4bcc9d6c85d39235f
3
+ metadata.gz: 6b6fe48106bf796c4c3a16e0e0031c26f65600df
4
+ data.tar.gz: 8010ef98d1e5742c2865e003e0b030b1c72f4173
5
5
  SHA512:
6
- metadata.gz: 60f2393cd3256884abd746afa887acca2eafd3fd1ce2aee22077266380bee7ff19db4b507cd6a36ce3d1dacd90a994d16fcaa187a8a98129e0cd59d333a5919a
7
- data.tar.gz: 7b4de21e5069a8296a2038f24fe57c72125b8b743b741aa0654ff8f22b41a83561dac3aaae54abc804993db6c3fd8d9b1230f66684e45d0f9b5e4f9f44523a3e
6
+ metadata.gz: 23be8b8408635c826a19540db11e9388a0ee44bd5ee9d0bc80e83c4756c8cff14d7ed3b6dd1dea2f38e8a759429d7300acb7146ce864b506671bee22eb2e15f9
7
+ data.tar.gz: a12f3f65af2553b12f33a75c206d2417cc56978230be7b56f60d79cfe2a292715ca947c138a48c82a9dac384943018c50a7035552988af4b9382722e695715f5
data/README.md CHANGED
@@ -24,10 +24,6 @@ A simple API for launching tmux sessions from Ruby scripts
24
24
  require 'lab42/tmux/autoimport'
25
25
 
26
26
  session "vi_session" do
27
- configure do | c |
28
- c.home '.' # Would have been the default
29
- c.window_automatic_rename true # Default is false
30
- end
31
27
  new_window 'vi' do
32
28
  send_keys 'vi .'
33
29
  wait_for '.. (up a dir)' # NERDTree pane has loaded (not yet implemented)
@@ -40,6 +36,21 @@ A simple API for launching tmux sessions from Ruby scripts
40
36
  end
41
37
  ```
42
38
 
39
+ ### Configuration
40
+
41
+ ```ruby
42
+ require 'lab42/tmux/autoimport'
43
+
44
+ config do
45
+ window_automatic_rename true # now there will be no `set-window-option -g automatic-rename off`
46
+ end
47
+
48
+ session "sh-session" do
49
+ new_window 'console' # opens a second window
50
+ end
51
+
52
+ ```
53
+
43
54
  ### Hooks
44
55
 
45
56
  Add a `after_new_window` hook for tmux commands to be executed after the creation of a new
@@ -54,6 +65,40 @@ window.
54
65
  end
55
66
  ```
56
67
 
68
+ ### Window Events
69
+
70
+ The real use case for which Ruby was much better than shell scripts was the `wait_for` method
71
+ as it allows us to wait for some text in a pane to be shown before doing some action.
72
+
73
+ This is a real use case which will open vi with _NERDTree_, wait for NERDTree to split panes
74
+ and only then switch to the right hand side split pane (of vi, not tmux).
75
+
76
+ ```ruby
77
+
78
+ config
79
+ # options for wait_for
80
+ pre_wait_interval 0.1 # Before checking for text
81
+ post_wait_interval 0.1 # After text has shown up in pane
82
+ wait_timeout 4 # Do not wait longer than that
83
+
84
+ verbose true # Talk to stdout for post mortem analyse
85
+ end
86
+
87
+ new_session 'lab42_core' do
88
+ new_window 'vi' do
89
+ send_keys 'vi .'
90
+ wait_for "up a dir" do # Block will be executed iff text appears
91
+ # before timeout only
92
+ send_keys_raw 'C-w', 'l'
93
+ send_keys ':e README.md'
94
+ send_keys ':so local.vim'
95
+ send_keys_raw 'ziG'
96
+ end
97
+ # Script continues after timeout or appearance of text
98
+ # ...
99
+ end
100
+ end
101
+ ```
57
102
 
58
103
  ### Plugins
59
104
 
data/lib/lab42/tmux.rb CHANGED
@@ -5,9 +5,14 @@ require_relative 'tmux/session'
5
5
  module Lab42
6
6
  module Tmux
7
7
 
8
- def new_session session_name=nil, &block
8
+ def config &block
9
+ $config = Config.new
10
+ $config.instance_exec( &block )
11
+ end
12
+
13
+ def new_session session_name, &block
9
14
  raise ArgumentError, 'No block provided' unless block
10
- session = Session.new session_name || Config.session_name
15
+ session = Session.new session_name
11
16
  session.run &block
12
17
  end
13
18
 
@@ -30,7 +30,7 @@ module Lab42
30
30
  @session_name = sess_name
31
31
  @window_number = 0
32
32
  @commands = []
33
- @configuration = Config.new
33
+ @configuration = $config || Config.new
34
34
 
35
35
  self.class.instance self
36
36
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Lab42
3
3
  module Tmux
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end # module Tmux
6
6
  end # module Lab42
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lab42_tmux2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-08-17 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forwarder2