Sha256: 37d3d0a8d39602852030cb33be9df9bb9d7f0607ad93858b8b97587bde60ed68

Contents?: true

Size: 1.66 KB

Versions: 12

Compression:

Stored size: 1.66 KB

Contents

# -*- encoding: utf-8 -*-
#
# Author:: Douglas Triggs (<doug@getchef.com>)
#
# Copyright (C) 2014, Chef, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This is the generic action handler
module ChefMetal
  class ActionHandler

    # This should be replaced with whatever records the update; by default it
    # essentially does nothing here.
    def updated!
      @updated = true
    end

    def should_perform_actions
      true
    end

    def report_progress(description)
      Array(description).each { |d| puts d }
    end

    def performed_action(description)
      Array(description).each { |d| puts d }
    end

    # This should perform the actual action (e.g., converge) if there is an
    # action that needs to be done.
    def perform_action(description)
      if should_perform_actions
        result = yield
      else
        result = nil
      end
      performed_action(description)
      result
    end

    # Open a stream which can be printed to and closed
    def open_stream(name)
      if block_given?
        yield STDOUT
      else
        STDOUT
      end
    end

    # A URL identifying the host node. nil if no such node.
    def host_node
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
clc-fork-chef-metal-0.14.alpha.10 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.9 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.8 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.7 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.6 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.5 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.4 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.3 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.2 lib/chef_metal/action_handler.rb
chef-metal-0.14.2 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.14.alpha.1 lib/chef_metal/action_handler.rb
chef-metal-0.14.1 lib/chef_metal/action_handler.rb