Working Remotely? Thinking about it?

Are you a member of a geographically dispersed team? Are you thinking of working remotely, or hiring remote developers? Wide Teams is my new blog and podcast for distributed teams. Check it out for getting started guides, tips and best practices, news, interviews, screencasts, and more all about working remotely and collaborating with wide-spread teams.

[ANN] HookR 1.0.0

2008 December 5
by avdi

I’m pleased to announce the availability of “HookR”:http://hookr.rubyforge.org 1.0.0

h2. Description

HookR is a publish/subscribe callback hook facility for Ruby.

h2. What is it?

HookR can be understood in a few different ways.

* If you are familiar with Events and Event Listeners in “Java”:http://java.sun.com/docs/books/tutorial/javabeans/events/index.html or “C#”:http://msdn.microsoft.com/en-us/library/aa645739(VS.71).aspx; “Hooks”:http://www.gnu.org/software/emacs/manual/html_node/elisp/Hooks.html#Hooks in Emacs-lisp; or signals-and-slots as implemented in the “Qt”:http://doc.trolltech.com/4.4/signalsandslots.html, “Boost.Signals”:http://www.boost.org/doc/libs/1_37_0/doc/html/signals.html, or “libsigc++”:http://libsigc.sourceforge.net/ frameworks – HookR provides a very similar facility.
* If you’ve ever used the Observer standard library, but wished you could have more than one type of notification per observable object, HookR is the library for you.
* HookR is an easy way to add “Rails-style”:http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html before- and after-filters to your own classes.
* HookR is an “Inversion-of-Control”:http://martinfowler.com/bliki/InversionOfControl.html framework in that it makes it easy to write event-driven code.
* HookR is a way to support a limited, structured form of Aspect Oriented Programming (“AOP”:http://en.wikipedia.org/wiki/Aspect-oriented_programming) where the advisable events are explicitly defined.

h2. What HookR is not:

* HookR is not (yet) an asynchronous event notification system. No provision is made for multi-threaded operation or event queueing.
* HookR will show you a good time, but it will not make you breakfast in the morning.

h2. Synopsis

  require 'rubygems'
  require 'hookr'

  class ZeroWing
    include HookR::Hooks
    define_hook :we_get_signal, :message

    def start_game
      execute_hook(:we_get_signal, "How are you gentlemen?")
    end

    def bomb(event, message)
      puts "somebody set us up the bomb!"
    end

    we_get_signal do |event, message|
      puts "Main screen turn on!"
      puts "Cats: #{message}"
    end

    we_get_signal :bomb

  end

  zw = ZeroWing.new
  zw.we_get_signal do
    puts "Take off every zig!"
  end

  zw.start_game
  # >> Main screen turn on!
  # >> Cats: How are you gentlemen?
  # >> somebody set us up the bomb!
  # >> Take off every zig!

h2. Get it Now

Pull your hat way down over your eyes, drive over to the your local red-light district, and type:

sudo gem install hookr

For more information, check out the website: http://hookr.rubyforge.org

Bookmark and Share
Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Related posts:

  1. [ANN] fail-fast 1.0.0 Released
  2. Announcing Firetower – A command-line interface to Campfire
  3. [ANN] alter-ego 1.0.0 Released
  4. ISO8601 Dates in Ruby
  5. Sustainable Development in Ruby, Part 2: Method Injection
  • You have no idea the degree of cognitive dissonance this evoked when I stumbled across it before my first morning coffee...
blog comments powered by Disqus