/hookin

A Clojure hook management system

Primary LanguageClojure

HookIn

Pronounced 'Hú-kin\

Is a clojure hook management system, enabling the user to manually register or dynamically load and register clj and jar files and extract functions marked as hooked transformations and add them to a list of transformations, which can then be applied to data.

Usage

This section provides some short basic examples of how to use HookIn. For more examples and advanced features check out the prjects GitHub wiki pages.

Example 1 - Simple usage

(defn
  test-function
  [data]
  (+ data 10))

(register-transformation :add-10 test-function)

(apply-transformations :add-10 15)

Defines a function named "test-function", which are then registered in the hook management system under the hook :add-10. It is then applied to the number 15 for a result of 25.

Example 2 - Autoloading hooked functions

Code placed in a file called plugin.clj
(ns test.plugin
  (:require [hookin.core :as hookin]))

(hookin/hookfn test-function :add-10
               [data]
               (+ data 10))
In your project
(load-hooks-file "/path-to-file/plugin.clj")

(apply-transformations :add-10 15)

Defines a hooked function named "test-function" associated with the hook ":add-10" in a seperate clj file. The file is then loaded into the project and the function is registered in the hook management system under the hook :add-10. It is then applied to the number 15 for a result of 25.

Acknowledgements

This project is the new version of the Plugin Management System project, originally based on the ideas and initial work of Jacob Emcken

License

Copyright (C) 2013 Claus Engel-Christensen

Distributed under the Eclipse Public License, the same as Clojure.