class SSHKit::CommandMap

Constants

TO_VALUE

Public Class Methods

new(value = nil) click to toggle source
# File lib/sshkit/command_map.rb, line 36
def initialize(value = nil)
  @map = CommandHash.new(value || defaults)
end

Public Instance Methods

[](command) click to toggle source
# File lib/sshkit/command_map.rb, line 40
def [](command)
  if prefix[command].any?
    prefixes = prefix[command].map(&TO_VALUE)
    prefixes = prefixes.join(" ")

    "#{prefixes} #{command}"
  else
    TO_VALUE.(@map[command])
  end
end
[]=(command, new_command) click to toggle source
# File lib/sshkit/command_map.rb, line 55
def []=(command, new_command)
  @map[command] = new_command
end
clear() click to toggle source
# File lib/sshkit/command_map.rb, line 59
def clear
  @map = CommandHash.new(defaults)
end
defaults() click to toggle source
# File lib/sshkit/command_map.rb, line 63
def defaults
  Hash.new do |hash, command|
    if %w{if test time exec}.include? command.to_s
      hash[command] = command.to_s
    else
      hash[command] = "/usr/bin/env #{command}"
    end
  end
end
prefix() click to toggle source
# File lib/sshkit/command_map.rb, line 51
def prefix
  @prefix ||= PrefixProvider.new
end