terminal_multiplexer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/env CHANGED
@@ -12,6 +12,7 @@ class Default < Thor
12
12
  tmux.new_window
13
13
  tmux.new_window
14
14
  tmux.new_window('tests', 'guard')
15
+ tmux.active_window(2)
15
16
  tmux.start
16
17
  end
17
18
  end
@@ -1,3 +1,3 @@
1
1
  module Terminal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -28,9 +28,9 @@ module Terminal
28
28
  session
29
29
  end
30
30
 
31
- def new_window(name='tab', command='zsh', session_name='default')
32
- session = @sessions.find { |s| s.name == session_name }
33
31
 
32
+ def new_window(name='tab', command='zsh')
33
+ session = get_last_session
34
34
 
35
35
  if session == nil
36
36
  say "Warning: No valid session found. Create a default one"
@@ -41,8 +41,18 @@ module Terminal
41
41
 
42
42
  end
43
43
 
44
+ def active_window(num)
45
+ session = get_last_session
46
+ session.active_window(num)
47
+ end
48
+
49
+
44
50
  private
45
51
 
52
+ def get_last_session
53
+ @sessions[-1]
54
+ end
55
+
46
56
  def build_multiplexer_command_string
47
57
  m_str = @sessions.collect{ |s| s.plain}.join(' ')
48
58
  m_str
@@ -5,8 +5,9 @@ module Terminal
5
5
 
6
6
  describe Multiplexer do
7
7
 
8
+ let(:multi) { Multiplexer.new }
9
+
8
10
  describe "#new_session" do
9
- let(:multi) { Multiplexer.new }
10
11
 
11
12
  it "creates a new session with default name" do
12
13
  multi.new_session
@@ -33,27 +34,50 @@ module Terminal
33
34
  end
34
35
 
35
36
  describe "#new_window" do
36
- let(:multi) { Multiplexer.new }
37
-
38
37
  it "creates a new window for the default session" do
39
38
  multi.new_window
40
39
  multi.send(:build_multiplexer_command_string).should == "new-session -n default zsh\\; new-window -n tab zsh\\; select-window -t:+1\\;"
41
40
  end
42
- it "creates two session one with and one without a window if the session name doesn't match " do
41
+ it "creates a new window for \"session1\"" do
43
42
  multi.new_session('session1','ksh')
44
43
  multi.new_window
45
- multi.send(:build_multiplexer_command_string).should == "new-session -n session1 ksh\\; select-window -t:+1\\; new-session -n default zsh\\; new-window -n tab zsh\\; select-window -t:+1\\;"
44
+ multi.send(:build_multiplexer_command_string).should == "new-session -n session1 ksh\\; new-window -n tab zsh\\; select-window -t:+1\\;"
46
45
  end
47
46
 
48
- it "creates two session one with and one without a window if the session name doesn't match " do
47
+ it "creates a new window for session \"default\"" do
49
48
  multi.new_session
50
49
  multi.new_window
51
50
  multi.send(:build_multiplexer_command_string).should == "new-session -n default zsh\\; new-window -n tab zsh\\; select-window -t:+1\\;"
52
51
  end
53
52
 
54
- #it "creates a new window for a given session" do
55
- # multi.new_session
56
- #end
53
+ it "creates 2 windows in session1 and 2 windows in session2 (the last defined session, after creating the windows)" do
54
+ multi.new_session('session1','ksh')
55
+ multi.new_window('window1','ksh')
56
+ multi.new_window('window2','ksh')
57
+ multi.new_session('session2','ksh')
58
+ multi.new_window('window3','ksh')
59
+ multi.new_window('window4','ksh')
60
+ multi.send(:build_multiplexer_command_string).should == "new-session -n session1 ksh\\; new-window -n window1 ksh\\; new-window -n window2 ksh\\; select-window -t:+1\\; new-session -n session2 ksh\\; new-window -n window3 ksh\\; new-window -n window4 ksh\\; select-window -t:+1\\;"
61
+ end
62
+
63
+ end
64
+
65
+ describe "#active_window" do
66
+ it "selects the window from the last defined session" do
67
+ multi.new_session('session1','ksh')
68
+ multi.new_window('window1','ksh')
69
+ multi.new_window('window2','ksh')
70
+ multi.active_window(2)
71
+ multi.send(:build_multiplexer_command_string).should == "new-session -n session1 ksh\\; new-window -n window1 ksh\\; new-window -n window2 ksh\\; select-window -t:+2\\;"
72
+ end
73
+
74
+ it "doesn't matter where you place the window selector. It selects the window from the last defined session" do
75
+ multi.new_session('session1','ksh')
76
+ multi.active_window(2)
77
+ multi.new_window('window1','ksh')
78
+ multi.new_window('window2','ksh')
79
+ multi.send(:build_multiplexer_command_string).should == "new-session -n session1 ksh\\; new-window -n window1 ksh\\; new-window -n window2 ksh\\; select-window -t:+2\\;"
80
+ end
57
81
  end
58
82
  end
59
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal_multiplexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
16
- requirement: &11158060 !ruby/object:Gem::Requirement
16
+ requirement: &22895840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *11158060
24
+ version_requirements: *22895840
25
25
  description:
26
26
  email:
27
27
  - dev@fedux.org