tmuxinator 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/tmuxinator +1 -10
- data/lib/tmuxinator/assets/sample.yml +1 -1
- data/lib/tmuxinator/cli.rb +31 -0
- data/lib/tmuxinator/version.rb +1 -1
- data/spec/lib/tmuxinator/cli_spec.rb +161 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67d2add167813b344a5424b97ac84bb6b726165d52a071bacc1864ddbbd06eae
|
4
|
+
data.tar.gz: 8c48ba6566bf06b8168b83b87144fb47c7b879d88f419cd45bb113a4231c7615
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9440f1aad417be22cb857a9b5854fec445bd46b4ef9540bb70b70550ff43f335ecef26b4b9ffb6d126124790589df5a39b676fcc41d43ffa229c68d0e3f6122c
|
7
|
+
data.tar.gz: 6150cea906e82d4f7038cb5ec383930c5e1d293801c92e807c97b0f2468448849fa451c988d32880ecec2812062581bf0306711b56ed9fecd7743c88bc615e80
|
data/bin/tmuxinator
CHANGED
@@ -4,13 +4,4 @@ $:.unshift File.expand_path("../../lib/", __FILE__)
|
|
4
4
|
require "thor"
|
5
5
|
require "tmuxinator"
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
if ARGV.empty? && Tmuxinator::Config.local?
|
10
|
-
Tmuxinator::Cli.new.local
|
11
|
-
elsif name && !Tmuxinator::Cli::COMMANDS.keys.include?(name.to_sym) &&
|
12
|
-
Tmuxinator::Config.exists?(name: name)
|
13
|
-
Tmuxinator::Cli.new.start(name, *ARGV.drop(1))
|
14
|
-
else
|
15
|
-
Tmuxinator::Cli.start
|
16
|
-
end
|
7
|
+
Tmuxinator::Cli.bootstrap ARGV
|
data/lib/tmuxinator/cli.rb
CHANGED
@@ -34,6 +34,17 @@ module Tmuxinator
|
|
34
34
|
list: "Lists all tmuxinator projects"
|
35
35
|
}.freeze
|
36
36
|
|
37
|
+
# For future reference: due to how tmuxinator currently consumes
|
38
|
+
# command-line arguments (see ::bootstrap, below), invocations of Thor's
|
39
|
+
# base commands (i.e. 'help', etc) can be instead routed to #start (rather
|
40
|
+
# than to ::start). In order to prevent this, the THOR_COMMANDS and
|
41
|
+
# RESERVED_COMMANDS constants have been introduced. The former enumerates
|
42
|
+
# any/all Thor commands we want to insure get passed through to Thor.start.
|
43
|
+
# The latter is the superset of the Thor commands and any tmuxinator
|
44
|
+
# commands, defined in COMMANDS, above.
|
45
|
+
THOR_COMMANDS = %w[-v help].freeze
|
46
|
+
RESERVED_COMMANDS = (COMMANDS.keys + THOR_COMMANDS).map(&:to_s).freeze
|
47
|
+
|
37
48
|
package_name "tmuxinator" \
|
38
49
|
unless Gem::Version.create(Thor::VERSION) < Gem::Version.create("0.18")
|
39
50
|
|
@@ -344,5 +355,25 @@ module Tmuxinator
|
|
344
355
|
say "Checking if $SHELL is set ==> "
|
345
356
|
yes_no Tmuxinator::Doctor.shell?
|
346
357
|
end
|
358
|
+
|
359
|
+
# This method was defined as something of a workaround... Previously
|
360
|
+
# the conditional contained within was in the executable (i.e.
|
361
|
+
# bin/tmuxinator). It has been moved here so as to be testable. A couple
|
362
|
+
# of notes:
|
363
|
+
# - ::start (defined in Thor::Base) expects the first argument to be an
|
364
|
+
# array or ARGV, not a varargs. Perhaps ::bootstrap should as well?
|
365
|
+
# - ::start has a different purpose from #start and hence a different
|
366
|
+
# signature
|
367
|
+
def self.bootstrap(args = [])
|
368
|
+
name = args[0] || nil
|
369
|
+
if args.empty? && Tmuxinator::Config.local?
|
370
|
+
Tmuxinator::Cli.new.local
|
371
|
+
elsif name && !Tmuxinator::Cli::RESERVED_COMMANDS.include?(name) &&
|
372
|
+
Tmuxinator::Config.exists?(name: name)
|
373
|
+
Tmuxinator::Cli.new.start(name, *args.drop(1))
|
374
|
+
else
|
375
|
+
Tmuxinator::Cli.start(args)
|
376
|
+
end
|
377
|
+
end
|
347
378
|
end
|
348
379
|
end
|
data/lib/tmuxinator/version.rb
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Tmuxinator::Cli do
|
4
|
+
shared_context :local_project_setup do
|
5
|
+
let(:local_project_config) { ".tmuxinator.yml" }
|
6
|
+
let(:content_fixture) { "../../fixtures/sample.yml" }
|
7
|
+
let(:content_relpath) { File.join(File.dirname(__FILE__), content_fixture) }
|
8
|
+
let(:content_path) { File.expand_path(content_relpath) }
|
9
|
+
let(:content) { File.read(content_path) }
|
10
|
+
let(:working_dir) { FileUtils.pwd }
|
11
|
+
let(:local_project_relpath) { File.join(working_dir, local_project_config) }
|
12
|
+
let(:local_project_path) { File.expand_path(local_project_relpath) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
File.new(local_project_path, "w").tap do |f|
|
16
|
+
f.write content
|
17
|
+
end.close
|
18
|
+
expect(File.exists?(local_project_path)).to be_truthy
|
19
|
+
expect(File.read(local_project_path)).to eq content
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
File.delete(local_project_path)
|
24
|
+
end
|
25
|
+
end
|
4
26
|
let(:cli) { Tmuxinator::Cli }
|
5
27
|
|
6
28
|
before do
|
@@ -18,6 +40,128 @@ describe Tmuxinator::Cli do
|
|
18
40
|
end
|
19
41
|
end
|
20
42
|
|
43
|
+
context "base thor functionality" do
|
44
|
+
shared_examples_for :base_thor_functionality do
|
45
|
+
it "supports -v" do
|
46
|
+
out, err = capture_io { cli.bootstrap(["-v"]) }
|
47
|
+
expect(err).to eq ""
|
48
|
+
expect(out).to include(Tmuxinator::VERSION)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "supports help" do
|
52
|
+
out, err = capture_io { cli.bootstrap(["help"]) }
|
53
|
+
expect(err).to eq ""
|
54
|
+
expect(out).to include("tmuxinator commands:")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it_should_behave_like :base_thor_functionality
|
59
|
+
|
60
|
+
context "with a local project config" do
|
61
|
+
include_context :local_project_setup
|
62
|
+
|
63
|
+
it_should_behave_like :base_thor_functionality
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "::bootstrap" do
|
68
|
+
subject { cli.bootstrap(args) }
|
69
|
+
let(:args) { [] }
|
70
|
+
|
71
|
+
shared_examples_for :bootstrap_with_arguments do
|
72
|
+
let(:args) { [arg1] }
|
73
|
+
|
74
|
+
context "and the first arg is a tmuxinator command" do
|
75
|
+
let(:arg1) { "list" }
|
76
|
+
|
77
|
+
it "should call ::start" do
|
78
|
+
expect(cli).to receive(:start).with(args)
|
79
|
+
subject
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "and the first arg is" do
|
84
|
+
let(:arg1) { "sample" }
|
85
|
+
|
86
|
+
context "a tmuxinator project name" do
|
87
|
+
before do
|
88
|
+
expect(Tmuxinator::Config).to \
|
89
|
+
receive(:exists?).with(name: arg1) { true }
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should call #start" do
|
93
|
+
instance = instance_double(cli)
|
94
|
+
expect(cli).to receive(:new).and_return(instance)
|
95
|
+
expect(instance).to receive(:start).with(*args)
|
96
|
+
subject
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "a thor command" do
|
101
|
+
context "(-v)" do
|
102
|
+
let(:arg1) { "-v" }
|
103
|
+
|
104
|
+
it "should call ::start" do
|
105
|
+
expect(cli).to receive(:start).with(args)
|
106
|
+
subject
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "(help)" do
|
111
|
+
let(:arg1) { "help" }
|
112
|
+
|
113
|
+
it "should call ::start" do
|
114
|
+
expect(cli).to receive(:start).with(args)
|
115
|
+
subject
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "something else" do
|
121
|
+
before do
|
122
|
+
expect(Tmuxinator::Config).to \
|
123
|
+
receive(:exists?).with(name: arg1) { false }
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should call ::start" do
|
127
|
+
expect(cli).to receive(:start).with(args)
|
128
|
+
subject
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "and there is a local project config" do
|
135
|
+
include_context :local_project_setup
|
136
|
+
|
137
|
+
context "when no args are supplied" do
|
138
|
+
it "should call #local" do
|
139
|
+
instance = instance_double(cli)
|
140
|
+
expect(cli).to receive(:new).and_return(instance)
|
141
|
+
expect(instance).to receive(:local)
|
142
|
+
subject
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when one or more args are supplied" do
|
147
|
+
it_should_behave_like :bootstrap_with_arguments
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "and there is no local project config" do
|
152
|
+
context "when no args are supplied" do
|
153
|
+
it "should call ::start" do
|
154
|
+
expect(cli).to receive(:start).with([])
|
155
|
+
subject
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "when one or more args are supplied" do
|
160
|
+
it_should_behave_like :bootstrap_with_arguments
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
21
165
|
describe "#completions" do
|
22
166
|
before do
|
23
167
|
ARGV.replace(["completions", "start"])
|
@@ -638,21 +782,26 @@ describe Tmuxinator::Cli do
|
|
638
782
|
end
|
639
783
|
|
640
784
|
describe "#generate_project_file" do
|
641
|
-
let(:name) { "foobar" }
|
642
|
-
let(:path) { Tmuxinator::Config.default_project(name) }
|
785
|
+
let(:name) { "foobar-#{Time.now.to_i}" }
|
643
786
|
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
787
|
+
it "should always generate a project file" do
|
788
|
+
Dir.mktmpdir do |dir|
|
789
|
+
path = "#{dir}/#{name}.yml"
|
790
|
+
expect(File).not_to exist(path), "expected file at #{path} not to exist"
|
791
|
+
new_path = Tmuxinator::Cli.new.generate_project_file(name, path)
|
792
|
+
expect(new_path).to eq path
|
793
|
+
expect(File).to exist new_path
|
794
|
+
end
|
650
795
|
end
|
651
796
|
|
652
|
-
it "should
|
653
|
-
|
654
|
-
|
655
|
-
|
797
|
+
it "should generate a project file using the correct project file path" do
|
798
|
+
file = StringIO.new
|
799
|
+
allow(File).to receive(:open) { |&block| block.yield file }
|
800
|
+
Dir.mktmpdir do |dir|
|
801
|
+
path = "#{dir}/#{name}.yml"
|
802
|
+
_ = Tmuxinator::Cli.new.generate_project_file(name, path)
|
803
|
+
expect(file.string).to match %r{\A# #{path}$}
|
804
|
+
end
|
656
805
|
end
|
657
806
|
end
|
658
807
|
|
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.11.
|
4
|
+
version: 0.11.3
|
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
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: erubis
|