Class: Patriot::Command::PostProcessor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/patriot/command/post_processor/base.rb

Overview

The base class of every post processor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • props (Hash) (defaults to: {})

    properties of this post processor



24
25
26
27
28
# File 'lib/patriot/command/post_processor/base.rb', line 24

def initialize(props = {})
  @props = {}
  props.each{|k,v| @props[k.to_sym] = v}
  validate_props(@props)
end

Instance Attribute Details

#propsObject

Returns the value of attribute props.



21
22
23
# File 'lib/patriot/command/post_processor/base.rb', line 21

def props
  @props
end

Class Method Details

.declare_post_processor_name(mth_name, parent_cls = Patriot::Command::Base, processor_cls = self) ⇒ Object

declare DSL method name for adding a post processor

Parameters:

  • mth_name (String)

    the DSL method name

  • parent_cls (Class<Patriot::Command::Base>) (defaults to: Patriot::Command::Base)

    parent command in which the post porcessor is available

  • processor_cls (Class<Patriot::Command::PostProcessor::Base] the class of the post processor) (defaults to: self)

    rocessor_cls [Class<Patriot::Command::PostProcessor::Base] the class of the post processor



12
13
14
15
16
17
18
19
# File 'lib/patriot/command/post_processor/base.rb', line 12

def self.declare_post_processor_name(mth_name, parent_cls=Patriot::Command::Base, processor_cls=self)
  parent_cls.class_eval do
    define_method(mth_name) do |processor_props = {}|
      pp = processor_cls.new(processor_props)
      add_post_processor(pp)
    end
  end
end

Instance Method Details

#process(cmd, worker, job_ticket) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/patriot/command/post_processor/base.rb', line 33

def process(cmd, worker, job_ticket)
  case job_ticket.exit_code
  when Patriot::Command::ExitCode::SUCCEEDED then return process_success(cmd, worker, job_ticket)
  when Patriot::Command::ExitCode::FAILED    then return process_failure(cmd, worker, job_ticket)
  end
  return true
end

#process_failure(cmd, worker, job_ticket) ⇒ Object



45
46
47
# File 'lib/patriot/command/post_processor/base.rb', line 45

def process_failure(cmd, worker, job_ticket)
  return true
end

#process_success(cmd, worker, job_ticket) ⇒ Object



41
42
43
# File 'lib/patriot/command/post_processor/base.rb', line 41

def process_success(cmd, worker, job_ticket)
  return true
end

#validate_props(props) ⇒ Object



30
31
# File 'lib/patriot/command/post_processor/base.rb', line 30

def validate_props(props)
end