Sha256: 7a90eae1686812d04f996897d33c178ed4494fd2f437608f3378c51af3bbf5ac

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

require 'albacore/albacoretask'

class PLink
  include Albacore::Task
  include Albacore::RunCommand

  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 @command
    fail_with_message 'Plink.path_to_command cannot be nil.'
    return false
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
albacore-0.3.6 lib/albacore/plink.rb
albacore-1.0.0.rc.2 lib/albacore/plink.rb
albacore-1.0.0.rc.1 lib/albacore/plink.rb
albacore-0.3.5 lib/albacore/plink.rb
albacore-0.3.4 lib/albacore/plink.rb
albacore-0.3.3 lib/albacore/plink.rb
albacore-0.3.2 lib/albacore/plink.rb
albacore-0.3.1 lib/albacore/plink.rb
albacore-0.3.0 lib/albacore/plink.rb
albacore-0.2.7 lib/albacore/plink.rb
albacore-0.2.6 lib/albacore/plink.rb