Sha256: 0d0cddaa57de7625aa2ad68cc5192e2cad17e22954d4369f3019e4a8c51c3e50

Contents?: true

Size: 1.61 KB

Versions: 28

Compression:

Stored size: 1.61 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
        yield
      end
      performed_action(description)
    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

28 entries across 28 versions & 2 rubygems

Version Path
chef-metal-0.14 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.13.alpha.1 lib/chef_metal/action_handler.rb
chef-metal-0.13 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.12.1.alpha.4 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.12.1.alpha.3 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.12.1.alpha.2 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.12.1.alpha.1 lib/chef_metal/action_handler.rb
chef-metal-0.12.1 lib/chef_metal/action_handler.rb
chef-metal-0.12 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.11.2.alpha.3 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.11.2.alpha.2 lib/chef_metal/action_handler.rb
clc-fork-chef-metal-0.11.2.alpha.1 lib/chef_metal/action_handler.rb
chef-metal-0.11.2 lib/chef_metal/action_handler.rb
chef-metal-0.11.1 lib/chef_metal/action_handler.rb
chef-metal-0.11 lib/chef_metal/action_handler.rb
chef-metal-0.11.beta.11 lib/chef_metal/action_handler.rb
chef-metal-0.11.beta.10 lib/chef_metal/action_handler.rb
chef-metal-0.11.beta.9 lib/chef_metal/action_handler.rb
chef-metal-0.11.beta.8 lib/chef_metal/action_handler.rb
chef-metal-0.11.beta.7 lib/chef_metal/action_handler.rb