Class: Ec2ssh::Command::Update

Inherits:
Base
  • Object
show all
Defined in:
lib/ec2ssh/command/update.rb

Instance Attribute Summary

Attributes inherited from Base

#cli

Instance Method Summary collapse

Methods inherited from Base

#dotfile, #dotfile_path, #ssh_config_path

Constructor Details

#initialize(cli) ⇒ Update

Returns a new instance of Update.



10
11
12
# File 'lib/ec2ssh/command/update.rb', line 10

def initialize(cli)
  super
end

Instance Method Details

#builderObject



25
26
27
# File 'lib/ec2ssh/command/update.rb', line 25

def builder
  @builder ||= Builder.new dsl
end

#dslObject



29
30
31
# File 'lib/ec2ssh/command/update.rb', line 29

def dsl
  @dsl ||= Ec2ssh::Dsl::Parser.parse File.read(dotfile_path)
end

#runObject

Raises:



14
15
16
17
18
19
20
21
22
23
# File 'lib/ec2ssh/command/update.rb', line 14

def run
  ssh_config = SshConfig.new(ssh_config_path)
  raise MarkNotFound unless ssh_config.mark_exist?

  ssh_config.parse!
  lines = builder.build_host_lines
  ssh_config_str = ssh_config.wrap lines
  ssh_config.replace! ssh_config_str
  cli.yellow ssh_config_str
end