[Needle] [ANN] Needle 0.6.0

Jamis Buck jgb3 at email.byu.edu
Thu Oct 21 12:51:19 EDT 2004


Needle is a new dependency injection (a.k.a. "inversion of control") 
container for Ruby.

   Project Page/Downloads: http://rubyforge.org/projects/needle
   User Manual (work in progress): http://needle.rubyforge.org
   API Documentation: http://needle.rubyforge.org/api
   Needle Wiki: http://needle.rubyforge.org/wiki/wiki.pl

This release (0.6) is the second public release. It is, in general, NOT 
backwards compatible with software written against Needle 0.5 (you were, 
after all, warned that this might happen).

Needle is currently considered experimental software. You are encouraged 
to download it and try it out, but be warned that subsequent releases of 
Needle may change the API in non-backwards-compatible ways. This trend 
will continue until the release of Needle 1.0, at which point Needle 
will be considered "stable".

Please report any bugs. The bug tracker on the project page are a good 
place to do so, or you can just email me (jgb3 at email.byu.edu). 
Additionally, you might consider taking advantage of the following 
resources:

   Bug Reports: 
http://rubyforge.org/tracker/?atid=1642&group_id=410&func=browse
   Forums: http://rubyforge.org/forum/?group_id=410
   Mailing List: http://rubyforge.org/mailman/listinfo/needle-discuss
   Feature Requests: 
http://rubyforge.org/tracker/?atid=1645&group_id=410&func=browse

------------------
Changes in 0.6
------------------

   * Added benchmarks.

   * Removed Container#register!.

   * Added Container#define and Container#define!. Container#define! 
works just like Container#register! used to. Container#define is similar 
to #define!, but does not use instance_eval (thanks for the suggestion, 
Jim).

   * Service constructor blocks may accept two parameters: the 
container, and the service point itself.

   * Container#namespace (and friends) no longer acts like "mkdir -p".

   * Added QueryableMutex for detecting cycles in dependencies.

   * Changed implementation of service models to use instantiation 
pipelines.

   * Added many new service models (prototype_initialize, threaded, 
singleton_deferred_initialize, etc.)

   * Added Jim Weirich's "DI in Ruby" article to documentation.

------------------
Examples
------------------

Using #register:

   require 'needle'
   registry = Needle::Registry.new

   registry.register( :adder ) { Adder.new }
   registry.register( :calc ) do |r|
     calc = Calculator.new
     calc.adder = r.adder
     calc
   end

   calc = registry.calc
   p calc.add( 5, 6 )

Using #define!:

   registry.define! do
     adder { Adder.new }
     calc do
       c = Calculator.new
       c.adder = adder
       c
     end
   end

Using #define:

   registry.define do |b|
     b.adder { Adder.new }
     b.calc do
       c = Calculator.new
       c.adder = b.adder
       c
     end
   end

-- 
Jamis Buck
jgb3 at email.byu.edu
http://www.jamisbuck.org/jamis


More information about the Needle-discuss mailing list