Class: Rundock::Operation::Base
Direct Known Subclasses
Constant Summary collapse
- OperationNotImplementedError =
Class.new(NotImplementedError)
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#instruction ⇒ Object
readonly
Returns the value of attribute instruction.
Instance Method Summary collapse
- #assign_args(src, args) ⇒ Object
-
#initialize(instruction, attributes) ⇒ Base
constructor
A new instance of Base.
- #logging(message, severity) ⇒ Object
- #run(backend, attributes = {}) ⇒ Object
Constructor Details
#initialize(instruction, attributes) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 |
# File 'lib/rundock/operation/base.rb', line 9 def initialize(instruction, attributes) @instruction = instruction @attributes = attributes @attributes = {} unless attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/rundock/operation/base.rb', line 7 def attributes @attributes end |
#instruction ⇒ Object (readonly)
Returns the value of attribute instruction.
6 7 8 |
# File 'lib/rundock/operation/base.rb', line 6 def instruction @instruction end |
Instance Method Details
#assign_args(src, args) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rundock/operation/base.rb', line 25 def assign_args(src, args) return src unless args src.gsub(/\$#/, args.length.to_s) .gsub(/\$@/, args.join(' ')) .gsub(/\$[1-9]/) { |arg_n| args[arg_n.chars[1..-1].join.to_i - 1] } .gsub(/(\$\{)(\w+)(\})/) { ENV[Regexp.last_match(2)] } end |
#logging(message, severity) ⇒ Object
19 20 21 22 23 |
# File 'lib/rundock/operation/base.rb', line 19 def logging(, severity) h_host = @attributes[:nodename].just(' ', 15) h_ope = "start #{self.class.to_s.split('::').last.downcase}:" Logger.send(severity.to_sym, "#{h_host} #{h_ope} #{}") end |
#run(backend, attributes = {}) ⇒ Object
15 16 17 |
# File 'lib/rundock/operation/base.rb', line 15 def run(backend, attributes = {}) raise OperationNotImplementedError end |