tmuxinator 3.3.2 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdf76e1aba70cccc6acf0166890b8b040879783a37c8d0ceec71253014e791f9
4
- data.tar.gz: 5640fb566bc3bdd5559de9f973173a7a5c191e59325152b8f1e25a396720f0f3
3
+ metadata.gz: f5ef87c54d6e438767477e9e41cbe4d0b0d802c6aa980d07d1921819a7dc2b81
4
+ data.tar.gz: dc974393d493a3ebfd556c87615472acc34f4dc328bb2a31b277ad40a865c8d1
5
5
  SHA512:
6
- metadata.gz: ce504b0cd0ab29d9536676b00fd1e8e8efd2f0aa248265f95ab0092df9038f44bb9b64abad28e4b57e48d05a7a81edb0ad52a4531ca33a0669ee7911682f2b0e
7
- data.tar.gz: b19d2a5072cf93013fa91ee6849412b8d6988e8ba12e1298ca134abaed59eb840853f93df004c09f1adb5d62ac1cffbca0ae3a91b3661af4a892770e42c57f09
6
+ metadata.gz: dec7830c2331a3fb50a36afd880168ab3ec616900b41ba87c33e610235ee5cb935f794c1738ab5054bc78e3303b3fc078a1a380aed45fd7c9a08870b6a360ca0
7
+ data.tar.gz: 182bc06919fe54d090fc455c5f69c5a653115887d495acba204cc2112ffd7379e759d3ed8d40067b8c00be1b20d95468f15a72562728400bfbb806f4a7020ede
@@ -391,13 +391,17 @@ module Tmuxinator
391
391
  method_option :newline, type: :boolean,
392
392
  aliases: ["-n"],
393
393
  desc: "Force output to be one entry per line."
394
+ method_option :active, type: :boolean,
395
+ aliases: ["-a"],
396
+ desc: "Filter output by active project sessions."
394
397
 
395
398
  def list
396
399
  say "tmuxinator projects:"
400
+ configs = Tmuxinator::Config.configs(active: options[:active])
397
401
  if options[:newline]
398
- say Tmuxinator::Config.configs.join("\n")
402
+ say configs.join("\n")
399
403
  else
400
- print_in_columns Tmuxinator::Config.configs
404
+ print_in_columns configs
401
405
  end
402
406
  end
403
407
 
@@ -126,13 +126,33 @@ module Tmuxinator
126
126
  asset_path "wemux_template.erb"
127
127
  end
128
128
 
129
- # Sorted list of all .yml files, including duplicates
130
- def configs
131
- directories.map do |directory|
129
+ # List of all active tmux sessions
130
+ def active_sessions
131
+ `tmux list-sessions -F "#S"`.split("\n")
132
+ end
133
+
134
+ # Sorted list of all project .yml file basenames, including duplicates
135
+ #
136
+ # @param active filter configs by active project sessions
137
+ # @return [Array<String>] list of project names
138
+ def configs(active: nil)
139
+ configs = config_file_basenames
140
+
141
+ if active == true
142
+ configs &= active_sessions
143
+ elsif active == false
144
+ configs -= active_sessions
145
+ end
146
+
147
+ configs
148
+ end
149
+
150
+ def config_file_basenames
151
+ directories.flat_map do |directory|
132
152
  Dir["#{directory}/**/*.yml"].map do |path|
133
153
  path.gsub("#{directory}/", "").gsub(".yml", "")
134
154
  end
135
- end.flatten.sort
155
+ end.sort
136
156
  end
137
157
 
138
158
  # Existent directories which may contain project files
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tmuxinator
4
- VERSION = "3.3.2"
4
+ VERSION = "3.3.3"
5
5
  end
@@ -845,6 +845,14 @@ describe Tmuxinator::Cli do
845
845
  end
846
846
  end
847
847
 
848
+ context "set --active flag " do
849
+ ARGV.replace(["list", "--active"])
850
+
851
+ it "is a valid option" do
852
+ expect { capture_io { cli.start } }.to_not raise_error
853
+ end
854
+ end
855
+
848
856
  context "no arguments are given" do
849
857
  ARGV.replace(["list"])
850
858
 
@@ -281,6 +281,26 @@ describe Tmuxinator::Config do
281
281
  to eq ["both", "both", "dup/local-dup", "home", "local-dup", "xdg"]
282
282
  end
283
283
 
284
+ it "gets a sorted list of all active projects" do
285
+ allow(described_class).to receive(:environment?).and_return false
286
+ allow(described_class).
287
+ to receive(:active_sessions).
288
+ and_return ["both", "home"]
289
+
290
+ expect(described_class.configs(active: true)).
291
+ to eq ["both", "home"]
292
+ end
293
+
294
+ it "gets a sorted list excluding active projects" do
295
+ allow(described_class).to receive(:environment?).and_return false
296
+ allow(described_class).
297
+ to receive(:active_sessions).
298
+ and_return ["both", "home"]
299
+
300
+ expect(described_class.configs(active: false)).
301
+ to eq ["dup/local-dup", "local-dup", "xdg"]
302
+ end
303
+
284
304
  it "lists only projects in $TMUXINATOR_CONFIG when set" do
285
305
  allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
286
306
  and_return "#{fixtures_dir}/TMUXINATOR_CONFIG"
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: 3.3.2
4
+ version: 3.3.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: 2024-10-24 00:00:00.000000000 Z
12
+ date: 2024-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubi