needle 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/faq/faq.yml +396 -14
- data/doc/manual-html/chapter-1.html +33 -4
- data/doc/manual-html/chapter-2.html +44 -6
- data/doc/manual-html/chapter-3.html +34 -5
- data/doc/manual-html/chapter-4.html +33 -4
- data/doc/manual-html/chapter-5.html +208 -4
- data/doc/manual-html/chapter-6.html +226 -4
- data/doc/manual-html/chapter-7.html +165 -4
- data/doc/manual-html/chapter-8.html +138 -6
- data/doc/manual-html/index.html +36 -9
- data/doc/manual/manual.rb +1 -1
- data/doc/manual/manual.yml +17 -4
- data/doc/manual/page.erb +2 -1
- data/doc/manual/parts/02_namespaces.txt +11 -2
- data/doc/manual/parts/03_overview.txt +1 -1
- data/doc/manual/parts/interceptors_architecture.txt +5 -0
- data/doc/manual/parts/interceptors_attaching.txt +64 -0
- data/doc/manual/parts/interceptors_custom.txt +25 -0
- data/doc/manual/parts/interceptors_ordering.txt +13 -0
- data/doc/manual/parts/interceptors_overview.txt +5 -0
- data/doc/manual/parts/libraries_creating.txt +30 -0
- data/doc/manual/parts/libraries_overview.txt +3 -0
- data/doc/manual/parts/libraries_using.txt +31 -0
- data/doc/manual/parts/logging_configuration.txt +30 -0
- data/doc/manual/parts/logging_logfactory.txt +31 -0
- data/doc/manual/parts/logging_overview.txt +5 -0
- data/doc/manual/parts/models_models.txt +35 -0
- data/doc/manual/parts/models_overview.txt +3 -0
- data/doc/manual/parts/models_pipelines.txt +63 -0
- data/lib/needle/container.rb +52 -7
- data/lib/needle/lifecycle/initialize.rb +1 -1
- data/lib/needle/log-factory.rb +46 -8
- data/lib/needle/thread.rb +6 -0
- data/lib/needle/version.rb +2 -2
- data/test/pipeline/tc_collection.rb +1 -1
- data/test/pipeline/tc_element.rb +2 -2
- data/test/services.rb +21 -0
- data/test/tc_container.rb +18 -0
- data/test/tc_logger.rb +35 -1
- metadata +17 -2
data/lib/needle/thread.rb
CHANGED
@@ -23,6 +23,12 @@ module Needle
|
|
23
23
|
# cycles in the dependency graph of services.
|
24
24
|
class QueryableMutex < Mutex
|
25
25
|
|
26
|
+
# Create a new unlocked QueryableMutex.
|
27
|
+
def initialize
|
28
|
+
super
|
29
|
+
@locking_thread = nil
|
30
|
+
end
|
31
|
+
|
26
32
|
# Checks to see if the current thread has the mutex locked, and if it
|
27
33
|
# does, raises an exception. Otherwise, locks the mutex and sets the
|
28
34
|
# locking thread to Thread.current.
|
data/lib/needle/version.rb
CHANGED
data/test/pipeline/tc_element.rb
CHANGED
@@ -56,8 +56,8 @@ class TC_Pipeline_Element < Test::Unit::TestCase
|
|
56
56
|
element1 = Needle::Pipeline::Element.new( nil, :test1, 25 )
|
57
57
|
element2 = Needle::Pipeline::Element.new( nil, :test2, 75 )
|
58
58
|
|
59
|
-
assert_equal -1, element1 <=> element2
|
60
|
-
assert_equal 1, element2 <=> element1
|
59
|
+
assert_equal( -1, element1 <=> element2 )
|
60
|
+
assert_equal( 1, element2 <=> element1 )
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_comparable
|
data/test/services.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module A
|
2
|
+
module B
|
3
|
+
module C
|
4
|
+
|
5
|
+
def register_services( container )
|
6
|
+
container.namespace( :foo ) do |ns|
|
7
|
+
ns.register( :bar ) { "hello" }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
module_function :register_services
|
11
|
+
|
12
|
+
def register_other_services( container )
|
13
|
+
container.namespace( :blah ) do |ns|
|
14
|
+
ns.register( :baz ) { "hello" }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
module_function :register_other_services
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/test/tc_container.rb
CHANGED
@@ -311,4 +311,22 @@ class TC_Container < Test::Unit::TestCase
|
|
311
311
|
assert_same p1, p2
|
312
312
|
end
|
313
313
|
|
314
|
+
def test_require_default
|
315
|
+
container = Needle::Container.new
|
316
|
+
container.register( :service_models, :pipeline=>[] ) { Hash[ :singleton => [] ] }
|
317
|
+
container.require( "services", "A::B::C" )
|
318
|
+
|
319
|
+
assert_not_nil container[:foo]
|
320
|
+
assert_not_nil container[:foo][:bar]
|
321
|
+
end
|
322
|
+
|
323
|
+
def test_require_custom
|
324
|
+
container = Needle::Container.new
|
325
|
+
container.register( :service_models , :pipeline=>[] ) { Hash[ :singleton => [] ] }
|
326
|
+
container.require( "services", "A::B::C", :register_other_services )
|
327
|
+
|
328
|
+
assert_not_nil container[:blah]
|
329
|
+
assert_not_nil container[:blah][:baz]
|
330
|
+
end
|
331
|
+
|
314
332
|
end
|
data/test/tc_logger.rb
CHANGED
@@ -44,7 +44,7 @@ class TC_Logger < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
def teardown
|
46
46
|
logs = Dir[File.join(File.dirname(__FILE__),"*.log")]
|
47
|
-
File.delete *logs unless logs.empty?
|
47
|
+
File.delete( *logs ) unless logs.empty?
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_log_filename
|
@@ -73,6 +73,40 @@ class TC_Logger < Test::Unit::TestCase
|
|
73
73
|
factory.close
|
74
74
|
end
|
75
75
|
|
76
|
+
def test_log_bad_option
|
77
|
+
assert_raise( ArgumentError ) do
|
78
|
+
Needle::LogFactory.new :bogus => "hello"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_bad_log_level_option
|
83
|
+
assert_raise( ArgumentError ) do
|
84
|
+
Needle::LogFactory.new :levels => { "test.*" => { :bogus => 5 } }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_log_config_via_yaml
|
89
|
+
require 'yaml'
|
90
|
+
config = YAML.load( <<-EOF )
|
91
|
+
---
|
92
|
+
filename: ./somewhere.log
|
93
|
+
roll-age: 5
|
94
|
+
roll-size: 10241024
|
95
|
+
default-date-format: "%Y-%m-%d %H:%M:%S"
|
96
|
+
default-message-format: "[%d] %C - %m"
|
97
|
+
default-level: WARN
|
98
|
+
levels:
|
99
|
+
test.*: INFO
|
100
|
+
verbose.*:
|
101
|
+
level: WARN
|
102
|
+
date-format: "%Y-%m-%d"
|
103
|
+
message-format: "%C - %m"
|
104
|
+
EOF
|
105
|
+
assert_nothing_raised do
|
106
|
+
Needle::LogFactory.new config
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
76
110
|
def test_log_get
|
77
111
|
factory = Needle::LogFactory.new
|
78
112
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.1
|
|
3
3
|
specification_version: 1
|
4
4
|
name: needle
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2004-
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2004-11-04
|
8
8
|
summary: Needle is a Dependency Injection/Inversion of Control container for Ruby. It supports both type-2 (setter) and type-3 (constructor) injection. It takes advantage of the dynamic nature of Ruby to provide a rich and flexible approach to injecting dependencies.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -60,20 +60,34 @@ files:
|
|
60
60
|
- doc/manual/page.erb
|
61
61
|
- doc/manual/index.erb
|
62
62
|
- doc/manual/manual.rb
|
63
|
+
- doc/manual/parts/logging_logfactory.txt
|
64
|
+
- doc/manual/parts/models_pipelines.txt
|
63
65
|
- doc/manual/parts/02_namespaces.txt
|
66
|
+
- doc/manual/parts/models_overview.txt
|
64
67
|
- doc/manual/parts/01_support.txt
|
65
68
|
- doc/manual/parts/03_locator.txt
|
66
69
|
- doc/manual/parts/02_services.txt
|
67
70
|
- doc/manual/parts/04_setup.txt
|
68
71
|
- doc/manual/parts/01_alternatives.txt
|
69
72
|
- doc/manual/parts/04_overview.txt
|
73
|
+
- doc/manual/parts/models_models.txt
|
74
|
+
- doc/manual/parts/logging_overview.txt
|
75
|
+
- doc/manual/parts/interceptors_architecture.txt
|
76
|
+
- doc/manual/parts/interceptors_attaching.txt
|
70
77
|
- doc/manual/parts/01_what_is_needle.txt
|
71
78
|
- doc/manual/parts/03_overview.txt
|
72
79
|
- doc/manual/parts/02_creating.txt
|
80
|
+
- doc/manual/parts/libraries_using.txt
|
73
81
|
- doc/manual/parts/01_license.txt
|
74
82
|
- doc/manual/parts/01_use_cases.txt
|
83
|
+
- doc/manual/parts/libraries_creating.txt
|
75
84
|
- doc/manual/parts/02_overview.txt
|
76
85
|
- doc/manual/parts/03_conventional.txt
|
86
|
+
- doc/manual/parts/logging_configuration.txt
|
87
|
+
- doc/manual/parts/interceptors_custom.txt
|
88
|
+
- doc/manual/parts/libraries_overview.txt
|
89
|
+
- doc/manual/parts/interceptors_overview.txt
|
90
|
+
- doc/manual/parts/interceptors_ordering.txt
|
77
91
|
- lib/needle.rb
|
78
92
|
- lib/needle
|
79
93
|
- lib/needle/interceptor.rb
|
@@ -106,6 +120,7 @@ files:
|
|
106
120
|
- test/lifecycle
|
107
121
|
- test/models
|
108
122
|
- test/tc_interceptor_chain.rb
|
123
|
+
- test/services.rb
|
109
124
|
- test/tc_logger.rb
|
110
125
|
- test/tc_container.rb
|
111
126
|
- test/pipeline/tc_element.rb
|