Class: SSHKit::CommandMap
- Inherits:
-
Object
- Object
- SSHKit::CommandMap
- Defined in:
- lib/sshkit/command_map.rb
Defined Under Namespace
Classes: PrefixProvider
Instance Method Summary collapse
- #[](command) ⇒ Object
- #[]=(command, new_command) ⇒ Object
- #clear ⇒ Object
- #defaults ⇒ Object
-
#initialize(value = nil) ⇒ CommandMap
constructor
A new instance of CommandMap.
- #prefix ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ CommandMap
Returns a new instance of CommandMap.
15 16 17 |
# File 'lib/sshkit/command_map.rb', line 15 def initialize(value = nil) @map = value || defaults end |
Instance Method Details
#[](command) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/sshkit/command_map.rb', line 19 def [](command) if prefix[command].any? prefixes = prefix[command].join(" ") "#{prefixes} #{command}" else @map[command] end end |
#[]=(command, new_command) ⇒ Object
33 34 35 |
# File 'lib/sshkit/command_map.rb', line 33 def []=(command, new_command) @map[command] = new_command end |
#clear ⇒ Object
37 38 39 |
# File 'lib/sshkit/command_map.rb', line 37 def clear @map = defaults end |
#defaults ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/sshkit/command_map.rb', line 41 def defaults Hash.new do |hash, command| if %w{if test time}.include? command.to_s hash[command] = command.to_s else hash[command] = "/usr/bin/env #{command}" end end end |
#prefix ⇒ Object
29 30 31 |
# File 'lib/sshkit/command_map.rb', line 29 def prefix @prefix ||= PrefixProvider.new end |