Sha256: 0bd84f4183d48e3a90075e19c98d8a92ed3beeca4ed646071059b646ccad8ed7

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby
require "runbook"

Runbook::Runs::SSHKit.register_hook(
  :output_before_hook,
  :before,
  Object
) do |object, metadata|
  location = "#{object.class}: #{metadata[:position]}"
  metadata[:toolbox].output " [Before: #{location}]\n"
end

Runbook::Runs::SSHKit.register_hook(
  :output_around_hook,
  :around,
  Object
) do |object, metadata, block|
  location = "#{object.class}: #{metadata[:position]}"
  metadata[:toolbox].output "  [Around_before: #{location}]\n"
  block.call(object, metadata)
  metadata[:toolbox].output "  [Around_after: #{location}]\n"
end

Runbook::Runs::SSHKit.register_hook(
  :output_after_hook,
  :after,
  Object
) do |object, metadata|
  location = "#{object.class}: #{metadata[:position]}"
  metadata[:toolbox].output " [After: #{location}]\n"
end

runbook = Runbook.book "Example Hooks Runbook" do
  description <<-DESC
This is a runbook for playing with runbook hooks
  DESC

  layout [[
    :runbook,
    :bottom,
  ]]

  section "Hook" do
    step do
      note "Looky, Looky, I got a hooky"
    end

    step
  end

  section "Fishing Hooks" do
    step do
      note "Hooked, line, and sinker"
    end

    step
  end

  section "Hooked on Phonics" do
    step do
      note "Huked on Phoonics reely werx 4 mee"
    end

    step
  end
end

if __FILE__ == $0
  Runbook::Runner.new(runbook).run
else
  runbook
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
careacademy-runbook-1.2.0 examples/hooks_runbook.rb
runbook-1.1.0 examples/hooks_runbook.rb
runbook-1.0.0 examples/hooks_runbook.rb
runbook-0.16.1 examples/hooks_runbook.rb
runbook-0.16.0 examples/hooks_runbook.rb
runbook-0.15.0 samples/hooks_runbook.rb
runbook-0.14.0 samples/hooks_runbook.rb
runbook-0.13.0 samples/hooks_runbook.rb
runbook-0.12.1 samples/hooks_runbook.rb