Command Hooks #187

h3rald opened this Issue Nov 28, 2010 · 0 comments


None yet

1 participant

h3rald commented Nov 28, 2010

Implementation Hints

You'd have to store Proc objects somewhere, i.e. a Glyph::HOOKS hash, maybe something like this:

          :before: # proc
          :after: # proc
      # ...
      # ...

Then you'd need something to evaluate the hooks.rb with. You could define a new class or module containing the after and before methods (and any other) or you could simply expose them at Glyph-level. At any rate, you'd have to run an instance_eval or class_eval when loading the files. The methods would be fairly simple:

 def after(command, &block)
    # Code to store block in Glyph::HOOKS[:project][command][:after]

...then, all you'd have to do is to call hooks from wherever you like inside each command, for example like this:

  # compile.rb

This is just a possible quick-and-dirty implementation. Obviously there are much better ways to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment