[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] Needle 0.6.0

Jamis Buck

10/21/2004 4:52:00 PM

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

Project Page/Downloads: http://rubyforge.org/proje...
User Manual (work in progress): http://needle.rub...
API Documentation: http://needle.rub.../api
Needle Wiki: http://needle.rub.../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@email.byu.edu).
Additionally, you might consider taking advantage of the following
resources:

Bug Reports:
http://rubyforge.org/tracker/?atid=1642&group_id=410&f...
Forums: http://rubyforge.org/forum/?gr...
Mailing List: http://rubyforge.org/mailman/listinfo/need...
Feature Requests:
http://rubyforge.org/tracker/?atid=1645&group_id=410&f...

------------------
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@email.byu.edu
http://www.jamisbuck...