Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Hooks #187

Open
h3rald opened this issue Nov 28, 2010 · 0 comments
Open

Command Hooks #187

h3rald opened this issue Nov 28, 2010 · 0 comments
Milestone

Comments

@h3rald
Copy link
Owner

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:

  :project:
      :compile:
          :before: # proc
          :after: # proc
      :init:
      :add:
      # ...
   :global:
      :compile:
      # ...

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]
 end

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

  # compile.rb
  Glyph::HOOKS[:project][:compile][:before].call(...parameters...)
  Glyph::HOOKS[:global][:compile][:before].call(...parameters...)

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
Projects
None yet
Development

No branches or pull requests

1 participant