tmuxinator 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tmuxinator/config.rb +18 -6
- data/lib/tmuxinator/version.rb +1 -1
- data/spec/fixtures/yaml.yaml +40 -0
- data/spec/lib/tmuxinator/cli_spec.rb +14 -13
- data/spec/lib/tmuxinator/config_spec.rb +119 -101
- data/spec/lib/tmuxinator/doctor_spec.rb +6 -6
- data/spec/lib/tmuxinator/window_spec.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a42092fba4aebfc0a51747b734727ae7593aaeae59ebfd315b037035acf1f0d
|
4
|
+
data.tar.gz: a9056816cf163274485aefa281c524661f38023435b358bb31fb7a3bc76c58a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14f58f568d7f1dee72b344a5ac82f88ce913471da6efa86fa13e966cbe79a304823ff3843cf0a0c16f36c190bce08e0a7f3a6322cf4af57aeb3c486fedce42d9
|
7
|
+
data.tar.gz: 28a231359aabc6b1fae54d8add528e4dfcf0f7a49bb33e8a134750b389cbeb0eaa89d1733f82b54e409353a0ddfa2e953c50d1a426708eeb093112dc47349db9
|
data/lib/tmuxinator/config.rb
CHANGED
@@ -9,9 +9,9 @@ module Tmuxinator
|
|
9
9
|
class << self
|
10
10
|
# The directory (created if needed) in which to store new projects
|
11
11
|
def directory
|
12
|
-
return environment if
|
13
|
-
return xdg if
|
14
|
-
return home if
|
12
|
+
return environment if environment?
|
13
|
+
return xdg if xdg?
|
14
|
+
return home if home?
|
15
15
|
# No project directory specified or existant, default to XDG:
|
16
16
|
FileUtils::mkdir_p(xdg)
|
17
17
|
xdg
|
@@ -21,6 +21,10 @@ module Tmuxinator
|
|
21
21
|
ENV["HOME"] + "/.tmuxinator"
|
22
22
|
end
|
23
23
|
|
24
|
+
def home?
|
25
|
+
File.directory?(home)
|
26
|
+
end
|
27
|
+
|
24
28
|
# ~/.config/tmuxinator unless $XDG_CONFIG_HOME has been configured to use
|
25
29
|
# a custom value. (e.g. if $XDG_CONFIG_HOME is set to ~/my-config, the
|
26
30
|
# return value will be ~/my-config/tmuxinator)
|
@@ -28,6 +32,10 @@ module Tmuxinator
|
|
28
32
|
XDG["CONFIG"].to_s + "/tmuxinator"
|
29
33
|
end
|
30
34
|
|
35
|
+
def xdg?
|
36
|
+
File.directory?(xdg)
|
37
|
+
end
|
38
|
+
|
31
39
|
# $TMUXINATOR_CONFIG (and create directory) or "".
|
32
40
|
def environment
|
33
41
|
environment = ENV["TMUXINATOR_CONFIG"]
|
@@ -36,6 +44,10 @@ module Tmuxinator
|
|
36
44
|
environment
|
37
45
|
end
|
38
46
|
|
47
|
+
def environment?
|
48
|
+
File.directory?(environment)
|
49
|
+
end
|
50
|
+
|
39
51
|
def sample
|
40
52
|
asset_path "sample.yml"
|
41
53
|
end
|
@@ -119,7 +131,7 @@ module Tmuxinator
|
|
119
131
|
# Listed in search order
|
120
132
|
# Used by `implode` and `list` commands
|
121
133
|
def directories
|
122
|
-
if
|
134
|
+
if environment?
|
123
135
|
[environment]
|
124
136
|
else
|
125
137
|
[xdg, home].select { |d| File.directory? d }
|
@@ -181,8 +193,8 @@ module Tmuxinator
|
|
181
193
|
# recursively searching 'directory'
|
182
194
|
def project_in(directory, name)
|
183
195
|
return nil if String(directory).empty?
|
184
|
-
projects = Dir.glob("#{directory}/**/*.yml").sort
|
185
|
-
projects.detect { |project| File.basename(project, "
|
196
|
+
projects = Dir.glob("#{directory}/**/*.{yml,yaml}").sort
|
197
|
+
projects.detect { |project| File.basename(project, ".*") == name }
|
186
198
|
end
|
187
199
|
end
|
188
200
|
end
|
data/lib/tmuxinator/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# ~/.tmuxinator/sample.yml
|
2
|
+
# you can make as many tabs as you wish...
|
3
|
+
|
4
|
+
name: sample
|
5
|
+
root: ~/test
|
6
|
+
socket_name: foo # Remove to use default socket
|
7
|
+
pre_window: rbenv shell 2.0.0-p247 # Runs in each tab and pane
|
8
|
+
tmux_options: -f ~/.tmux.mac.conf # Pass arguments to tmux
|
9
|
+
tmux_detached: false
|
10
|
+
windows:
|
11
|
+
- editor:
|
12
|
+
pre:
|
13
|
+
- echo "I get run in each pane, before each pane command!"
|
14
|
+
-
|
15
|
+
layout: main-vertical
|
16
|
+
panes:
|
17
|
+
- vim
|
18
|
+
- #empty, will just run plain bash
|
19
|
+
- top
|
20
|
+
- pane_with_multiple_commands:
|
21
|
+
- ssh server
|
22
|
+
- echo "Hello"
|
23
|
+
- shell:
|
24
|
+
- git pull
|
25
|
+
- git merge
|
26
|
+
- guard:
|
27
|
+
layout: tiled
|
28
|
+
pre:
|
29
|
+
- echo "I get run in each pane."
|
30
|
+
- echo "Before each pane command!"
|
31
|
+
panes:
|
32
|
+
-
|
33
|
+
- #empty, will just run plain bash
|
34
|
+
-
|
35
|
+
- database: bundle exec rails db
|
36
|
+
- server: bundle exec rails s
|
37
|
+
- logs: tail -f log/development.log
|
38
|
+
- console: bundle exec rails c
|
39
|
+
- capistrano:
|
40
|
+
- server: ssh user@example.com
|
@@ -24,7 +24,8 @@ describe Tmuxinator::Cli do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
subject(:cli) { described_class }
|
28
|
+
|
28
29
|
let(:fixtures_dir) { File.expand_path("../../../fixtures/", __FILE__) }
|
29
30
|
let(:project) { FactoryBot.build(:project) }
|
30
31
|
let(:project_config) do
|
@@ -421,7 +422,7 @@ describe Tmuxinator::Cli do
|
|
421
422
|
expect(File).not_to exist(path)
|
422
423
|
|
423
424
|
# now generate a project file
|
424
|
-
expect(
|
425
|
+
expect(described_class.new.generate_project_file(name, path)).to eq path
|
425
426
|
expect(File).to exist path
|
426
427
|
|
427
428
|
# add some content to the project file
|
@@ -829,7 +830,7 @@ describe Tmuxinator::Cli do
|
|
829
830
|
end
|
830
831
|
|
831
832
|
it "should generate a project file" do
|
832
|
-
new_path =
|
833
|
+
new_path = described_class.new.find_project_file(name, false)
|
833
834
|
expect(new_path).to eq path
|
834
835
|
expect(File).to exist new_path
|
835
836
|
end
|
@@ -840,7 +841,7 @@ describe Tmuxinator::Cli do
|
|
840
841
|
|
841
842
|
before do
|
842
843
|
expect(File).not_to exist(path), "expected file at #{path} not to exist"
|
843
|
-
expect(
|
844
|
+
expect(described_class.new.generate_project_file(name, path)).to eq path
|
844
845
|
expect(File).to exist path
|
845
846
|
|
846
847
|
File.open(path, "w") do |f|
|
@@ -851,7 +852,7 @@ describe Tmuxinator::Cli do
|
|
851
852
|
end
|
852
853
|
|
853
854
|
it "should _not_ generate a new project file" do
|
854
|
-
new_path =
|
855
|
+
new_path = described_class.new.find_project_file(name, false)
|
855
856
|
expect(new_path).to eq path
|
856
857
|
expect(File).to exist new_path
|
857
858
|
expect(File.read(new_path)).to match %r{#{extra}}
|
@@ -866,7 +867,7 @@ describe Tmuxinator::Cli do
|
|
866
867
|
Dir.mktmpdir do |dir|
|
867
868
|
path = "#{dir}/#{name}.yml"
|
868
869
|
expect(File).not_to exist(path), "expected file at #{path} not to exist"
|
869
|
-
new_path =
|
870
|
+
new_path = described_class.new.generate_project_file(name, path)
|
870
871
|
expect(new_path).to eq path
|
871
872
|
expect(File).to exist new_path
|
872
873
|
end
|
@@ -877,7 +878,7 @@ describe Tmuxinator::Cli do
|
|
877
878
|
allow(File).to receive(:open) { |&block| block.yield file }
|
878
879
|
Dir.mktmpdir do |dir|
|
879
880
|
path = "#{dir}/#{name}.yml"
|
880
|
-
_ =
|
881
|
+
_ = described_class.new.generate_project_file(name, path)
|
881
882
|
expect(file.string).to match %r{\A# #{path}$}
|
882
883
|
end
|
883
884
|
end
|
@@ -915,18 +916,18 @@ describe Tmuxinator::Cli do
|
|
915
916
|
context "attach option" do
|
916
917
|
describe "detach" do
|
917
918
|
it "sets force_detach to false when no attach argument is provided" do
|
918
|
-
project =
|
919
|
+
project = described_class.new.create_project(name: name)
|
919
920
|
expect(project.force_detach).to eq(false)
|
920
921
|
end
|
921
922
|
|
922
923
|
it "sets force_detach to true when 'attach: false' is provided" do
|
923
|
-
project =
|
924
|
+
project = described_class.new.create_project(attach: false,
|
924
925
|
name: name)
|
925
926
|
expect(project.force_detach).to eq(true)
|
926
927
|
end
|
927
928
|
|
928
929
|
it "sets force_detach to false when 'attach: true' is provided" do
|
929
|
-
project =
|
930
|
+
project = described_class.new.create_project(attach: true,
|
930
931
|
name: name)
|
931
932
|
expect(project.force_detach).to eq(false)
|
932
933
|
end
|
@@ -934,18 +935,18 @@ describe Tmuxinator::Cli do
|
|
934
935
|
|
935
936
|
describe "attach" do
|
936
937
|
it "sets force_attach to false when no attach argument is provided" do
|
937
|
-
project =
|
938
|
+
project = described_class.new.create_project(name: name)
|
938
939
|
expect(project.force_attach).to eq(false)
|
939
940
|
end
|
940
941
|
|
941
942
|
it "sets force_attach to true when 'attach: true' is provided" do
|
942
|
-
project =
|
943
|
+
project = described_class.new.create_project(attach: true,
|
943
944
|
name: name)
|
944
945
|
expect(project.force_attach).to eq(true)
|
945
946
|
end
|
946
947
|
|
947
948
|
it "sets force_attach to false when 'attach: false' is provided" do
|
948
|
-
project =
|
949
|
+
project = described_class.new.create_project(attach: false,
|
949
950
|
name: name)
|
950
951
|
expect(project.force_attach).to eq(false)
|
951
952
|
end
|
@@ -11,55 +11,50 @@ describe Tmuxinator::Config do
|
|
11
11
|
allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
|
12
12
|
and_return "expected"
|
13
13
|
allow(File).to receive(:directory?).and_return true
|
14
|
-
expect(
|
14
|
+
expect(described_class.directory).to eq "expected"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
context "only ~/.tmuxinator exists" do
|
19
19
|
it "is ~/.tmuxinator" do
|
20
|
-
allow(
|
21
|
-
|
22
|
-
allow(
|
23
|
-
|
24
|
-
|
25
|
-
with(Tmuxinator::Config.home).and_return true
|
26
|
-
expect(Tmuxinator::Config.directory).to eq Tmuxinator::Config.home
|
20
|
+
allow(described_class).to receive(:environment?).and_return false
|
21
|
+
allow(described_class).to receive(:xdg?).and_return false
|
22
|
+
allow(described_class).to receive(:home?).and_return true
|
23
|
+
|
24
|
+
expect(described_class.directory).to eq described_class.home
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
28
|
context "only $XDG_CONFIG_HOME/tmuxinator exists" do
|
31
29
|
it "is #xdg" do
|
32
|
-
allow(
|
33
|
-
|
34
|
-
allow(
|
35
|
-
|
36
|
-
|
37
|
-
with(Tmuxinator::Config.home).and_return false
|
38
|
-
expect(Tmuxinator::Config.directory).to eq Tmuxinator::Config.xdg
|
30
|
+
allow(described_class).to receive(:environment?).and_return false
|
31
|
+
allow(described_class).to receive(:xdg?).and_return true
|
32
|
+
allow(described_class).to receive(:home?).and_return false
|
33
|
+
|
34
|
+
expect(described_class.directory).to eq described_class.xdg
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
38
|
context "both $XDG_CONFIG_HOME/tmuxinator and ~/.tmuxinator exist" do
|
43
39
|
it "is #xdg" do
|
44
|
-
allow(
|
45
|
-
|
46
|
-
allow(
|
47
|
-
|
48
|
-
|
49
|
-
with(Tmuxinator::Config.home).and_return true
|
50
|
-
expect(Tmuxinator::Config.directory).to eq Tmuxinator::Config.xdg
|
40
|
+
allow(described_class).to receive(:environment?).and_return false
|
41
|
+
allow(described_class).to receive(:xdg?).and_return true
|
42
|
+
allow(described_class).to receive(:home?).and_return true
|
43
|
+
|
44
|
+
expect(described_class.directory).to eq described_class.xdg
|
51
45
|
end
|
52
46
|
end
|
53
47
|
|
54
|
-
context "parent directory(s) do not exist" do
|
48
|
+
context "defaulting to xdg with parent directory(s) that do not exist" do
|
55
49
|
it "creates parent directories if required" do
|
56
|
-
allow(
|
57
|
-
allow(
|
58
|
-
|
50
|
+
allow(described_class).to receive(:environment?).and_return false
|
51
|
+
allow(described_class).to receive(:xdg?).and_return false
|
52
|
+
allow(described_class).to receive(:home?).and_return false
|
53
|
+
|
59
54
|
Dir.mktmpdir do |dir|
|
60
55
|
config_parent = "#{dir}/non_existant_parent/s"
|
61
56
|
allow(XDG).to receive(:[]).with("CONFIG").and_return config_parent
|
62
|
-
expect(
|
57
|
+
expect(described_class.directory).
|
63
58
|
to eq "#{config_parent}/tmuxinator"
|
64
59
|
expect(File.directory?("#{config_parent}/tmuxinator")).to be true
|
65
60
|
end
|
@@ -74,7 +69,7 @@ describe Tmuxinator::Config do
|
|
74
69
|
and_return "expected"
|
75
70
|
# allow(XDG).to receive(:[]).with("CONFIG").and_return "expected"
|
76
71
|
allow(File).to receive(:directory?).and_return true
|
77
|
-
expect(
|
72
|
+
expect(described_class.environment).to eq "expected"
|
78
73
|
end
|
79
74
|
end
|
80
75
|
|
@@ -84,67 +79,79 @@ describe Tmuxinator::Config do
|
|
84
79
|
and_return nil
|
85
80
|
# allow(XDG).to receive(:[]).with("CONFIG").and_return nil
|
86
81
|
allow(File).to receive(:directory?).and_return true
|
87
|
-
expect(
|
82
|
+
expect(described_class.environment).to eq ""
|
88
83
|
end
|
89
84
|
end
|
90
85
|
|
91
86
|
context "environment variable $TMUXINATOR_CONFIG is set and empty" do
|
92
87
|
it "is an empty string" do
|
93
88
|
allow(XDG).to receive(:[]).with("CONFIG").and_return ""
|
94
|
-
|
89
|
+
allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").and_return ""
|
90
|
+
expect(described_class.environment).to eq ""
|
95
91
|
end
|
96
92
|
end
|
97
93
|
end
|
98
94
|
|
99
95
|
describe "#directories" do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
96
|
+
context "without TMUXINATOR_CONFIG environment" do
|
97
|
+
before do
|
98
|
+
allow(described_class).to receive(:environment?).and_return false
|
99
|
+
end
|
104
100
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
101
|
+
it "is empty if no configuration directories exist" do
|
102
|
+
allow(File).to receive(:directory?).and_return false
|
103
|
+
expect(described_class.directories).to eq []
|
104
|
+
end
|
105
|
+
|
106
|
+
it "contains #xdg before #home" do
|
107
|
+
allow(described_class).to receive(:xdg).and_return "XDG"
|
108
|
+
allow(described_class).to receive(:home).and_return "HOME"
|
109
|
+
allow(File).to receive(:directory?).and_return true
|
110
|
+
|
111
|
+
expect(described_class.directories).to eq \
|
112
|
+
["XDG", "HOME"]
|
113
|
+
end
|
110
114
|
end
|
111
115
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
context "with TMUXINATOR_CONFIG environment" do
|
117
|
+
before do
|
118
|
+
allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
|
119
|
+
and_return "TMUXINATOR_CONFIG"
|
120
|
+
end
|
121
|
+
it "is only [$TMUXINATOR_CONFIG] if set" do
|
122
|
+
allow(File).to receive(:directory?).and_return true
|
123
|
+
|
124
|
+
expect(described_class.directories).to eq ["TMUXINATOR_CONFIG"]
|
125
|
+
end
|
119
126
|
end
|
120
127
|
end
|
121
128
|
|
122
129
|
describe "#home" do
|
123
130
|
it "is ~/.tmuxinator" do
|
124
|
-
expect(
|
131
|
+
expect(described_class.home).to eq "#{ENV['HOME']}/.tmuxinator"
|
125
132
|
end
|
126
133
|
end
|
127
134
|
|
128
135
|
describe "#xdg" do
|
129
136
|
it "is $XDG_CONFIG_HOME/tmuxinator" do
|
130
|
-
expect(
|
137
|
+
expect(described_class.xdg).to eq "#{XDG['CONFIG_HOME']}/tmuxinator"
|
131
138
|
end
|
132
139
|
end
|
133
140
|
|
134
141
|
describe "#sample" do
|
135
142
|
it "gets the path of the sample project" do
|
136
|
-
expect(
|
143
|
+
expect(described_class.sample).to include("sample.yml")
|
137
144
|
end
|
138
145
|
end
|
139
146
|
|
140
147
|
describe "#default" do
|
141
148
|
it "gets the path of the default config" do
|
142
|
-
expect(
|
149
|
+
expect(described_class.default).to include("default.yml")
|
143
150
|
end
|
144
151
|
end
|
145
152
|
|
146
153
|
describe "#version" do
|
147
|
-
subject {
|
154
|
+
subject { described_class.version }
|
148
155
|
|
149
156
|
before do
|
150
157
|
expect(Tmuxinator::Doctor).to receive(:installed?).and_return(true)
|
@@ -166,29 +173,29 @@ describe Tmuxinator::Config do
|
|
166
173
|
describe "#default_path_option" do
|
167
174
|
context ">= 1.8" do
|
168
175
|
before do
|
169
|
-
allow(
|
176
|
+
allow(described_class).to receive(:version).and_return(1.8)
|
170
177
|
end
|
171
178
|
|
172
179
|
it "returns -c" do
|
173
|
-
expect(
|
180
|
+
expect(described_class.default_path_option).to eq "-c"
|
174
181
|
end
|
175
182
|
end
|
176
183
|
|
177
184
|
context "< 1.8" do
|
178
185
|
before do
|
179
|
-
allow(
|
186
|
+
allow(described_class).to receive(:version).and_return(1.7)
|
180
187
|
end
|
181
188
|
|
182
189
|
it "returns default-path" do
|
183
|
-
expect(
|
190
|
+
expect(described_class.default_path_option).to eq "default-path"
|
184
191
|
end
|
185
192
|
end
|
186
193
|
end
|
187
194
|
|
188
195
|
describe "#default?" do
|
189
|
-
let(:directory) {
|
190
|
-
let(:local_default) {
|
191
|
-
let(:proj_default) {
|
196
|
+
let(:directory) { described_class.directory }
|
197
|
+
let(:local_default) { described_class::LOCAL_DEFAULT }
|
198
|
+
let(:proj_default) { described_class.default }
|
192
199
|
|
193
200
|
context "when the file exists" do
|
194
201
|
before do
|
@@ -197,7 +204,7 @@ describe Tmuxinator::Config do
|
|
197
204
|
end
|
198
205
|
|
199
206
|
it "returns true" do
|
200
|
-
expect(
|
207
|
+
expect(described_class.default?).to be_truthy
|
201
208
|
end
|
202
209
|
end
|
203
210
|
|
@@ -208,105 +215,115 @@ describe Tmuxinator::Config do
|
|
208
215
|
end
|
209
216
|
|
210
217
|
it "returns true" do
|
211
|
-
expect(
|
218
|
+
expect(described_class.default?).to be_falsey
|
212
219
|
end
|
213
220
|
end
|
214
221
|
end
|
215
222
|
|
216
223
|
describe "#configs" do
|
217
224
|
before do
|
218
|
-
allow(
|
219
|
-
allow(
|
225
|
+
allow(described_class).to receive_messages(xdg: xdg_config_dir)
|
226
|
+
allow(described_class).to receive_messages(home: home_config_dir)
|
220
227
|
end
|
221
228
|
|
222
229
|
it "gets a sorted list of all projects" do
|
223
|
-
|
230
|
+
allow(described_class).to receive(:environment?).and_return false
|
231
|
+
|
232
|
+
expect(described_class.configs).
|
224
233
|
to eq ["both", "both", "dup/local-dup", "home", "local-dup", "xdg"]
|
225
234
|
end
|
226
235
|
|
227
236
|
it "lists only projects in $TMUXINATOR_CONFIG when set" do
|
228
237
|
allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
|
229
238
|
and_return "#{fixtures_dir}/TMUXINATOR_CONFIG"
|
230
|
-
expect(
|
239
|
+
expect(described_class.configs).to eq ["TMUXINATOR_CONFIG"]
|
231
240
|
end
|
232
241
|
end
|
233
242
|
|
234
243
|
describe "#exists?" do
|
235
244
|
before do
|
236
245
|
allow(File).to receive_messages(exist?: true)
|
237
|
-
allow(
|
246
|
+
allow(described_class).to receive_messages(project: "")
|
238
247
|
end
|
239
248
|
|
240
249
|
it "checks if the given project exists" do
|
241
|
-
expect(
|
250
|
+
expect(described_class.exists?(name: "test")).to be_truthy
|
242
251
|
end
|
243
252
|
end
|
244
253
|
|
245
254
|
describe "#global_project" do
|
246
|
-
let(:directory) {
|
255
|
+
let(:directory) { described_class.directory }
|
247
256
|
let(:base) { "#{directory}/sample.yml" }
|
248
257
|
let(:first_dup) { "#{home_config_dir}/dup/local-dup.yml" }
|
258
|
+
let(:yaml) { "#{directory}/yaml.yaml" }
|
249
259
|
|
250
260
|
before do
|
251
|
-
allow(
|
252
|
-
allow(
|
261
|
+
allow(described_class).to receive(:environment?).and_return false
|
262
|
+
allow(described_class).to receive(:xdg).and_return fixtures_dir
|
263
|
+
allow(described_class).to receive(:home).and_return fixtures_dir
|
253
264
|
end
|
254
265
|
|
255
266
|
context "with project yml" do
|
256
267
|
it "gets the project as path to the yml file" do
|
257
|
-
expect(
|
268
|
+
expect(described_class.global_project("sample")).to eq base
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
context "with project yaml" do
|
273
|
+
it "gets the project as path to the yaml file" do
|
274
|
+
expect(Tmuxinator::Config.global_project("yaml")).to eq yaml
|
258
275
|
end
|
259
276
|
end
|
260
277
|
|
261
278
|
context "without project yml" do
|
262
279
|
it "gets the project as path to the yml file" do
|
263
|
-
expect(
|
280
|
+
expect(described_class.global_project("new-project")).to be_nil
|
264
281
|
end
|
265
282
|
end
|
266
283
|
|
267
284
|
context "with duplicate project files" do
|
268
285
|
it "is the first .yml file found" do
|
269
|
-
expect(
|
286
|
+
expect(described_class.global_project("local-dup")).to eq first_dup
|
270
287
|
end
|
271
288
|
end
|
272
289
|
end
|
273
290
|
|
274
291
|
describe "#local?" do
|
275
292
|
it "checks if the given project exists" do
|
276
|
-
path =
|
293
|
+
path = described_class::LOCAL_DEFAULT
|
277
294
|
expect(File).to receive(:exist?).with(path) { true }
|
278
|
-
expect(
|
295
|
+
expect(described_class.local?).to be_truthy
|
279
296
|
end
|
280
297
|
end
|
281
298
|
|
282
299
|
describe "#local_project" do
|
283
|
-
let(:default) {
|
300
|
+
let(:default) { described_class::LOCAL_DEFAULT }
|
284
301
|
|
285
302
|
context "with a project yml" do
|
286
303
|
it "gets the project as path to the yml file" do
|
287
304
|
expect(File).to receive(:exist?).with(default) { true }
|
288
|
-
expect(
|
305
|
+
expect(described_class.local_project).to eq default
|
289
306
|
end
|
290
307
|
end
|
291
308
|
|
292
309
|
context "without project yml" do
|
293
310
|
it "gets the project as path to the yml file" do
|
294
|
-
expect(
|
311
|
+
expect(described_class.local_project).to be_nil
|
295
312
|
end
|
296
313
|
end
|
297
314
|
end
|
298
315
|
|
299
316
|
describe "#project" do
|
300
|
-
let(:directory) {
|
301
|
-
let(:default) {
|
317
|
+
let(:directory) { described_class.directory }
|
318
|
+
let(:default) { described_class::LOCAL_DEFAULT }
|
302
319
|
|
303
320
|
context "with an non-local project yml" do
|
304
321
|
before do
|
305
|
-
allow(
|
322
|
+
allow(described_class).to receive_messages(directory: fixtures_dir)
|
306
323
|
end
|
307
324
|
|
308
325
|
it "gets the project as path to the yml file" do
|
309
|
-
expect(
|
326
|
+
expect(described_class.project("sample")).
|
310
327
|
to eq "#{directory}/sample.yml"
|
311
328
|
end
|
312
329
|
end
|
@@ -314,48 +331,48 @@ describe Tmuxinator::Config do
|
|
314
331
|
context "with a local project, but no global project" do
|
315
332
|
it "gets the project as path to the yml file" do
|
316
333
|
expect(File).to receive(:exist?).with(default) { true }
|
317
|
-
expect(
|
334
|
+
expect(described_class.project("sample")).to eq "./.tmuxinator.yml"
|
318
335
|
end
|
319
336
|
end
|
320
337
|
|
321
338
|
context "without project yml" do
|
322
339
|
let(:expected) { "#{directory}/new-project.yml" }
|
323
340
|
it "gets the project as path to the yml file" do
|
324
|
-
expect(
|
341
|
+
expect(described_class.project("new-project")).to eq expected
|
325
342
|
end
|
326
343
|
end
|
327
344
|
end
|
328
345
|
|
329
346
|
describe "#validate" do
|
330
|
-
let(:default) {
|
347
|
+
let(:default) { described_class::LOCAL_DEFAULT }
|
331
348
|
|
332
349
|
context "when a project config file is provided" do
|
333
350
|
it "should raise if the project config file can't be found" do
|
334
351
|
project_config = "dont-exist.yml"
|
335
352
|
regex = /Project config \(#{project_config}\) doesn't exist\./
|
336
353
|
expect do
|
337
|
-
|
354
|
+
described_class.validate(project_config: project_config)
|
338
355
|
end.to raise_error RuntimeError, regex
|
339
356
|
end
|
340
357
|
|
341
358
|
it "should load and validate the project" do
|
342
359
|
project_config = File.join(fixtures_dir, "sample.yml")
|
343
|
-
expect(
|
360
|
+
expect(described_class.validate(project_config: project_config)).to \
|
344
361
|
be_a Tmuxinator::Project
|
345
362
|
end
|
346
363
|
|
347
364
|
it "should take precedence over a named project" do
|
348
|
-
allow(
|
365
|
+
allow(described_class).to receive_messages(directory: fixtures_dir)
|
349
366
|
project_config = File.join(fixtures_dir, "sample_number_as_name.yml")
|
350
|
-
project =
|
351
|
-
|
367
|
+
project = described_class.validate(name: "sample",
|
368
|
+
project_config: project_config)
|
352
369
|
expect(project.name).to eq("222")
|
353
370
|
end
|
354
371
|
|
355
372
|
it "should take precedence over a local project" do
|
356
|
-
expect(
|
373
|
+
expect(described_class).not_to receive(:local?)
|
357
374
|
project_config = File.join(fixtures_dir, "sample_number_as_name.yml")
|
358
|
-
project =
|
375
|
+
project = described_class.validate(project_config: project_config)
|
359
376
|
expect(project.name).to eq("222")
|
360
377
|
end
|
361
378
|
end
|
@@ -363,13 +380,13 @@ describe Tmuxinator::Config do
|
|
363
380
|
context "when a project name is provided" do
|
364
381
|
it "should raise if the project file can't be found" do
|
365
382
|
expect do
|
366
|
-
|
383
|
+
described_class.validate(name: "sample")
|
367
384
|
end.to raise_error RuntimeError, %r{Project.+doesn't.exist}
|
368
385
|
end
|
369
386
|
|
370
387
|
it "should load and validate the project" do
|
371
|
-
expect(
|
372
|
-
expect(
|
388
|
+
expect(described_class).to receive_messages(directory: fixtures_dir)
|
389
|
+
expect(described_class.validate(name: "sample")).to \
|
373
390
|
be_a Tmuxinator::Project
|
374
391
|
end
|
375
392
|
end
|
@@ -378,7 +395,7 @@ describe Tmuxinator::Config do
|
|
378
395
|
it "should raise if the local project file doesn't exist" do
|
379
396
|
expect(File).to receive(:exist?).with(default) { false }
|
380
397
|
expect do
|
381
|
-
|
398
|
+
described_class.validate
|
382
399
|
end.to raise_error RuntimeError, %r{Project.+doesn't.exist}
|
383
400
|
end
|
384
401
|
|
@@ -388,18 +405,19 @@ describe Tmuxinator::Config do
|
|
388
405
|
expect(File).to receive(:exist?).with(default).at_least(:once) { true }
|
389
406
|
expect(File).to receive(:read).with(default).and_return(content)
|
390
407
|
|
391
|
-
expect(
|
408
|
+
expect(described_class.validate).to be_a Tmuxinator::Project
|
392
409
|
end
|
393
410
|
end
|
394
411
|
|
395
412
|
context "when no project can be found" do
|
396
413
|
it "should raise with NO_PROJECT_FOUND_MSG" do
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
414
|
+
expect(described_class).to receive_messages(
|
415
|
+
valid_project_config?: false,
|
416
|
+
valid_local_project?: false,
|
417
|
+
valid_standard_project?: false
|
418
|
+
)
|
401
419
|
expect do
|
402
|
-
|
420
|
+
described_class.validate
|
403
421
|
end.to raise_error RuntimeError, %r{Project could not be found\.}
|
404
422
|
end
|
405
423
|
end
|
@@ -8,7 +8,7 @@ describe Tmuxinator::Doctor do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns true" do
|
11
|
-
expect(
|
11
|
+
expect(described_class.installed?).to be_truthy
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,7 +18,7 @@ describe Tmuxinator::Doctor do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "returns false" do
|
21
|
-
expect(
|
21
|
+
expect(described_class.installed?).to be_falsey
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -30,7 +30,7 @@ describe Tmuxinator::Doctor do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "returns true" do
|
33
|
-
expect(
|
33
|
+
expect(described_class.editor?).to be_truthy
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -40,7 +40,7 @@ describe Tmuxinator::Doctor do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "returns false" do
|
43
|
-
expect(
|
43
|
+
expect(described_class.editor?).to be_falsey
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -52,7 +52,7 @@ describe Tmuxinator::Doctor do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "returns true" do
|
55
|
-
expect(
|
55
|
+
expect(described_class.shell?).to be_truthy
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -62,7 +62,7 @@ describe Tmuxinator::Doctor do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "returns false" do
|
65
|
-
expect(
|
65
|
+
expect(described_class.shell?).to be_falsey
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -33,12 +33,12 @@ describe Tmuxinator::Window do
|
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
36
|
-
let(:window) {
|
37
|
-
let(:window_root) {
|
36
|
+
let(:window) { described_class.new(yaml, 0, project) }
|
37
|
+
let(:window_root) { described_class.new(yaml_root, 0, project) }
|
38
38
|
|
39
39
|
shared_context "window command context" do
|
40
40
|
let(:project) { double(:project) }
|
41
|
-
let(:window) {
|
41
|
+
let(:window) { described_class.new(yaml, 0, project) }
|
42
42
|
let(:root?) { true }
|
43
43
|
let(:root) { "/project/tmuxinator" }
|
44
44
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tmuxinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allen Bargi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-12-
|
12
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: erubis
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- spec/fixtures/sample_with_project_config.yml
|
273
273
|
- spec/fixtures/xdg-tmuxinator/both.yml
|
274
274
|
- spec/fixtures/xdg-tmuxinator/xdg.yml
|
275
|
+
- spec/fixtures/yaml.yaml
|
275
276
|
- spec/lib/tmuxinator/cli_spec.rb
|
276
277
|
- spec/lib/tmuxinator/config_spec.rb
|
277
278
|
- spec/lib/tmuxinator/doctor_spec.rb
|
@@ -335,6 +336,7 @@ test_files:
|
|
335
336
|
- spec/fixtures/sample_with_project_config.yml
|
336
337
|
- spec/fixtures/xdg-tmuxinator/both.yml
|
337
338
|
- spec/fixtures/xdg-tmuxinator/xdg.yml
|
339
|
+
- spec/fixtures/yaml.yaml
|
338
340
|
- spec/lib/tmuxinator/cli_spec.rb
|
339
341
|
- spec/lib/tmuxinator/config_spec.rb
|
340
342
|
- spec/lib/tmuxinator/doctor_spec.rb
|