Sha256: 2cedb5b4babecff443ded1fe2348b4da8e1994dcec07093f8daa8cc9cfedf545

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'albacore/support/albacore_helper'

class PLink
  extend AttrMethods
  include RunCommand
  include YAMLConfig
  include Logging

  attr_accessor :host, :port, :user, :key, :verbose
  attr_array :commands

  def initialize()
      @require_valid_command = false
      @port = 22
      @verbose = false
      @commands = []
      super()
  end

  def run()
    check_command
    return if @failed
    parameters = create_parameters
    result = run_command "Plink", parameters.join(" ")
    failure_message = 'Command Failed. See Build Log For Detail'
    fail_with_message failure_message if !result
  end
  
  def create_parameters
    parameters = []
    parameters << "#{@user}@#{@host} -P #{@port} "
    parameters << build_parameter("i", @key) unless @key.nil?
    parameters << "-batch"
    parameters << "-v" if @verbose
    parameters << @commands
    @logger.debug "PLink Parameters" + parameters.join(" ")
    return parameters
  end

  def build_parameter(param_name, param_value)
    "-#{param_name} #{param_value}"
  end

  def check_command
    return if @path_to_command
    fail_with_message 'Plink.path_to_command cannot be nil.'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
albacore-0.1.1 lib/albacore/plink.rb
albacore-0.1.0 lib/albacore/plink.rb