Class: Utils::ConfigFile::SshTunnel
- Inherits:
-
BlockConfig
- Object
- BlockConfig
- Utils::ConfigFile::SshTunnel
- Defined in:
- lib/utils/config_file.rb
Overview
SSH tunnel configuration manager
Provides functionality for configuring and managing SSH tunnels with support for different terminal multiplexers like tmux and screen. Allows setting up tunnel specifications with local and remote address/port combinations, handling environment variables, and managing copy/paste functionality for tunnel sessions.
Defined Under Namespace
Classes: CopyPaste
Instance Method Summary collapse
-
#copy_paste(enable = false) {|block| ... } ⇒ CopyPaste?
The copy_paste method manages the copy-paste functionality by returning an existing instance or creating a new one.
-
#initialize ⇒ SshTunnel
constructor
The initialize method sets up the instance by calling the superclass constructor and assigning the terminal multiplexer configuration.
-
#multiplexer_attach(session) ⇒ String
The multiplexer_attach method generates a command string for attaching to a session using either screen or tmux multiplexer.
-
#multiplexer_list ⇒ String?
The multiplexer_list method returns the appropriate command string for listing sessions based on the current multiplexer type.
-
#multiplexer_new(session) ⇒ String?
The multiplexer_new method generates a command string for creating a new session in the specified terminal multiplexer.
-
#terminal_multiplexer=(terminal_multiplexer) ⇒ Object
The terminal_multiplexer= method sets the terminal multiplexer type for the editor.
Methods inherited from BlockConfig
config, inherited, lazy_config, #to_ruby
Constructor Details
#initialize ⇒ SshTunnel
The initialize method sets up the instance by calling the superclass constructor and assigning the terminal multiplexer configuration.
565 566 567 568 |
# File 'lib/utils/config_file.rb', line 565 def initialize super self.terminal_multiplexer = terminal_multiplexer end |
Instance Method Details
#copy_paste(enable = false) {|block| ... } ⇒ CopyPaste?
The copy_paste method manages the copy-paste functionality by returning an existing instance or creating a new one.
This method checks if a copy-paste instance already exists and returns it if available. If no instance exists, it creates a new one based on whether a block is provided or the enable flag is set to true.
instance, or nil if not enabled
697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/utils/config_file.rb', line 697 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) ⇒ String
The multiplexer_attach method generates a command string for attaching to a session using either screen or tmux multiplexer.
622 623 624 625 626 627 628 629 |
# File 'lib/utils/config_file.rb', line 622 def multiplexer_attach(session) case @multiplexer when 'screen' 'screen -DUR "%s"' % session when 'tmux' 'tmux -u attach -d -t "%s"' % session end end |
#multiplexer_list ⇒ String?
The multiplexer_list method returns the appropriate command string for listing sessions based on the current multiplexer type.
591 592 593 594 595 596 597 598 |
# File 'lib/utils/config_file.rb', line 591 def multiplexer_list case @multiplexer when 'screen' 'screen -ls' when 'tmux' 'tmux ls' end end |
#multiplexer_new(session) ⇒ String?
The multiplexer_new method generates a command string for creating a new session in the specified terminal multiplexer.
607 608 609 610 611 612 613 614 |
# File 'lib/utils/config_file.rb', line 607 def multiplexer_new(session) case @multiplexer when 'screen' 'false' when 'tmux' 'tmux -u new -s "%s"' % session end end |
#terminal_multiplexer=(terminal_multiplexer) ⇒ Object
The terminal_multiplexer= method sets the terminal multiplexer type for the editor.
This method assigns the specified terminal multiplexer to the editor configuration, validating that it is either ‘screen’ or ‘tmux’. It converts the input to a string and ensures it matches one of the supported multiplexer types.
be configured
580 581 582 583 584 |
# File 'lib/utils/config_file.rb', line 580 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 |