Sha256: 0c3adee67b3ebab2051f3a6f90b863dec3e553fca4022c615c30cf65e7b89b51

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 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()
    return unless check_command
    
    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 true if @path_to_command
    fail_with_message 'Plink.path_to_command cannot be nil.'
    return false
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
albacore-0.1.5 lib/albacore/plink.rb
albacore-0.1.4 lib/albacore/plink.rb
albacore-0.1.3 lib/albacore/plink.rb
albacore-0.1.2 lib/albacore/plink.rb