tmuxinator 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -1
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +36 -0
  6. data/CONTRIBUTING.md +29 -0
  7. data/Gemfile +4 -7
  8. data/{LICENSE.txt → LICENSE} +1 -1
  9. data/README.md +128 -118
  10. data/Rakefile +1 -72
  11. data/bin/mux +8 -3
  12. data/bin/tmuxinator +8 -3
  13. data/completion/tmuxinator.bash +18 -0
  14. data/completion/tmuxinator.zsh +20 -0
  15. data/lib/tmuxinator.rb +13 -7
  16. data/lib/tmuxinator/assets/sample.yml +24 -11
  17. data/lib/tmuxinator/assets/template.erb +47 -0
  18. data/lib/tmuxinator/cli.rb +121 -145
  19. data/lib/tmuxinator/config.rb +92 -0
  20. data/lib/tmuxinator/deprecations.rb +19 -0
  21. data/lib/tmuxinator/pane.rb +36 -0
  22. data/lib/tmuxinator/project.rb +142 -0
  23. data/lib/tmuxinator/util.rb +14 -0
  24. data/lib/tmuxinator/version.rb +3 -0
  25. data/lib/tmuxinator/window.rb +76 -0
  26. data/spec/factories/projects.rb +17 -0
  27. data/spec/fixtures/sample.deprecations.yml +35 -0
  28. data/spec/fixtures/sample.yml +35 -0
  29. data/spec/lib/tmuxinator/cli_spec.rb +230 -0
  30. data/spec/lib/tmuxinator/config_spec.rb +121 -0
  31. data/spec/lib/tmuxinator/pane_spec.rb +7 -0
  32. data/spec/lib/tmuxinator/project_spec.rb +209 -0
  33. data/spec/lib/tmuxinator/util_spec.rb +4 -0
  34. data/spec/lib/tmuxinator/window_spec.rb +62 -0
  35. data/spec/spec_helper.rb +28 -8
  36. data/tmuxinator.gemspec +47 -65
  37. metadata +186 -62
  38. data/.document +0 -5
  39. data/Gemfile.lock +0 -28
  40. data/TODO +0 -4
  41. data/VERSION +0 -1
  42. data/bin/tmuxinator_completion +0 -29
  43. data/lib/tmuxinator/assets/tmux_config.tmux +0 -37
  44. data/lib/tmuxinator/config_writer.rb +0 -104
  45. data/lib/tmuxinator/helper.rb +0 -19
  46. data/spec/tmuxinator_spec.rb +0 -54
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Gemfile.lock DELETED
@@ -1,28 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.6.4)
7
- bundler (~> 1.0)
8
- git (>= 1.2.5)
9
- rake
10
- rake (0.9.2)
11
- rcov (0.9.10)
12
- rspec (2.6.0)
13
- rspec-core (~> 2.6.0)
14
- rspec-expectations (~> 2.6.0)
15
- rspec-mocks (~> 2.6.0)
16
- rspec-core (2.6.4)
17
- rspec-expectations (2.6.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.6.0)
20
-
21
- PLATFORMS
22
- ruby
23
-
24
- DEPENDENCIES
25
- bundler (~> 1.0.18)
26
- jeweler (~> 1.6.4)
27
- rcov (~> 0.9.10)
28
- rspec (~> 2.6.0)
data/TODO DELETED
@@ -1,4 +0,0 @@
1
- - no need to create .tmuxinator
2
- - Adding support for specifying global tmux options https://github.com/jbettcher/tmuxinator/commit/6f2cf2ec67ff018e1d629e4eae6421287e190086
3
- - release the iterminator version of this
4
- - flush the issues
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.5.0
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Tmuxinator command line completion.
4
-
5
- have=$(command -v tmuxinator)
6
-
7
- test -n "$have" &&
8
- _tmuxinator_commands_complete()
9
- {
10
- COMPREPLY=()
11
- if [ $COMP_CWORD = 1 ]; then
12
- local commands="open copy delete update_scripts implode list doctor help version"
13
- COMPREPLY=(`compgen -W "$commands" -- $2`)
14
- fi
15
- return 0
16
- }
17
-
18
- _tmuxinator_open_complete()
19
- {
20
- COMPREPLY=()
21
- if [ $COMP_CWORD = 1 ]; then
22
- local configs=`find ~/.tmuxinator/ -name *.yml | cut -d/ -f5 | sed s:.yml::g`
23
- COMPREPLY=(`compgen -W "$configs" -- $2`)
24
- fi
25
- return 0
26
- }
27
-
28
- complete -F _tmuxinator_commands_complete -o default tmuxinator mux
29
- complete -F _tmuxinator_open_complete -o default muxo
@@ -1,37 +0,0 @@
1
- #!<%= ENV['SHELL'] || '/bin/bash' %>
2
- tmux <%= socket %> start-server
3
-
4
- if ! $(tmux <%= socket %> has-session -t <%=s @project_name %>); then
5
- cd <%= @project_root || "." %>
6
- <%= @pre.kind_of?(Array) ? @pre.join(" && ") : @pre %>
7
- env TMUX= tmux <%= socket %> start-server \; set-option -g base-index 1 \; new-session -d -s <%=s @project_name %> -n <%=s @tabs[0].name %>
8
- tmux <%= socket %> set-option -t <%=s @project_name %> default-path <%= @project_root %>
9
-
10
- <% @tabs[1..-1].each_with_index do |tab, i| %>
11
- tmux <%= socket %> new-window -t <%= window(i+2) %> -n <%=s tab.name %>
12
- <% end %>
13
-
14
- # set up tabs and panes
15
- <% @tabs.each_with_index do |tab, i| %>
16
- # tab "<%= tab.name %>"
17
- <% if tab.command %>
18
- <%= send_keys(tab.command, i+1) %>
19
- <% elsif tab.panes %>
20
- <%= send_keys(tab.panes.shift, i+1) %>
21
- <% tab.panes.each do |pane| %>
22
- tmux <%= socket %> splitw -t <%= window(i+1) %>
23
- <%= send_keys(pane, i+1) %>
24
- <% end %>
25
- tmux <%= socket %> select-layout -t <%= window(i+1) %> <%=s tab.layout %>
26
- <% end %>
27
- <% end %>
28
-
29
- tmux <%= socket %> select-window -t <%= window(1) %>
30
-
31
- fi
32
-
33
- if [ -z $TMUX ]; then
34
- tmux <%= socket %> -u attach-session -t <%=s @project_name %>
35
- else
36
- tmux <%= socket %> -u switch-client -t <%=s @project_name %>
37
- fi
@@ -1,104 +0,0 @@
1
- module Tmuxinator
2
-
3
- class ConfigWriter
4
- attr_accessor :file_name, :file_path, :project_name, :project_root, :rvm, :tabs, :pre
5
-
6
- include Tmuxinator::Helper
7
-
8
- def initialize this_full_path=nil
9
- self.file_path = this_full_path if this_full_path
10
- end
11
-
12
- def file_path= full_path
13
- @file_path = full_path
14
- @file_name = File.basename full_path, '.yml'
15
- process_config! if full_path && File.exist?(full_path)
16
- end
17
-
18
- def write!
19
- raise "Unable to write with out a file_name defined" unless self.file_name
20
- tmp = File.open(config_path, 'w') {|f| f.write(render) }
21
- end
22
-
23
- def render
24
- ERB.new(IO.read(TMUX_TEMPLATE)).result(binding)
25
- end
26
-
27
- def config_path
28
- "#{root_dir}#{file_name}.tmux" if file_name
29
- end
30
-
31
- def socket
32
- "-L #{@socket_name}" if @socket_name
33
- end
34
-
35
- private
36
-
37
- def root_dir
38
- "$HOME/.tmuxinator/"
39
- end
40
-
41
- def process_config!
42
- begin
43
- yaml = YAML.load(File.read(file_path))
44
- rescue
45
- exit!("Invalid YAML file format.")
46
- end
47
-
48
- exit!("Your configuration file should include some tabs.") if yaml["tabs"].nil?
49
- exit!("Your configuration file didn't specify a 'project_root'") if yaml["project_root"].nil?
50
- exit!("Your configuration file didn't specify a 'project_name'") if yaml["project_name"].nil?
51
-
52
- @project_name = yaml["project_name"]
53
- @project_root = yaml["project_root"]
54
- @rvm = yaml["rvm"]
55
- @pre = build_command(yaml["pre"])
56
- @tabs = []
57
- @socket_name = yaml['socket_name']
58
-
59
- yaml["tabs"].each do |tab|
60
- t = OpenStruct.new
61
- t.name = tab.keys.first
62
- value = tab.values.first
63
-
64
- case value
65
- when Hash
66
- t.panes = (value["panes"] || ['']).map do |pane|
67
- build_command(pane)
68
- end
69
- t.layout = value["layout"]
70
- else
71
- t.command = build_command(value)
72
- end
73
- @tabs << t
74
- end
75
- end
76
-
77
- def parse_tabs tab_list
78
- end
79
-
80
- def shell_escape str
81
- "'#{str.to_s.gsub("'") { %('\'') }}'"
82
- end
83
- alias s shell_escape
84
-
85
- def window(i)
86
- "#{s @project_name}:#{i}"
87
- end
88
-
89
- def send_keys cmd, window_number
90
- return '' unless cmd
91
- "tmux #{socket} send-keys -t #{window(window_number)} #{s cmd} C-m"
92
- end
93
-
94
- def build_command(value)
95
- commands = [value].flatten.compact.reject { |c| c.strip.empty? }
96
- if @rvm
97
- commands.unshift "rvm use #{@rvm}"
98
- end
99
-
100
- commands.join ' && '
101
- end
102
- end
103
-
104
- end
@@ -1,19 +0,0 @@
1
- module Tmuxinator
2
- module Helper
3
-
4
- def exit!(msg)
5
- puts msg
6
- Kernel.exit(1)
7
- end
8
-
9
- def confirm!(msg)
10
- puts msg
11
- if %w(yes Yes YES y).include?(STDIN.gets.chop)
12
- yield
13
- else
14
- exit! "Aborting."
15
- end
16
- end
17
-
18
- end
19
- end
@@ -1,54 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Tmuxinator::ConfigWriter do
4
- context "With no defined filename" do
5
- its(:file_path){ should be_nil }
6
- its(:project_name){ should be_nil }
7
- its(:project_root){ should be_nil }
8
- its(:rvm){ should be_nil }
9
- its(:tabs){ should be_nil }
10
- its(:config_path){ should be_nil }
11
- its(:pre){ should be_nil }
12
- its(:socket){ should be_nil }
13
- end
14
-
15
- context "While Defining the filename on init" do
16
- subject{ Tmuxinator::ConfigWriter.new(SAMPLE_CONFIG) }
17
- its(:file_path){ should eql SAMPLE_CONFIG }
18
- its(:file_name){ should eql "sample" }
19
- end
20
-
21
- context "After filename has been defined" do
22
- before do
23
- subject.file_path = SAMPLE_CONFIG
24
- end
25
-
26
- its(:file_path){ should eql SAMPLE_CONFIG }
27
- its(:file_name){ should eql File.basename(SAMPLE_CONFIG, '.yml')}
28
- its(:project_name){ should eql 'Tmuxinator' }
29
- its(:project_root){ should eql '~/code/rails_project' }
30
- its(:rvm){ should eql '1.9.2@rails_project' }
31
- its(:tabs){ should be_an Array }
32
- its(:pre){ should eql 'rvm use 1.9.2@rails_project && sudo /etc/rc.d/mysqld start' }
33
- its(:socket){ should eql '-L foo' }
34
-
35
- let(:first_tab){ subject.tabs[0] }
36
-
37
- specify{ first_tab.should be_an OpenStruct }
38
- specify{ first_tab.name.should eql "editor" }
39
- specify{ first_tab.layout.should eql "main-vertical" }
40
- specify{ first_tab.panes.should be_an Array }
41
-
42
- it "should prepend each pane with the rvm string" do
43
- first_tab.panes.map{|p| p.split(/ && /)[0] }.should eql ["rvm use 1.9.2@rails_project"] * 3
44
- end
45
-
46
- it "should append each pane with the command string" do
47
- first_tab.panes.map{|p| p.split(/ && /)[1] }.should eql ["vim", nil, "top"]
48
- end
49
-
50
- let(:second_tab){ subject.tabs[1] }
51
- specify{ second_tab.name.should eql "shell" }
52
- specify{ second_tab.command.should eql "rvm use 1.9.2@rails_project && git pull"}
53
- end
54
- end