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.



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

def initialize(cli)
  super
end

Instance Method Details

#builderObject



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

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

#dslObject



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

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

#migratorObject



34
35
36
# File 'lib/ec2ssh/command/update.rb', line 34

def migrator
  @migrator ||= Migrator.new dotfile_path
end

#runObject

Raises:



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

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