UbiquoJobs::Helpers::ShellJob

Public Class Methods

new(*args) click to toggle source

On creation, set and validate the command

    # File vendor/plugins/ubiquo_jobs/lib/ubiquo_jobs/helpers/shell_job.rb, line 12
12:       def initialize(*args)
13:         super(*args)
14:         set_command
15:         validate_command
16:       end

Protected Instance Methods

do_job_work() click to toggle source

Overrides the do_job_work method of a normal Job Executes the command, the before_ and after_execution callbacks, and manages the results

    # File vendor/plugins/ubiquo_jobs/lib/ubiquo_jobs/helpers/shell_job.rb, line 24
24:       def do_job_work
25:         before_execution if self.respond_to?(:before_execution)
26:         output = %x{#{command}}
27:         self.update_attribute :result_output, output
28:         after_execution if self.respond_to?(:after_execution)
29:         $?
30:       end
escape_sh(param) click to toggle source

Escapes a string to make it safe to use as a command line parameter Based on Ruby’s 1.8.7 Shellwords::shellescape method

    # File vendor/plugins/ubiquo_jobs/lib/ubiquo_jobs/helpers/shell_job.rb, line 45
45:       def escape_sh(param)
46:         param.gsub(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
47:       end
set_command() click to toggle source

Method used to set the command to be executed

    # File vendor/plugins/ubiquo_jobs/lib/ubiquo_jobs/helpers/shell_job.rb, line 33
33:       def set_command
34:         raise NotImplementedError.new("Implement set_command() in your Job subclass") unless command
35:       end
validate_command() click to toggle source

Validates that the set command is correct

    # File vendor/plugins/ubiquo_jobs/lib/ubiquo_jobs/helpers/shell_job.rb, line 38
38:       def validate_command
39:         errors.add_on_blank(:command)
40:         false unless errors.empty?
41:       end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.