Class: PLink

Inherits:
Object
  • Object
show all
Includes:
Albacore::RunCommand, Albacore::Task
Defined in:
lib/albacore/plink.rb

Instance Attribute Summary collapse

Attributes included from Albacore::RunCommand

#command, #working_directory

Attributes included from Logging

#current_log_device, #logger

Instance Method Summary collapse

Methods included from Albacore::RunCommand

#get_command, #run_command

Methods included from AttrMethods

#attr_array, #attr_hash

Methods included from Albacore::Task

clean_dirname, create_rake_task, include_config, included

Methods included from UpdateAttributes

#<<, #update_attributes

Methods included from YAMLConfig

#configure, #load_config_by_task_name

Methods included from Logging

#create_logger, #log_device=, #log_level, #log_level=

Methods included from Failure

#fail_with_message

Constructor Details

#initializePLink

Returns a new instance of PLink.



10
11
12
13
14
15
16
# File 'lib/albacore/plink.rb', line 10

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

Instance Attribute Details

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/albacore/plink.rb', line 7

def host
  @host
end

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/albacore/plink.rb', line 7

def key
  @key
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/albacore/plink.rb', line 7

def port
  @port
end

#userObject

Returns the value of attribute user.



7
8
9
# File 'lib/albacore/plink.rb', line 7

def user
  @user
end

#verboseObject

Returns the value of attribute verbose.



7
8
9
# File 'lib/albacore/plink.rb', line 7

def verbose
  @verbose
end

Instance Method Details

#build_parameter(param_name, param_value) ⇒ Object



38
39
40
# File 'lib/albacore/plink.rb', line 38

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

#check_commandObject



42
43
44
45
46
# File 'lib/albacore/plink.rb', line 42

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

#create_parametersObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/albacore/plink.rb', line 27

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

#runObject



18
19
20
21
22
23
24
25
# File 'lib/albacore/plink.rb', line 18

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