tmuxinator 0.10.0 → 0.10.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b82c1fce5acc4afbea3917be671204b8ec18ce24
4
- data.tar.gz: '06860d74aa9ccabd291d0f4e996fdfdf803600d9'
3
+ metadata.gz: 7855a8b99f46048a0d44b79346cd87fee6364c4a
4
+ data.tar.gz: 7676ef2c515adec3a19b15a056eb8e69b2f9ecde
5
5
  SHA512:
6
- metadata.gz: e240783bffcbabaa05f371944a7e6654117b9ca1840e7cb2cdf736171943e740973ce8d38506d67c8cd5a8b2ebab360727f3d67b84587c2241c4850e568118ef
7
- data.tar.gz: ca0fc2c809ead67680c77cbb2fff2a43d917ffaa6a89c40ed9ef2c46eef2f517611814c2b385979c18401709158e4695d602bec448d599d70148a0789d916012
6
+ metadata.gz: 47fba1ba5c244c5381ee93a94e48d15aaff6b8bdb36490f2897de3759c7fea3f90395868dc2194c61d86cc4458a648aba7359d6fa2b7232f334900cadf774ee5
7
+ data.tar.gz: bd71de3f1b6144b69d42a0d20b5900ed8d6112fb4ee608113ca71ecb2f8a6384fa7ca13fe1609715303cb7a47c5fb5921a0f7f475c2f88915d8e0fda08ab4113
@@ -6,6 +6,23 @@ require "thor/version"
6
6
  require "xdg"
7
7
  require "yaml"
8
8
 
9
+ module Tmuxinator
10
+ SUPPORTED_TMUX_VERSIONS = [
11
+ 1.5,
12
+ 1.6,
13
+ 1.7,
14
+ 1.8,
15
+ 1.9,
16
+ 2.0,
17
+ 2.1,
18
+ 2.2,
19
+ 2.3,
20
+ 2.4,
21
+ 2.5,
22
+ 2.6
23
+ ].freeze
24
+ end
25
+
9
26
  require "tmuxinator/util"
10
27
  require "tmuxinator/deprecations"
11
28
  require "tmuxinator/wemux_support"
@@ -18,6 +35,3 @@ require "tmuxinator/pane"
18
35
  require "tmuxinator/project"
19
36
  require "tmuxinator/window"
20
37
  require "tmuxinator/version"
21
-
22
- module Tmuxinator
23
- end
@@ -3,6 +3,7 @@ module Tmuxinator
3
3
  LOCAL_DEFAULT = "./.tmuxinator.yml".freeze
4
4
  NO_LOCAL_FILE_MSG =
5
5
  "Project file at ./.tmuxinator.yml doesn't exist.".freeze
6
+ TMUX_MASTER_VERSION = Float::INFINITY
6
7
 
7
8
  class << self
8
9
  # The directory (created if needed) in which to store new projects
@@ -45,7 +46,15 @@ module Tmuxinator
45
46
  end
46
47
 
47
48
  def version
48
- `tmux -V`.split(" ")[1].to_f if Tmuxinator::Doctor.installed?
49
+ if Tmuxinator::Doctor.installed?
50
+ tmux_version = `tmux -V`.split(" ")[1]
51
+
52
+ if tmux_version == "master"
53
+ TMUX_MASTER_VERSION
54
+ else
55
+ tmux_version.to_f
56
+ end
57
+ end
49
58
  end
50
59
 
51
60
  def default_path_option
@@ -38,7 +38,7 @@ module Tmuxinator
38
38
  end
39
39
 
40
40
  def pane_index
41
- index + tab.project.base_index
41
+ index + tab.project.pane_base_index
42
42
  end
43
43
 
44
44
  def tmux_split_command
@@ -34,6 +34,11 @@ module Tmuxinator
34
34
  DEPRECATION: the post option has been replaced by project hooks and will
35
35
  not be supported anymore.
36
36
  M
37
+ TMUX_MASTER_DEP_MSG = <<-M
38
+ DEPRECATION: You are running tmuxinator with an unsupported version of tmux.
39
+ Please consider using a supported version:
40
+ (#{Tmuxinator::SUPPORTED_TMUX_VERSIONS.join(', ')})
41
+ M
37
42
 
38
43
  attr_reader :yaml
39
44
  attr_reader :force_attach
@@ -49,7 +54,7 @@ module Tmuxinator
49
54
  @args = args
50
55
 
51
56
  content = Erubis::Eruby.new(raw_content).result(binding)
52
- YAML.load(content)
57
+ YAML.safe_load(content)
53
58
  rescue SyntaxError, StandardError => error
54
59
  raise "Failed to parse config file: #{error.message}"
55
60
  end
@@ -172,7 +177,14 @@ module Tmuxinator
172
177
  # if no tmux sessions exist.
173
178
  # Please see issues #402 and #414.
174
179
  sessions = `#{tmux_command} ls 2> /dev/null`
175
- !!sessions.match("^#{name}:")
180
+
181
+ # Remove any escape sequences added by `shellescape` in Project#name.
182
+ # Escapes can result in: "ArgumentError: invalid multibyte character"
183
+ # when attempting to match `name` against `sessions`.
184
+ # Please see issue #564.
185
+ unescaped_name = name.shellsplit.join("")
186
+
187
+ !(sessions !~ /^#{unescaped_name}:/)
176
188
  end
177
189
 
178
190
  def socket
@@ -264,7 +276,8 @@ module Tmuxinator
264
276
  cli_args?,
265
277
  legacy_synchronize?,
266
278
  pre?,
267
- post?
279
+ post?,
280
+ unsupported_version?
268
281
  ]
269
282
  end
270
283
 
@@ -275,7 +288,8 @@ module Tmuxinator
275
288
  CLIARGS_DEP_MSG,
276
289
  SYNC_DEP_MSG,
277
290
  PRE_DEP_MSG,
278
- POST_DEP_MSG
291
+ POST_DEP_MSG,
292
+ TMUX_MASTER_DEP_MSG
279
293
  ]
280
294
  end
281
295
 
@@ -307,6 +321,10 @@ module Tmuxinator
307
321
  yaml["post"]
308
322
  end
309
323
 
324
+ def unsupported_version?
325
+ !Tmuxinator::SUPPORTED_TMUX_VERSIONS.include?(Tmuxinator::Config.version)
326
+ end
327
+
310
328
  def get_pane_base_index
311
329
  tmux_config["pane-base-index"]
312
330
  end
@@ -1,3 +1,3 @@
1
1
  module Tmuxinator
2
- VERSION = "0.10.0".freeze
2
+ VERSION = "0.10.1".freeze
3
3
  end
@@ -129,7 +129,7 @@ module Tmuxinator
129
129
  end
130
130
 
131
131
  def tmux_select_first_pane
132
- "#{project.tmux} select-pane -t #{tmux_window_target}.#{panes.first.index + project.base_index}"
132
+ "#{project.tmux} select-pane -t #{tmux_window_target}.#{panes.first.index + project.pane_base_index}"
133
133
  end
134
134
 
135
135
  def synchronize_before?
@@ -1,6 +1,7 @@
1
1
  def yaml_load(file)
2
- YAML.load(File.read(File.expand_path(file)))
2
+ YAML.safe_load(File.read(File.expand_path(file)))
3
3
  end
4
+
4
5
  FactoryGirl.define do
5
6
  factory :project, class: Tmuxinator::Project do
6
7
  transient do
@@ -41,6 +42,14 @@ FactoryGirl.define do
41
42
  initialize_with { Tmuxinator::Project.new(file) }
42
43
  end
43
44
 
45
+ factory :project_with_emoji_as_name, class: Tmuxinator::Project do
46
+ transient do
47
+ file { yaml_load("spec/fixtures/sample_emoji_as_name.yml") }
48
+ end
49
+
50
+ initialize_with { Tmuxinator::Project.new(file) }
51
+ end
52
+
44
53
  factory :project_with_literals_as_window_name, class: Tmuxinator::Project do
45
54
  transient do
46
55
  file { yaml_load("spec/fixtures/sample_literals_as_window_name.yml") }
@@ -0,0 +1,5 @@
1
+ # ~/.tmuxinator/sample_emoji_as_name.yml
2
+
3
+ name: 🍩
4
+ windows:
5
+ - emoji: echo 🍩
@@ -143,6 +143,26 @@ describe Tmuxinator::Config do
143
143
  end
144
144
  end
145
145
 
146
+ describe "#version" do
147
+ subject { Tmuxinator::Config.version }
148
+
149
+ before do
150
+ expect(Tmuxinator::Doctor).to receive(:installed?).and_return(true)
151
+ allow_any_instance_of(Kernel).to receive(:`).with(/tmux\s\-V/).
152
+ and_return("tmux #{version}")
153
+ end
154
+
155
+ context "master" do
156
+ let(:version) { "master" }
157
+ it { is_expected.to eq Float::INFINITY }
158
+ end
159
+
160
+ context "installed" do
161
+ let(:version) { "2.4" }
162
+ it { is_expected.to eq version.to_f }
163
+ end
164
+ end
165
+
146
166
  describe "#default_path_option" do
147
167
  context ">= 1.8" do
148
168
  before do
@@ -15,6 +15,7 @@ describe Tmuxinator::Pane do
15
15
  before do
16
16
  allow(project).to receive(:name).and_return "foo"
17
17
  allow(project).to receive(:base_index).and_return 0
18
+ allow(project).to receive(:pane_base_index).and_return 1
18
19
 
19
20
  allow(window).to receive(:project).and_return project
20
21
  allow(window).to receive(:index).and_return 0
@@ -26,5 +27,5 @@ describe Tmuxinator::Pane do
26
27
  expect(subject).to be_a(Tmuxinator::Pane)
27
28
  end
28
29
 
29
- it { expect(subject.tmux_window_and_pane_target).to eql "foo:0.0" }
30
+ it { expect(subject.tmux_window_and_pane_target).to eql "foo:0.1" }
30
31
  end
@@ -8,6 +8,9 @@ describe Tmuxinator::Project do
8
8
  let(:project_with_number_as_name) do
9
9
  FactoryGirl.build(:project_with_number_as_name)
10
10
  end
11
+ let(:project_with_emoji_as_name) do
12
+ FactoryGirl.build(:project_with_emoji_as_name)
13
+ end
11
14
  let(:project_with_literals_as_window_name) do
12
15
  FactoryGirl.build(:project_with_literals_as_window_name)
13
16
  end
@@ -165,6 +168,14 @@ describe Tmuxinator::Project do
165
168
  end
166
169
  end
167
170
 
171
+ context "as emoji" do
172
+ it "will gracefully handle a name given as an emoji" do
173
+ rendered = project_with_emoji_as_name
174
+ # needs to allow for \\ present in shellescape'd project name
175
+ expect(rendered.name).to match(/^\\*🍩/)
176
+ end
177
+ end
178
+
168
179
  context "window as non-string literal" do
169
180
  it "will gracefully handle a window name given as a non-string literal" do
170
181
  rendered = project_with_literals_as_window_name
@@ -60,6 +60,7 @@ describe Tmuxinator::Window do
60
60
  tmux: "tmux",
61
61
  name: "test",
62
62
  base_index: 1,
63
+ pane_base_index: 0,
63
64
  root: "/project/tmuxinator",
64
65
  root?: true
65
66
  )
@@ -369,4 +370,10 @@ describe Tmuxinator::Window do
369
370
  end
370
371
  end
371
372
  end
373
+
374
+ describe "#tmux_select_first_pane" do
375
+ it "targets the pane based on the configured pane_base_index" do
376
+ expect(window.tmux_select_first_pane).to eq("tmux select-pane -t test:1.0")
377
+ end
378
+ end
372
379
  end
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.10.0
4
+ version: 0.10.1
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: 2017-09-19 00:00:00.000000000 Z
12
+ date: 2017-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis
@@ -183,14 +183,14 @@ dependencies:
183
183
  requirements:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: 0.46.0
186
+ version: 0.48.1
187
187
  type: :development
188
188
  prerelease: false
189
189
  version_requirements: !ruby/object:Gem::Requirement
190
190
  requirements:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: 0.46.0
193
+ version: 0.48.1
194
194
  - !ruby/object:Gem::Dependency
195
195
  name: simplecov
196
196
  requirement: !ruby/object:Gem::Requirement
@@ -249,6 +249,7 @@ files:
249
249
  - spec/fixtures/nowindows.yml
250
250
  - spec/fixtures/sample.deprecations.yml
251
251
  - spec/fixtures/sample.yml
252
+ - spec/fixtures/sample_emoji_as_name.yml
252
253
  - spec/fixtures/sample_literals_as_window_name.yml
253
254
  - spec/fixtures/sample_number_as_name.yml
254
255
  - spec/fixtures/sample_wemux.yml
@@ -309,6 +310,7 @@ test_files:
309
310
  - spec/fixtures/nowindows.yml
310
311
  - spec/fixtures/sample.deprecations.yml
311
312
  - spec/fixtures/sample.yml
313
+ - spec/fixtures/sample_emoji_as_name.yml
312
314
  - spec/fixtures/sample_literals_as_window_name.yml
313
315
  - spec/fixtures/sample_number_as_name.yml
314
316
  - spec/fixtures/sample_wemux.yml