Sha256: b992baca1a543b6016b6b13030c9fe137aa9cb3af8967b529d5525d585cf6094

Contents?: true

Size: 1.5 KB

Versions: 15

Compression:

Stored size: 1.5 KB

Contents

#
# plugin.rb - An example Einhorn plugin.
#
# Including this file in [yourgemhere]/lib/einhorn/plugins/ will cause Einhorn
# to load it.  This example plugin defines all the methods that Einhorn
# recognizes and will invoke, although none of these methods is required.
#

module Einhorn::Plugins
  module ExamplePlugin
    # If a State module is defined, its contents will be passed to new
    # einhorn processes when einhorn is reloaded
    module State
      extend Einhorn::AbstractState
      def self.default_state
        {
          :yay => nil
        }
      end
    end

    def self.initialize_example_plugin
      # The initializer method must be named `initialize_##[plugin_name]',
      # where [plugin_name] is the name of the plugin module or class in
      # lower_case_with_underscores.
      puts 'I will be called before einhorn does any work.'
    end

    def self.optparse(opts)
      opts.on("--my-option X", "Patch einhorn with additional options!") do |x|
        State.yay = x
      end
    end

    def self.post_optparse
      # Called after all options native to einhorn or patched by any plugins
      # are parsed. Good place to do argument validation
      raise "Argument --my-option is required" unless State.yay
    end

    def self.event_loop
      # Called each time einhorn enters its event loop, in which it cleans up
      # any terminated children and respawns them.
    end

    def self.exit
      # Called after the event loop terminates, just before einhorn exits.
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
einhorn-0.6.5 example/plugin.rb
einhorn-0.6.4 example/plugin.rb
einhorn-0.6.3 example/plugin.rb
einhorn-0.6.2 example/plugin.rb
einhorn-0.6.1 example/plugin.rb
einhorn-0.6.0 example/plugin.rb
einhorn-0.5.7 example/plugin.rb
einhorn-0.5.6 example/plugin.rb
einhorn-0.5.5 example/plugin.rb
einhorn-0.5.4 example/plugin.rb
einhorn-0.5.3 example/plugin.rb
einhorn-0.5.2 example/plugin.rb
einhorn-0.5.1 example/plugin.rb
einhorn-0.5.0 example/plugin.rb
einhorn-0.4.9 example/plugin.rb