Class: Utils::ConfigFile::SshTunnel

Inherits:
BlockConfig show all
Defined in:
lib/utils/config_file.rb

Defined Under Namespace

Classes: CopyPaste

Instance Method Summary collapse

Methods inherited from BlockConfig

config, inherited, #to_ruby

Constructor Details

#initializeSshTunnel

Returns a new instance of SshTunnel.



186
187
188
189
# File 'lib/utils/config_file.rb', line 186

def initialize
  super
  self.terminal_multiplexer = terminal_multiplexer
end

Instance Method Details

#copy_paste(enable = false, &block) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
# File 'lib/utils/config_file.rb', line 238

def copy_paste(enable = false, &block)
  if @copy_paste
    @copy_paste
  else
    if block
      @copy_paste = CopyPaste.new(&block)
    elsif enable
      @copy_paste = CopyPaste.new {}
    end
  end
end

#multiplexer_attach(session) ⇒ Object



215
216
217
218
219
220
221
222
# File 'lib/utils/config_file.rb', line 215

def multiplexer_attach(session)
  case @multiplexer
  when 'screen'
    'screen -DUR "%s"' % session
  when 'tmux'
    'tmux -u attach -d -t "%s"' % session
  end
end

#multiplexer_listObject



197
198
199
200
201
202
203
204
# File 'lib/utils/config_file.rb', line 197

def multiplexer_list
  case @multiplexer
  when 'screen'
    'screen -ls'
  when 'tmux'
    'tmux ls'
  end
end

#multiplexer_new(session) ⇒ Object



206
207
208
209
210
211
212
213
# File 'lib/utils/config_file.rb', line 206

def multiplexer_new(session)
  case @multiplexer
  when 'screen'
    'false'
  when 'tmux'
    'tmux -u new -s "%s"' % session
  end
end

#terminal_multiplexer=(terminal_multiplexer) ⇒ Object



191
192
193
194
195
# File 'lib/utils/config_file.rb', line 191

def terminal_multiplexer=(terminal_multiplexer)
  @multiplexer = terminal_multiplexer.to_s
  @multiplexer =~ /\A(screen|tmux)\z/ or
    fail "invalid terminal_multiplexer #{terminal_multiplexer.inspect} was configured"
end