teamocil 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/teamocil.rb +1 -1
- data/lib/teamocil/layout.rb +8 -5
- data/spec/fixtures/layouts.yml +9 -0
- data/spec/layout_spec.rb +41 -4
- metadata +12 -11
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -173,9 +173,7 @@ To get autocompletion when typing `teamocil <Tab>` in a zsh session, add this li
|
|
173
173
|
|
174
174
|
## Todo list
|
175
175
|
|
176
|
-
*
|
177
|
-
* Making sure the layout is valid before executing it
|
178
|
-
* Refactor the `Layout` class to make it “test-friendly”
|
176
|
+
* Making sure the layout is valid before executing it (ie. throw exceptions).
|
179
177
|
|
180
178
|
## Contributors
|
181
179
|
|
@@ -184,6 +182,8 @@ Feel free to contribute and submit issues/pull requests [on GitHub](https://gith
|
|
184
182
|
* Samuel Garneau ([garno](https://github.com/garno))
|
185
183
|
* Jimmy Bourassa ([jbourassa](https://github.com/jbourassa))
|
186
184
|
|
185
|
+
Take a look at the `spec` folder before you do, and make sure `bundle exec rake spec` passes after your modifications :)
|
186
|
+
|
187
187
|
## License
|
188
188
|
|
189
189
|
Teamocil is © 2011 [Rémi Prévost](http://exomel.com) and may be freely distributed under the [LITL license](http://litl.info/). See the `LICENSE` file.
|
data/lib/teamocil.rb
CHANGED
data/lib/teamocil/layout.rb
CHANGED
@@ -44,7 +44,8 @@ module Teamocil
|
|
44
44
|
@root = attrs["root"]
|
45
45
|
@options = attrs["options"]
|
46
46
|
@filters = attrs["filters"]
|
47
|
-
@splits = attrs["splits"]
|
47
|
+
@splits = attrs["splits"] || []
|
48
|
+
@splits = @splits.each_with_index.map { |split, index| Split.new(self, index, split) }
|
48
49
|
@index = index
|
49
50
|
@session = session
|
50
51
|
|
@@ -104,15 +105,17 @@ module Teamocil
|
|
104
105
|
commands = []
|
105
106
|
|
106
107
|
# Is it a vertical or horizontal split?
|
108
|
+
init_command = ""
|
107
109
|
unless @index == 0
|
108
110
|
if !@width.nil?
|
109
|
-
|
111
|
+
init_command = "tmux split-window -h -p #{@width}"
|
110
112
|
elsif !@height.nil?
|
111
|
-
|
113
|
+
init_command = "tmux split-window -p #{@height}"
|
112
114
|
else
|
113
|
-
|
115
|
+
init_command = "tmux split-window"
|
114
116
|
end
|
115
|
-
|
117
|
+
init_command << " -t #{@target}" unless @target.nil?
|
118
|
+
commands << init_command
|
116
119
|
end
|
117
120
|
|
118
121
|
# Wrap all commands around filters
|
data/spec/fixtures/layouts.yml
CHANGED
@@ -13,6 +13,7 @@ two-windows:
|
|
13
13
|
- cmd:
|
14
14
|
- "echo 'bar'"
|
15
15
|
- "echo 'bar in an array'"
|
16
|
+
target: bottom-right
|
16
17
|
- cmd: "echo 'bar again'"
|
17
18
|
width: 50
|
18
19
|
|
@@ -32,3 +33,11 @@ two-windows-with-filters:
|
|
32
33
|
- cmd: "echo 'foo'"
|
33
34
|
- cmd: "echo 'foo again'"
|
34
35
|
width: 50
|
36
|
+
|
37
|
+
three-windows-within-a-session:
|
38
|
+
session:
|
39
|
+
name: "my awesome session"
|
40
|
+
windows:
|
41
|
+
- name: "first window"
|
42
|
+
- name: "second window"
|
43
|
+
- name: "third window"
|
data/spec/layout_spec.rb
CHANGED
@@ -2,15 +2,19 @@ require File.join(File.dirname(__FILE__), "spec_helper.rb")
|
|
2
2
|
|
3
3
|
describe Teamocil::Layout do
|
4
4
|
|
5
|
-
context "initializing" do
|
6
|
-
end
|
7
|
-
|
8
5
|
context "compiling" do
|
9
6
|
|
10
|
-
before
|
7
|
+
before do # {{{
|
11
8
|
@layout = Teamocil::Layout.new(layouts["two-windows"], {})
|
12
9
|
end # }}}
|
13
10
|
|
11
|
+
it "creates windows" do # {{{
|
12
|
+
session = @layout.compile!
|
13
|
+
session.windows.each do |window|
|
14
|
+
window.should be_an_instance_of Teamocil::Layout::Window
|
15
|
+
end
|
16
|
+
end # }}}
|
17
|
+
|
14
18
|
it "creates windows with names" do # {{{
|
15
19
|
session = @layout.compile!
|
16
20
|
session.windows[0].name.should == "foo"
|
@@ -23,6 +27,13 @@ describe Teamocil::Layout do
|
|
23
27
|
session.windows[1].root.should == "/bar"
|
24
28
|
end # }}}
|
25
29
|
|
30
|
+
it "creates splits" do # {{{
|
31
|
+
session = @layout.compile!
|
32
|
+
session.windows.first.splits.each do |split|
|
33
|
+
split.should be_an_instance_of Teamocil::Layout::Split
|
34
|
+
end
|
35
|
+
end # }}}
|
36
|
+
|
26
37
|
it "creates splits with dimensions" do # {{{
|
27
38
|
session = @layout.compile!
|
28
39
|
session.windows.first.splits[0].width.should == nil
|
@@ -57,5 +68,31 @@ describe Teamocil::Layout do
|
|
57
68
|
session.windows.first.filters["after"].last.should == "echo second after filter"
|
58
69
|
end # }}}
|
59
70
|
|
71
|
+
it "should handle blank filters" do # {{{
|
72
|
+
session = @layout.compile!
|
73
|
+
session.windows.first.filters.should have_key "after"
|
74
|
+
session.windows.first.filters.should have_key "before"
|
75
|
+
session.windows.first.filters["after"].should be_empty
|
76
|
+
session.windows.first.filters["before"].should be_empty
|
77
|
+
end # }}}
|
78
|
+
|
79
|
+
it "should handle splits without a target" do # {{{
|
80
|
+
session = @layout.compile!
|
81
|
+
session.windows.last.splits.last.target.should == nil
|
82
|
+
end # }}}
|
83
|
+
|
84
|
+
it "should handle splits with a target" do # {{{
|
85
|
+
session = @layout.compile!
|
86
|
+
session.windows.last.splits.first.target.should == "bottom-right"
|
87
|
+
end # }}}
|
88
|
+
|
89
|
+
it "should handle windows within a session" do # {{{
|
90
|
+
layout = Teamocil::Layout.new(layouts["three-windows-within-a-session"], {})
|
91
|
+
session = layout.compile!
|
92
|
+
session.windows.length.should == 3
|
93
|
+
session.name.should == "my awesome session"
|
94
|
+
end # }}}
|
95
|
+
|
60
96
|
end
|
97
|
+
|
61
98
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamocil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- "R\xC3\xA9mi Pr\xC3\xA9vost"
|
@@ -14,12 +15,12 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-24 00:00:00 Z
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
20
21
|
name: rake
|
21
22
|
prerelease: false
|
22
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
24
|
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
@@ -29,11 +30,11 @@ dependencies:
|
|
29
30
|
- 0
|
30
31
|
version: "0"
|
31
32
|
type: :development
|
32
|
-
|
33
|
+
requirement: *id001
|
33
34
|
- !ruby/object:Gem::Dependency
|
34
35
|
name: rspec
|
35
36
|
prerelease: false
|
36
|
-
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
37
38
|
none: false
|
38
39
|
requirements:
|
39
40
|
- - ">="
|
@@ -43,11 +44,11 @@ dependencies:
|
|
43
44
|
- 0
|
44
45
|
version: "0"
|
45
46
|
type: :development
|
46
|
-
|
47
|
+
requirement: *id002
|
47
48
|
- !ruby/object:Gem::Dependency
|
48
49
|
name: yard
|
49
50
|
prerelease: false
|
50
|
-
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
51
52
|
none: false
|
52
53
|
requirements:
|
53
54
|
- - ">="
|
@@ -57,11 +58,11 @@ dependencies:
|
|
57
58
|
- 0
|
58
59
|
version: "0"
|
59
60
|
type: :development
|
60
|
-
|
61
|
+
requirement: *id003
|
61
62
|
- !ruby/object:Gem::Dependency
|
62
63
|
name: maruku
|
63
64
|
prerelease: false
|
64
|
-
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
65
66
|
none: false
|
66
67
|
requirements:
|
67
68
|
- - ">="
|
@@ -71,7 +72,7 @@ dependencies:
|
|
71
72
|
- 0
|
72
73
|
version: "0"
|
73
74
|
type: :development
|
74
|
-
|
75
|
+
requirement: *id004
|
75
76
|
description: Teamocil helps you set up window and splits layouts for tmux using YAML configuration files.
|
76
77
|
email: remi@exomel.com
|
77
78
|
executables:
|