Sha256: 003dda5af0b59b09fd471ae732e790d3942eb49f6e1255e60421fce76c7ba40a

Contents?: true

Size: 998 Bytes

Versions: 13

Compression:

Stored size: 998 Bytes

Contents

require 'rundock'

module Rundock
  class Node
    attr_reader :name
    attr_reader :operations
    attr_reader :backend
    attr_accessor :hooks

    def initialize(name, backend)
      @name = name
      @backend = backend
      @operations = []
      @hooks = []
    end

    def add_operation(ope)
      @operations = [] unless @operations
      @operations << ope
    end

    def run
      Logger.formatter.on_rec
      Logger.debug("run node: #{@name}")
      Logger.warn("no operation running: #{@name}") if @operations.blank?

      node_attributes = []

      @operations.each do |ope|
        Logger.debug("run operation: #{ope.class}")
        node_attributes << ope.attributes
        ope.run(@backend, ope.attributes)
      end

      log_buffer = Logger.formatter.flush unless Logger.formatter.buffer.empty?

      @hooks.each do |h|
        Logger.debug("run hook: #{h.name}")
        h.hook(node_attributes, log_buffer)
      end

      Logger.formatter.off_rec
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rundock-1.0.6 lib/rundock/node.rb
rundock-1.0.5 lib/rundock/node.rb
rundock-1.0.4 lib/rundock/node.rb
rundock-1.0.2 lib/rundock/node.rb
rundock-1.0.1 lib/rundock/node.rb
rundock-1.0.0 lib/rundock/node.rb
rundock-0.5.8 lib/rundock/node.rb
rundock-0.5.7 lib/rundock/node.rb
rundock-0.5.4 lib/rundock/node.rb
rundock-0.5.3 lib/rundock/node.rb
rundock-0.5.2 lib/rundock/node.rb
rundock-0.5.0 lib/rundock/node.rb
rundock-0.4.16 lib/rundock/node.rb