lib/guard/notifiers/tmux.rb in guard-2.5.1 vs lib/guard/notifiers/tmux.rb in guard-2.6.0

- old
+ new

@@ -202,29 +202,31 @@ end # Notification starting, save the current Tmux settings # and quiet the Tmux output. # - def turn_on + def self.turn_on unless @options_stored _reset_options_store + _clients.each do |client| options_store[client] ||= {} `#{ DEFAULTS[:client] } show -t #{ client }`.each_line do |line| option, _, setting = line.chomp.partition(' ') @options_store[client][option] = setting end end + @options_stored = true end end # Notification stopping. Restore the previous Tmux state # if available (existing options are restored, new options # are unset) and unquiet the Tmux output. # - def turn_off + def self.turn_off if @options_stored @options_store.each do |client, options| options.each do |key, value| if value `#{ DEFAULTS[:client] } set -t #{ client } -q #{ key } #{ value }` @@ -235,23 +237,27 @@ end _reset_options_store end end - def options_store + def self.options_store @options_store ||= {} end private def system(args) args += " >#{ DEV_NULL } 2>&1" if ENV['GUARD_ENV'] == 'test' super end + def self._clients + `#{ DEFAULTS[:client] } list-clients -F '\#{ client_tty }'`.split(/\n/) + end + def _clients - %x( #{DEFAULTS[:client]} list-clients -F '\#{client_tty}').split(/\n/); + self.class._client end def _run_client(cmd, args) if @options.fetch(:display_on_all_clients, DEFAULTS[:display_on_all_clients]) _clients.each do |client| @@ -269,14 +275,15 @@ end end # Reset the internal Tmux options store defaults. # - def _reset_options_store + def self._reset_options_store @options_stored = false @options_store = {} - _clients.each do | client | + + _clients.each do |client| @options_store[client] = { 'status-left-bg' => nil, 'status-right-bg' => nil, 'status-left-fg' => nil, 'status-right-fg' => nil, @@ -285,19 +292,11 @@ 'display-time' => nil } end end - # Remove clients which no longer exist from options store - # - def _remove_old_clients - (options_store.keys - _clients).each do | old_client | - options_store.delete old_client - end - end - def _tmux_version - @tmux_version ||= `tmux -V`.chomp.gsub(/[^0-9.]/,'').to_f + @tmux_version ||= `tmux -V`.chomp.gsub(/[^0-9.]/, '').to_f end end end