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
# File 'lib/eac_ruby_utils/envs/ssh_env.rb', line 41

def initialize(uri)
  @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


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

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

#to_sObject


45
46
47
# File 'lib/eac_ruby_utils/envs/ssh_env.rb', line 45

def to_s
  uri.to_s
end