Sha256: ca1a1e463a8e97063807727cfde84e86e8e97d25bafe5504ce792a1c26515864

Contents?: true

Size: 572 Bytes

Versions: 17

Compression:

Stored size: 572 Bytes

Contents

require_relative 'hook'

module Cloudstrap
  module Hooks
    def hooks
      return [] unless Dir.exist? config.hooks_dir

      Dir
        .entries(config.hooks_dir)
        .reject { |entry| %w(. ..).include? entry }
        .map { |entry| Hook.new entry, host: jumpbox_ip, key: ssh_key.private_file }
    end

    def hook(name)
      hook = hooks.find { |h| h.name == name }
      return unless hook
      hook.call
    end

    def hooking(event)
      return unless block_given?
      hook "pre-#{event}"
      yield.tap { hook "post-#{event}" }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cloudstrap-0.51.1.pre lib/cloudstrap/hooks.rb
cloudstrap-0.50.1.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.12.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.11.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.10.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.8.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.4.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.2.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.1.pre lib/cloudstrap/hooks.rb
cloudstrap-0.49.0.pre lib/cloudstrap/hooks.rb
cloudstrap-0.48.15.pre lib/cloudstrap/hooks.rb
cloudstrap-0.48.2.pre lib/cloudstrap/hooks.rb
cloudstrap-0.48.0.pre lib/cloudstrap/hooks.rb
cloudstrap-0.47.8.pre lib/cloudstrap/hooks.rb
cloudstrap-0.47.7.pre lib/cloudstrap/hooks.rb
cloudstrap-0.47.2.pre lib/cloudstrap/hooks.rb
cloudstrap-0.47.0.pre lib/cloudstrap/hooks.rb