tmuxinator 0.6.8 → 0.6.9

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: 28b230df62265cc9e7487c362882d6724503c430
4
- data.tar.gz: 2e4aa507c3a1e5d0918244b0147c54d0b8dcca3e
3
+ metadata.gz: 60c188fb2f653399d19450cb82fddc9649e62983
4
+ data.tar.gz: efdf85185c8c00cee928a4b3e0114111d2efc406
5
5
  SHA512:
6
- metadata.gz: e397db0f981a7524b9106c4b47f2616aa5aff1486079c023ae8feacb936e8ee37b5617c60af5bebdfb03f354fd13063ccf6ca4cda9fd033dacacb01d5184f46f
7
- data.tar.gz: 0540b6d4bf2a5c1ab271368ad4d64393a469e380bdab750fefe8957fd3a14764c8cad5fa71be59ad61a9c7a15576453cffa1762a3a221729353fe7d32bda4585
6
+ metadata.gz: a9014d3cbacead8062969fc79059631e72683bd746b4139f4d67d23f9a5886fbe4626ef5de8d5b92fa2c2420fb67782e47ce6db31100881594a02c64c2f76412
7
+ data.tar.gz: c49b1ab81d626ed96711ab0df8e7eb142e1bc81683ab6dc4d371236956e16477504d8211273bf242b4bc2b32c83a5b0d1e63aa576350dd1b19b9697811cc4de0
@@ -2,6 +2,7 @@ require "yaml"
2
2
  require "erubis"
3
3
  require "shellwords"
4
4
  require "thor"
5
+ require "thor/version"
5
6
 
6
7
  require "tmuxinator/util"
7
8
  require "tmuxinator/deprecations"
@@ -15,3 +16,9 @@ require "tmuxinator/version"
15
16
 
16
17
  module Tmuxinator
17
18
  end
19
+
20
+ class Object
21
+ def blank?
22
+ respond_to?(:empty?) ? !!empty? : !self
23
+ end
24
+ end
@@ -1,4 +1,9 @@
1
1
  #!<%= ENV["SHELL"] || "/bin/bash" %>
2
+
3
+ # Clear rbenv variables before starting tmux
4
+ unset RBENV_VERSION
5
+ unset RBENV_DIR
6
+
2
7
  <%= tmux %> start-server\; has-session -t <%= name %> 2>/dev/null
3
8
 
4
9
  if [ "$?" -eq 1 ]; then
@@ -12,7 +17,9 @@ if [ "$?" -eq 1 ]; then
12
17
 
13
18
  <%- if Tmuxinator::Config.version < 1.7 -%>
14
19
  # Set the default path for versions prior to 1.7
15
- <%= tmux %> set-option -t <%= name %> <%= Tmuxinator::Config.default_path_option %> <%= root.shellescape -%> 1>/dev/null
20
+ <%- if root? -%>
21
+ <%= tmux %> set-option -t <%= name %> <%= Tmuxinator::Config.default_path_option %> <%= root -%> 1>/dev/null
22
+ <%- end -%>
16
23
  <%- end -%>
17
24
 
18
25
  # Create other windows.
@@ -11,7 +11,9 @@ if [ "$?" -eq 127 ]; then
11
11
  TMUX= <%= tmux %> new-session -d -s <%= name %> -n <%= windows.first.name %>
12
12
 
13
13
  # Set the default path.
14
- <%= tmux %> set-option -t <%= name %> default-path <%= root.shellescape -%> 1>/dev/null
14
+ <%- if root? -%>
15
+ <%= tmux %> set-option -t <%= name %> <%= Tmuxinator::Config.default_path_option %> <%= root -%> 1>/dev/null
16
+ <%- end -%>
15
17
 
16
18
  # Create other windows.
17
19
  <%- windows.drop(1).each do |window| -%>
@@ -9,7 +9,7 @@ module Tmuxinator
9
9
  @command_list = %w(commands copy debug delete doctor help implode list start version)
10
10
  end
11
11
 
12
- package_name "tmuxinator"
12
+ package_name "tmuxinator" unless Gem::Version.create(Thor::VERSION) < Gem::Version.create("0.18")
13
13
 
14
14
  desc "commands", "Lists commands available in tmuxinator"
15
15
 
@@ -76,14 +76,11 @@ module Tmuxinator
76
76
 
77
77
  exit!("Project #{existing} doesn't exist!") unless Tmuxinator::Config.exists?(existing)
78
78
 
79
- if Tmuxinator::Config.exists?(new)
80
- if yes?("#{new} already exists, would you like to overwrite it?", :red)
81
- FileUtils.rm(new_config_path)
82
- say "Overwriting #{new}"
83
- end
79
+ if !Tmuxinator::Config.exists?(new) or yes?("#{new} already exists, would you like to overwrite it?", :red)
80
+ say "Overwriting #{new}" if Tmuxinator::Config.exists?(new)
81
+ FileUtils.copy_file(existing_config_path, new_config_path)
84
82
  end
85
83
 
86
- FileUtils.copy_file(existing_config_path, new_config_path)
87
84
  Kernel.system("$EDITOR #{new_config_path}")
88
85
  end
89
86
 
@@ -19,7 +19,7 @@ module Tmuxinator
19
19
  end
20
20
 
21
21
  def installed?
22
- Kernel.system("which tmux > /dev/null")
22
+ Kernel.system("type tmux > /dev/null")
23
23
  end
24
24
 
25
25
  def version
@@ -84,13 +84,9 @@ module Tmuxinator
84
84
  exit!
85
85
  end
86
86
 
87
- unless project.root?
88
- puts "Your project file didn't specify a 'project_root'"
89
- exit!
90
- end
91
-
92
87
  unless project.name?
93
88
  puts "Your project file didn't specify a 'project_name'"
89
+ exit!
94
90
  end
95
91
 
96
92
  project
@@ -25,11 +25,13 @@ module Tmuxinator
25
25
  end
26
26
 
27
27
  def root
28
- yaml["project_root"] || File.expand_path(yaml["root"])
28
+ root = yaml["project_root"] || yaml["root"]
29
+ root.blank? ? nil : File.expand_path(root).shellescape
29
30
  end
30
31
 
31
32
  def name
32
- yaml["project_name"] && yaml["project_name"].shellescape || yaml["name"].shellescape
33
+ name = yaml["project_name"] || yaml["name"]
34
+ name.shellescape
33
35
  end
34
36
 
35
37
  def pre
@@ -1,3 +1,3 @@
1
1
  module Tmuxinator
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
3
3
  end
@@ -75,7 +75,8 @@ module Tmuxinator
75
75
  end
76
76
 
77
77
  def tmux_new_window_command
78
- "#{project.tmux} new-window #{Tmuxinator::Config.default_path_option} #{File.expand_path(project.root).shellescape} -t #{tmux_window_target} -n #{name}"
78
+ path = project.root? ? "#{Tmuxinator::Config.default_path_option} #{File.expand_path(project.root)}" : nil
79
+ "#{project.tmux} new-window #{path} -t #{tmux_window_target} -n #{name}"
79
80
  end
80
81
 
81
82
  def tmux_layout_command
@@ -4,10 +4,10 @@ describe Tmuxinator::Cli do
4
4
 
5
5
  before do
6
6
  ARGV.clear
7
- Kernel.stub(:system)
8
- FileUtils.stub(:copy_file)
9
- FileUtils.stub(:rm)
10
- FileUtils.stub(:remove_dir)
7
+ allow(Kernel).to receive(:system)
8
+ allow(FileUtils).to receive(:copy_file)
9
+ allow(FileUtils).to receive(:rm)
10
+ allow(FileUtils).to receive(:remove_dir)
11
11
  end
12
12
 
13
13
  context "no arguments" do
@@ -20,7 +20,7 @@ describe Tmuxinator::Cli do
20
20
  describe "#completions" do
21
21
  before do
22
22
  ARGV.replace(["completions", "start"])
23
- Tmuxinator::Config.stub(:configs => ["test.yml"])
23
+ allow(Tmuxinator::Config).to receive_messages(:configs => ["test.yml"])
24
24
  end
25
25
 
26
26
  it "gets completions" do
@@ -43,9 +43,9 @@ describe Tmuxinator::Cli do
43
43
  describe "#start" do
44
44
  before do
45
45
  ARGV.replace(["start", "foo"])
46
- Tmuxinator::Config.stub(:validate => project)
47
- Tmuxinator::Config.stub(:version => 1.9)
48
- Kernel.stub(:exec)
46
+ allow(Tmuxinator::Config).to receive_messages(:validate => project)
47
+ allow(Tmuxinator::Config).to receive_messages(:version => 1.9)
48
+ allow(Kernel).to receive(:exec)
49
49
  end
50
50
 
51
51
  context "no deprecations" do
@@ -59,7 +59,7 @@ describe Tmuxinator::Cli do
59
59
 
60
60
  context "deprecations" do
61
61
  before do
62
- $stdin.stub(:getc => "y")
62
+ allow($stdin).to receive_messages(:getc => "y")
63
63
  end
64
64
 
65
65
  let(:project) { FactoryGirl.build(:project_with_deprecations) }
@@ -76,12 +76,12 @@ describe Tmuxinator::Cli do
76
76
 
77
77
  before do
78
78
  ARGV.replace(["new", "test"])
79
- File.stub(:open) { |&block| block.yield file }
79
+ allow(File).to receive(:open) { |&block| block.yield file }
80
80
  end
81
81
 
82
82
  context "existing project doesn't exist" do
83
83
  before do
84
- Tmuxinator::Config.stub(:exists? => false)
84
+ allow(Tmuxinator::Config).to receive_messages(:exists? => false)
85
85
  end
86
86
 
87
87
  it "creates a new tmuxinator project file" do
@@ -92,7 +92,7 @@ describe Tmuxinator::Cli do
92
92
 
93
93
  context "files exists" do
94
94
  before do
95
- File.stub(:exists? => true)
95
+ allow(File).to receive_messages(:exists? => true)
96
96
  end
97
97
 
98
98
  it "just opens the file" do
@@ -105,20 +105,15 @@ describe Tmuxinator::Cli do
105
105
  describe "#copy" do
106
106
  before do
107
107
  ARGV.replace(["copy", "foo", "bar"])
108
- Tmuxinator::Config.stub(:exists?) { true }
108
+ allow(Tmuxinator::Config).to receive(:exists?) { true }
109
109
  end
110
110
 
111
111
  context "new project already exists" do
112
112
  before do
113
- Thor::LineEditor.stub(:readline => "y")
113
+ allow(Thor::LineEditor).to receive_messages(:readline => "y")
114
114
  end
115
115
 
116
116
  it "prompts user to confirm overwrite" do
117
- expect(FileUtils).to receive(:rm)
118
- capture_io { cli.start }
119
- end
120
-
121
- it "copies the config" do
122
117
  expect(FileUtils).to receive(:copy_file)
123
118
  capture_io { cli.start }
124
119
  end
@@ -126,7 +121,7 @@ describe Tmuxinator::Cli do
126
121
 
127
122
  context "existing project doens't exist" do
128
123
  before do
129
- Tmuxinator::Config.stub(:exists?) { false }
124
+ allow(Tmuxinator::Config).to receive(:exists?) { false }
130
125
  end
131
126
 
132
127
  it "exit with error code" do
@@ -140,7 +135,7 @@ describe Tmuxinator::Cli do
140
135
 
141
136
  before do
142
137
  ARGV.replace(["debug", "foo"])
143
- Tmuxinator::Config.stub(:validate => project)
138
+ allow(Tmuxinator::Config).to receive_messages(:validate => project)
144
139
  end
145
140
 
146
141
  it "renders the project" do
@@ -152,12 +147,12 @@ describe Tmuxinator::Cli do
152
147
  describe "#delete" do
153
148
  before do
154
149
  ARGV.replace(["delete", "foo"])
155
- Thor::LineEditor.stub(:readline => "y")
150
+ allow(Thor::LineEditor).to receive_messages(:readline => "y")
156
151
  end
157
152
 
158
153
  context "project exists" do
159
154
  before do
160
- Tmuxinator::Config.stub(:exists?) { true }
155
+ allow(Tmuxinator::Config).to receive(:exists?) { true }
161
156
  end
162
157
 
163
158
  it "deletes the project" do
@@ -168,7 +163,7 @@ describe Tmuxinator::Cli do
168
163
 
169
164
  context "project doesn't exist" do
170
165
  before do
171
- Thor::LineEditor.stub(:readline => "y")
166
+ allow(Thor::LineEditor).to receive_messages(:readline => "y")
172
167
  end
173
168
 
174
169
  it "exits with error message" do
@@ -180,7 +175,7 @@ describe Tmuxinator::Cli do
180
175
  describe "#implode" do
181
176
  before do
182
177
  ARGV.replace(["implode"])
183
- Thor::LineEditor.stub(:readline => "y")
178
+ allow(Thor::LineEditor).to receive_messages(:readline => "y")
184
179
  end
185
180
 
186
181
  it "confirms deletion of all projects" do
@@ -197,7 +192,7 @@ describe Tmuxinator::Cli do
197
192
  describe "#list" do
198
193
  before do
199
194
  ARGV.replace(["list"])
200
- Dir.stub(:[] => ["/path/to/project.yml"])
195
+ allow(Dir).to receive_messages(:[] => ["/path/to/project.yml"])
201
196
  end
202
197
 
203
198
  it "lists all projects" do
@@ -222,9 +217,9 @@ describe Tmuxinator::Cli do
222
217
  end
223
218
 
224
219
  it "checks requirements" do
225
- Tmuxinator::Config.should_receive(:installed?)
226
- Tmuxinator::Config.should_receive(:editor?)
227
- Tmuxinator::Config.should_receive(:shell?)
220
+ expect(Tmuxinator::Config).to receive(:installed?)
221
+ expect(Tmuxinator::Config).to receive(:editor?)
222
+ expect(Tmuxinator::Config).to receive(:shell?)
228
223
  capture_io { cli.start }
229
224
  end
230
225
  end
@@ -24,28 +24,28 @@ describe Tmuxinator::Config do
24
24
 
25
25
  context "when the file exists" do
26
26
  before do
27
- File.stub(:exists?).with(Tmuxinator::Config.default) { true }
27
+ allow(File).to receive(:exists?).with(Tmuxinator::Config.default) { true }
28
28
  end
29
29
 
30
30
  it "returns true" do
31
- expect(Tmuxinator::Config.default?).to be_true
31
+ expect(Tmuxinator::Config.default?).to be_truthy
32
32
  end
33
33
  end
34
34
 
35
35
  context "when the file doesn't exist" do
36
36
  before do
37
- File.stub(:exists?).with(Tmuxinator::Config.default) { false }
37
+ allow(File).to receive(:exists?).with(Tmuxinator::Config.default) { false }
38
38
  end
39
39
 
40
40
  it "returns true" do
41
- expect(Tmuxinator::Config.default?).to be_false
41
+ expect(Tmuxinator::Config.default?).to be_falsey
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
46
  describe "#configs" do
47
47
  before do
48
- Dir.stub(:[] => ["test.yml"])
48
+ allow(Dir).to receive_messages(:[] => ["test.yml"])
49
49
  end
50
50
 
51
51
  it "gets a list of all projects" do
@@ -56,21 +56,21 @@ describe Tmuxinator::Config do
56
56
  describe "#installed?" do
57
57
  context "tmux is installed" do
58
58
  before do
59
- Kernel.stub(:system) { true }
59
+ allow(Kernel).to receive(:system) { true }
60
60
  end
61
61
 
62
62
  it "returns true" do
63
- expect(Tmuxinator::Config.installed?).to be_true
63
+ expect(Tmuxinator::Config.installed?).to be_truthy
64
64
  end
65
65
  end
66
66
 
67
67
  context "tmux is not installed" do
68
68
  before do
69
- Kernel.stub(:system) { false }
69
+ allow(Kernel).to receive(:system) { false }
70
70
  end
71
71
 
72
72
  it "returns true" do
73
- expect(Tmuxinator::Config.installed?).to be_false
73
+ expect(Tmuxinator::Config.installed?).to be_falsey
74
74
  end
75
75
  end
76
76
  end
@@ -78,21 +78,21 @@ describe Tmuxinator::Config do
78
78
  describe "#editor?" do
79
79
  context "$EDITOR is set" do
80
80
  before do
81
- ENV.stub(:[]).with("EDITOR") { "vim" }
81
+ allow(ENV).to receive(:[]).with("EDITOR") { "vim" }
82
82
  end
83
83
 
84
84
  it "returns true" do
85
- expect(Tmuxinator::Config.editor?).to be_true
85
+ expect(Tmuxinator::Config.editor?).to be_truthy
86
86
  end
87
87
  end
88
88
 
89
89
  context "$EDITOR is not set" do
90
90
  before do
91
- ENV.stub(:[]).with("EDITOR") { nil }
91
+ allow(ENV).to receive(:[]).with("EDITOR") { nil }
92
92
  end
93
93
 
94
94
  it "returns false" do
95
- expect(Tmuxinator::Config.editor?).to be_false
95
+ expect(Tmuxinator::Config.editor?).to be_falsey
96
96
  end
97
97
  end
98
98
  end
@@ -100,33 +100,33 @@ describe Tmuxinator::Config do
100
100
  describe "#shell?" do
101
101
  context "$SHELL is set" do
102
102
  before do
103
- ENV.stub(:[]).with("SHELL") { "vim" }
103
+ allow(ENV).to receive(:[]).with("SHELL") { "vim" }
104
104
  end
105
105
 
106
106
  it "returns true" do
107
- expect(Tmuxinator::Config.shell?).to be_true
107
+ expect(Tmuxinator::Config.shell?).to be_truthy
108
108
  end
109
109
  end
110
110
 
111
111
  context "$SHELL is not set" do
112
112
  before do
113
- ENV.stub(:[]).with("SHELL") { nil }
113
+ allow(ENV).to receive(:[]).with("SHELL") { nil }
114
114
  end
115
115
 
116
116
  it "returns false" do
117
- expect(Tmuxinator::Config.shell?).to be_false
117
+ expect(Tmuxinator::Config.shell?).to be_falsey
118
118
  end
119
119
  end
120
120
  end
121
121
 
122
122
  describe "#exists?" do
123
123
  before do
124
- File.stub(:exists? => true)
125
- Tmuxinator::Config.stub(:project => "")
124
+ allow(File).to receive_messages(:exists? => true)
125
+ allow(Tmuxinator::Config).to receive_messages(:project => "")
126
126
  end
127
127
 
128
128
  it "checks if the given project exists" do
129
- expect(Tmuxinator::Config.exists?("test")).to be_true
129
+ expect(Tmuxinator::Config.exists?("test")).to be_truthy
130
130
  end
131
131
  end
132
132
 
@@ -135,7 +135,7 @@ describe Tmuxinator::Config do
135
135
 
136
136
  before do
137
137
  path = File.expand_path("../../../fixtures/", __FILE__)
138
- Tmuxinator::Config.stub(:root => path)
138
+ allow(Tmuxinator::Config).to receive_messages(:root => path)
139
139
  end
140
140
 
141
141
  context "with project yml" do
@@ -81,8 +81,8 @@ describe Tmuxinator::Project do
81
81
  context "with deprecations" do
82
82
  context "rbenv option is present" do
83
83
  before do
84
- project.stub(:rbenv? => true)
85
- project.stub_chain(:yaml, :[]).and_return("2.0.0-p247")
84
+ allow(project).to receive_messages(:rbenv? => true)
85
+ allow(project).to receive_message_chain(:yaml, :[]).and_return("2.0.0-p247")
86
86
  end
87
87
 
88
88
  it "still gets the correct pre_window command" do
@@ -92,8 +92,8 @@ describe Tmuxinator::Project do
92
92
 
93
93
  context "rvm option is present" do
94
94
  before do
95
- project.stub(:rbenv? => false)
96
- project.stub_chain(:yaml, :[]).and_return("ruby-2.0.0-p247")
95
+ allow(project).to receive_messages(:rbenv? => false)
96
+ allow(project).to receive_message_chain(:yaml, :[]).and_return("ruby-2.0.0-p247")
97
97
  end
98
98
 
99
99
  it "still gets the correct pre_window command" do
@@ -103,8 +103,8 @@ describe Tmuxinator::Project do
103
103
 
104
104
  context "pre_tab is present" do
105
105
  before do
106
- project.stub(:rbenv? => false)
107
- project.stub(:pre_tab? => true)
106
+ allow(project).to receive_messages(:rbenv? => false)
107
+ allow(project).to receive_messages(:pre_tab? => true)
108
108
  end
109
109
 
110
110
  it "still gets the correct pre_window command" do
@@ -117,7 +117,7 @@ describe Tmuxinator::Project do
117
117
  describe "#socket" do
118
118
  context "socket path is present" do
119
119
  before do
120
- project.stub(:socket_path => "/tmp")
120
+ allow(project).to receive_messages(:socket_path => "/tmp")
121
121
  end
122
122
 
123
123
  it "gets the socket path" do
@@ -147,7 +147,7 @@ describe Tmuxinator::Project do
147
147
  describe "#tmux_options" do
148
148
  context "no tmux options" do
149
149
  before do
150
- project.stub(:tmux_options? => false)
150
+ allow(project).to receive_messages(:tmux_options? => false)
151
151
  end
152
152
 
153
153
  it "returns nothing" do
@@ -157,7 +157,7 @@ describe Tmuxinator::Project do
157
157
 
158
158
  context "with deprecations" do
159
159
  before do
160
- project_with_deprecations.stub(:cli_args? => true)
160
+ allow(project_with_deprecations).to receive_messages(:cli_args? => true)
161
161
  end
162
162
 
163
163
  it "still gets the tmux options" do
@@ -168,7 +168,7 @@ describe Tmuxinator::Project do
168
168
 
169
169
  describe "#get_pane_base_index" do
170
170
  it "extracts the pane_base_index from tmux_options" do
171
- project.stub(show_tmux_options: tmux_config(pane_base_index: 3))
171
+ allow(project).to receive_messages(show_tmux_options: tmux_config(pane_base_index: 3))
172
172
 
173
173
  expect(project.get_pane_base_index).to eq("3")
174
174
  end
@@ -176,7 +176,7 @@ describe Tmuxinator::Project do
176
176
 
177
177
  describe "#get_base_index" do
178
178
  it "extracts the base index from options" do
179
- project.stub(show_tmux_options: tmux_config(base_index: 1))
179
+ allow(project).to receive_messages(show_tmux_options: tmux_config(base_index: 1))
180
180
 
181
181
  expect(project.get_base_index).to eq("1")
182
182
  end
@@ -185,8 +185,8 @@ describe Tmuxinator::Project do
185
185
  describe "#base_index" do
186
186
  context "pane base index present" do
187
187
  before do
188
- project.stub(:get_pane_base_index => "1")
189
- project.stub(:get_base_index => "1")
188
+ allow(project).to receive_messages(:get_pane_base_index => "1")
189
+ allow(project).to receive_messages(:get_base_index => "1")
190
190
  end
191
191
 
192
192
  it "gets the pane base index" do
@@ -196,8 +196,8 @@ describe Tmuxinator::Project do
196
196
 
197
197
  context "pane base index no present" do
198
198
  before do
199
- project.stub(:get_pane_base_index => nil)
200
- project.stub(:get_base_index => "0")
199
+ allow(project).to receive_messages(:get_pane_base_index => nil)
200
+ allow(project).to receive_messages(:get_base_index => "0")
201
201
  end
202
202
 
203
203
  it "gets the base index" do
@@ -215,7 +215,7 @@ describe Tmuxinator::Project do
215
215
  describe "#name?" do
216
216
  context "name is present" do
217
217
  it "returns true" do
218
- expect(project.name?).to be_true
218
+ expect(project.name?).to be_truthy
219
219
  end
220
220
  end
221
221
  end
@@ -223,7 +223,7 @@ describe Tmuxinator::Project do
223
223
  describe "#windows?" do
224
224
  context "windows are present" do
225
225
  it "returns true" do
226
- expect(project.windows?).to be_true
226
+ expect(project.windows?).to be_truthy
227
227
  end
228
228
  end
229
229
  end
@@ -231,7 +231,7 @@ describe Tmuxinator::Project do
231
231
  describe "#root?" do
232
232
  context "root are present" do
233
233
  it "returns true" do
234
- expect(project.root?).to be_true
234
+ expect(project.root?).to be_truthy
235
235
  end
236
236
  end
237
237
  end