Class: Rundock::Builder::DefaultSshBuilder

Inherits:
Base show all
Defined in:
lib/rundock/builder/default_ssh_builder.rb

Constant Summary collapse

PRESET_SSH_OPTIONS_DEFAULT_FILE_PATH =
"#{Gem::Specification.find_by_path('rundock').full_gem_path}/default_ssh.yml"

Constants inherited from Base

Base::BuilderNotImplementedError

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ DefaultSshBuilder

Returns a new instance of DefaultSshBuilder.



8
9
10
# File 'lib/rundock/builder/default_ssh_builder.rb', line 8

def initialize(options)
  super(options)
end

Instance Method Details

#buildObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rundock/builder/default_ssh_builder.rb', line 12

def build
  opts = {}

  if @options[:default_ssh_opts] && FileTest.exist?(@options[:default_ssh_opts])
    def_ssh_file = @options[:default_ssh_opts]
  else
    def_ssh_file = PRESET_SSH_OPTIONS_DEFAULT_FILE_PATH
  end

  File.open(def_ssh_file) do |f|
    YAML.load_documents(f) do |y|
      y.each do |k, v|
        opts["#{k}_ssh_default".to_sym] = v
      end
    end
  end

  opts
end