Class: EacRubyUtils::Envs::SshEnv

Inherits:
BaseEnv show all
Defined in:
lib/eac_ruby_utils/envs/ssh_env.rb,
lib/eac_ruby_utils/envs/ssh_env/quiet.rb,
lib/eac_ruby_utils/envs/ssh_env/terminal.rb,
lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb,
lib/eac_ruby_utils/envs/ssh_env/identity_file.rb

Defined Under Namespace

Modules: DashoOptions, IdentityFile, Quiet, Terminal

Constant Summary collapse

USER_PATTERN =
/[a-z_][a-z0-9_-]*/.freeze
HOSTNAME_PATTERN =
/[^@]+/.freeze
USER_HOSTNAME_PATTERN =
/\A(?:(#{USER_PATTERN})@)?(#{HOSTNAME_PATTERN})\z/.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseEnv

#command, #executable, #file, #file_exist?

Constructor Details

#initialize(uri) ⇒ SshEnv

Returns a new instance of SshEnv.



41
42
43
44
# File 'lib/eac_ruby_utils/envs/ssh_env.rb', line 41

def initialize(uri)
  super()
  @uri = self.class.parse_uri(uri).freeze
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



39
40
41
# File 'lib/eac_ruby_utils/envs/ssh_env.rb', line 39

def uri
  @uri
end

Class Method Details

.parse_uri(uri) ⇒ Object



20
21
22
# File 'lib/eac_ruby_utils/envs/ssh_env.rb', line 20

def parse_uri(uri)
  uri_by_url(uri) || uri_by_user_hostname(uri) || raise("URI has no SSH scheme: #{uri}")
end

Instance Method Details

#command_line(line) ⇒ Object



48
49
50
# File 'lib/eac_ruby_utils/envs/ssh_env.rb', line 48

def command_line(line)
  "#{ssh_command_line} #{Shellwords.escape(line)}"
end