Class: SshMenu::Actions
- Inherits:
-
Object
- Object
- SshMenu::Actions
- Defined in:
- lib/sshmenu/actions.rb
Class Method Summary collapse
Instance Method Summary collapse
- #connect(index) ⇒ Object
- #edit ⇒ Object
-
#initialize(config) ⇒ Actions
constructor
A new instance of Actions.
Constructor Details
#initialize(config) ⇒ Actions
Returns a new instance of Actions.
6 7 8 9 10 |
# File 'lib/sshmenu/actions.rb', line 6 def initialize(config) @general = config.general @connections = config.connections @config_file = config.config_file end |
Class Method Details
.ask_edit_with_default_editor ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/sshmenu/actions.rb', line 35 def self.ask_edit_with_default_editor editor = Config.default_editor config = Config.default_config_file print "Edit #{config} using default editor '#{editor}' [y/N]? " exec("#{editor} #{config}") if STDIN.getc[/[Yy]/] end |
Instance Method Details
#connect(index) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sshmenu/actions.rb', line 17 def connect(index) conn = @connections[index] if index >= @connections.size puts "invalid index: #{index}" exit end cmd = [@general['ssh_exec'], @general['ssh_opts'], conn['ssh_opts'], conn['user_host'] ].join(' ') puts "Command is #{cmd}" if $DEBUG puts "Connecting to #{conn['user_host']}" exec(cmd) end |
#edit ⇒ Object
12 13 14 15 |
# File 'lib/sshmenu/actions.rb', line 12 def edit puts "Edit config file #@config_file" exec("#{@general['editor']} #@config_file") end |