conject 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/conject.gemspec +1 -1
- data/lib/conject.rb +16 -0
- data/lib/conject/class_ext_object_context.rb +5 -0
- data/lib/conject/class_ext_provide_with_objects.rb +14 -0
- data/lib/conject/object_context.rb +7 -0
- data/lib/conject/object_ext_object_context.rb +5 -0
- data/lib/conject/object_factory.rb +1 -25
- data/lib/conject/version.rb +1 -1
- data/spec/acceptance/dev/provide_with_objects_spec.rb +36 -0
- data/spec/acceptance/regression/inherited_dependencies_spec.rb +6 -6
- data/spec/acceptance/regression/inject_object_context_spec.rb +90 -16
- data/spec/acceptance/{dev → regression}/module_scoping_spec.rb +0 -0
- data/spec/conject/object_context_spec.rb +31 -2
- data/spec/test_data/basic_composition/and_justice_for_all.rb +5 -1
- data/spec/test_data/basic_composition/kill_em_all.rb +2 -0
- data/spec/test_data/lazy_resolution/hobbit/baggins.rb +9 -0
- data/spec/test_data/lazy_resolution/hobbit/precious.rb +8 -0
- data/spec/test_data/lazy_resolution/hobbit/shire.rb +8 -0
- data/spec/test_data/lazy_resolution/hobbit/smeagol.rb +11 -0
- metadata +21 -10
- data/.gitignore +0 -7
- data/.rvmrc +0 -2
- data/NOTES.txt +0 -61
- data/TODO +0 -28
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
Conject v0.1.0
|
2
|
+
* All objects now have a public accessor object_context
|
3
|
+
* provide_with_objects can be used like construct_with, except it sets up lazy use-time resolution of dependencies
|
4
|
+
* ObjectContext#put now raises if you accidentally re-register an object with the same name
|
5
|
+
|
6
|
+
Conject v0.0.9
|
7
|
+
* Classes with module namespaces can now refer to collaborators in construct_with by omitting the full path corresponding to the object namespace
|
8
|
+
|
9
|
+
Conject v0.0.8
|
10
|
+
* peer_objects lets you declare within one object that if some subcontext should request an object, that object should be instantiated in THIS context
|
11
|
+
|
1
12
|
Conject v0.0.7
|
2
13
|
(re-release due to release automation fail on my part)
|
3
14
|
Conject v0.0.6
|
data/conject.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.homepage = "https://github.com/dcrosby42/conject"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
-
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.files = `git ls-files`.split("\n") - [".gitignore", ".rspec", ".rvmrc", "NOTES.txt", "TODO"]
|
13
13
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
14
|
gem.name = "conject"
|
15
15
|
gem.require_paths = ["lib"]
|
data/lib/conject.rb
CHANGED
@@ -2,8 +2,11 @@ require "conject/version"
|
|
2
2
|
|
3
3
|
require 'conject/object_definition'
|
4
4
|
require 'conject/extended_metaid'
|
5
|
+
require 'conject/class_ext_object_context'
|
6
|
+
require 'conject/object_ext_object_context'
|
5
7
|
require 'conject/class_ext_construct_with'
|
6
8
|
require 'conject/class_ext_object_peers'
|
9
|
+
require 'conject/class_ext_provide_with_objects'
|
7
10
|
require 'conject/object_context'
|
8
11
|
require 'conject/object_factory'
|
9
12
|
require 'conject/class_finder'
|
@@ -37,4 +40,17 @@ module Conject
|
|
37
40
|
:object_factory => object_factory
|
38
41
|
)
|
39
42
|
end
|
43
|
+
|
44
|
+
def self.install_object_context(target, context)
|
45
|
+
target.instance_variable_set(:@_conject_object_context, context)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.override_object_context_with(object_context, &block)
|
49
|
+
Thread.current[:_overriding_conject_object_context] = object_context
|
50
|
+
begin
|
51
|
+
block.call
|
52
|
+
ensure
|
53
|
+
Thread.current[:_overriding_conject_object_context] = nil
|
54
|
+
end
|
55
|
+
end
|
40
56
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'conject/utilities'
|
2
|
+
class Class
|
3
|
+
def provide_with_objects(*syms)
|
4
|
+
klass = self
|
5
|
+
|
6
|
+
# Define an internal reader method per dependency:
|
7
|
+
syms.each do |object_name|
|
8
|
+
mname = Conject::Utilities.generate_accessor_method_name(object_name)
|
9
|
+
class_def_private mname do
|
10
|
+
object_context[object_name]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -10,6 +10,8 @@ module Conject
|
|
10
10
|
|
11
11
|
# Inject a named object into this context
|
12
12
|
def put(name, object)
|
13
|
+
raise "This ObjectContext already has an instance or configuration for '#{name.to_s}'" if directly_has?(name)
|
14
|
+
Conject.install_object_context(object, self)
|
13
15
|
@cache[name.to_sym] = object
|
14
16
|
end
|
15
17
|
|
@@ -81,6 +83,11 @@ module Conject
|
|
81
83
|
@object_configs[name.to_sym] || {}
|
82
84
|
end
|
83
85
|
|
86
|
+
def inspect
|
87
|
+
"<ObjectContext 0x#{object_id.to_s(16)}>"
|
88
|
+
end
|
89
|
+
alias :to_s :inspect
|
90
|
+
|
84
91
|
private
|
85
92
|
|
86
93
|
#
|
@@ -18,14 +18,6 @@ module Conject
|
|
18
18
|
else
|
19
19
|
raise "Constructor lambda takes 0, 1 or 2 params; this lambda takes #{lambda_constructor.arity}"
|
20
20
|
end
|
21
|
-
|
22
|
-
# Provide a private accessor to the assigned object context
|
23
|
-
class << object
|
24
|
-
private
|
25
|
-
def object_context
|
26
|
-
@_conject_object_context #|| Conject.default_object_context
|
27
|
-
end
|
28
|
-
end
|
29
21
|
else
|
30
22
|
object = type_1_constructor(name, object_context)
|
31
23
|
end
|
@@ -50,11 +42,6 @@ module Conject
|
|
50
42
|
anchor_object_peers object_context, klass.object_peers
|
51
43
|
end
|
52
44
|
|
53
|
-
# Provide a private accessor to the assigned object context
|
54
|
-
klass.class_def_private :object_context do
|
55
|
-
@_conject_object_context || Thread.current[:current_object_context] #|| Conject.default_object_context
|
56
|
-
end
|
57
|
-
|
58
45
|
constructor_func = nil
|
59
46
|
if klass.has_object_definition?
|
60
47
|
object_map = dependency_resolver.resolve_for_class(klass, object_context)
|
@@ -63,26 +50,15 @@ module Conject
|
|
63
50
|
elsif Utilities.has_zero_arg_constructor?(klass)
|
64
51
|
# Default construction
|
65
52
|
constructor_func = lambda do klass.new end
|
66
|
-
Thread.current[:current_object_context] = object_context
|
67
|
-
begin
|
68
|
-
ensure
|
69
|
-
Thread.current[:current_object_context] = nil
|
70
|
-
end
|
71
53
|
else
|
72
54
|
# Oops, out of ideas on how to build.
|
73
55
|
raise ArgumentError.new("Class #{klass} has no special component needs, but neither does it have a zero-argument constructor.");
|
74
56
|
end
|
75
57
|
|
76
58
|
object = nil
|
77
|
-
|
78
|
-
begin
|
59
|
+
Conject.override_object_context_with object_context do
|
79
60
|
object = constructor_func.call
|
80
|
-
ensure
|
81
|
-
Thread.current[:current_object_context] = nil
|
82
61
|
end
|
83
|
-
|
84
|
-
return object
|
85
|
-
|
86
62
|
end
|
87
63
|
|
88
64
|
def anchor_object_peers(object_context, object_peers)
|
data/lib/conject/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe "lazy dependency resolution via provide_with_objects" do
|
4
|
+
subject { new_object_context }
|
5
|
+
|
6
|
+
before do
|
7
|
+
append_test_load_path "lazy_resolution"
|
8
|
+
require 'hobbit/baggins'
|
9
|
+
require 'hobbit/shire'
|
10
|
+
require 'hobbit/precious'
|
11
|
+
require 'hobbit/smeagol'
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
restore_load_path
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "for 'regular' context objects (instances)" do
|
19
|
+
it "provides objects" do
|
20
|
+
baggins = subject["hobbit/baggins"]
|
21
|
+
baggins.to_s.should == "From the Shire, found the One Ring"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can use deps inside #initialize" do
|
25
|
+
gollum = subject["hobbit/smeagol"]
|
26
|
+
gollum.saying.should == "They stole it from us, precious One Ring"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "mixed lazy and construct with"
|
31
|
+
describe "provide SELF with objects"
|
32
|
+
describe "objects injected into context after construction"
|
33
|
+
describe "module-relative dep names"
|
34
|
+
|
35
|
+
end
|
36
|
+
|
@@ -81,7 +81,7 @@ describe "basic inheritance" do
|
|
81
81
|
it "invokes subclass custom #initialize with component map" do
|
82
82
|
fur = subject[:fur]
|
83
83
|
tree = subject[:tree]
|
84
|
-
chauncy.got_map.should == { fur
|
84
|
+
chauncy.got_map.should == { :fur => fur, :tree => tree }
|
85
85
|
end
|
86
86
|
|
87
87
|
it "invokes superclass #initialize" do
|
@@ -150,7 +150,7 @@ describe "basic inheritance" do
|
|
150
150
|
class Shell; end
|
151
151
|
|
152
152
|
it "invokes super #initialize with component map" do
|
153
|
-
subject[:reptile].super_map.should == { scales
|
153
|
+
subject[:reptile].super_map.should == { :scales => subject[:scales] }
|
154
154
|
end
|
155
155
|
|
156
156
|
context "subclass has default #initialize" do
|
@@ -159,7 +159,7 @@ describe "basic inheritance" do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
it "invokes superclass #initialize" do
|
162
|
-
subject[:reptile].super_map.should == { scales
|
162
|
+
subject[:reptile].super_map.should == { :scales => subject[:scales] }
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -178,13 +178,13 @@ describe "basic inheritance" do
|
|
178
178
|
it "invokes subclass custom #initialize with component map" do
|
179
179
|
scales = subject[:scales]
|
180
180
|
rock = subject[:rock]
|
181
|
-
harry.got_map.should == { scales
|
181
|
+
harry.got_map.should == { :scales => scales, :rock => rock }
|
182
182
|
end
|
183
183
|
|
184
184
|
it "invokes superclass #initialize with component_map" do
|
185
185
|
scales = subject[:scales]
|
186
186
|
rock = subject[:rock]
|
187
|
-
harry.super_map.should == { scales
|
187
|
+
harry.super_map.should == { :scales => scales, :rock => rock }
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -239,7 +239,7 @@ describe "basic inheritance" do
|
|
239
239
|
|
240
240
|
it "does not invoke superclass #initiailize" do
|
241
241
|
subject[:croc].super_map.should be_nil
|
242
|
-
subject[:croc].my_map.should == { scales
|
242
|
+
subject[:croc].my_map.should == { :scales => subject[:scales] }
|
243
243
|
end
|
244
244
|
|
245
245
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "object_context:" do
|
4
4
|
subject { new_object_context }
|
5
5
|
|
6
6
|
before do
|
7
7
|
append_test_load_path "basic_composition"
|
8
|
-
require '
|
8
|
+
require 'kill_em_all'
|
9
9
|
require 'ride_the_lightning'
|
10
|
+
require 'master_of_puppets'
|
10
11
|
require 'and_justice_for_all'
|
11
12
|
end
|
12
13
|
|
@@ -14,47 +15,120 @@ describe "object referencing its own context" do
|
|
14
15
|
restore_load_path
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
subject[:this_object_context].should == subject
|
19
|
-
end
|
18
|
+
describe "NEW AND IMPROVED" do
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
describe "Class" do
|
21
|
+
it "has the default object context" do
|
22
|
+
Class.object_context.should == Conject.default_object_context
|
23
|
+
end
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
describe "Object" do
|
27
|
+
it "has the default object context at the class level" do
|
28
|
+
Object.object_context.should == Conject.default_object_context
|
29
|
+
end
|
30
|
+
it "has the default object context at the instance level" do
|
31
|
+
Object.new.object_context.should == Conject.default_object_context
|
32
|
+
"whatever".object_context.should == Conject.default_object_context
|
33
|
+
42.object_context.should == Conject.default_object_context
|
34
|
+
end
|
35
|
+
end
|
27
36
|
|
28
|
-
|
37
|
+
describe "any ol' instance" do
|
38
|
+
class FadeToBlack
|
39
|
+
end
|
29
40
|
|
30
|
-
|
41
|
+
let(:context1) { new_object_context }
|
42
|
+
let(:context2) { new_object_context }
|
43
|
+
let(:fade1) { FadeToBlack.new }
|
44
|
+
let(:fade2) { FadeToBlack.new }
|
45
|
+
|
46
|
+
it "can have object_context specified" do
|
47
|
+
Conject.install_object_context fade1, context1
|
48
|
+
fade1.object_context.should == context1
|
49
|
+
fade2.object_context.should == Conject.default_object_context
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can have the default object context overridden by Thread-local settings" do
|
53
|
+
fade1.object_context.should == Conject.default_object_context
|
54
|
+
|
55
|
+
Conject.override_object_context_with(context2) do
|
56
|
+
fade1.object_context.should == context2
|
57
|
+
end
|
58
|
+
|
59
|
+
fade1.object_context.should == Conject.default_object_context
|
60
|
+
end
|
61
|
+
|
62
|
+
it "will prefer its installed object context to the magic override" do
|
63
|
+
Conject.install_object_context fade1, context1
|
64
|
+
fade1.object_context.should == context1
|
65
|
+
|
66
|
+
Conject.override_object_context_with(context2) do
|
67
|
+
fade1.object_context.should == context1 # shouldn't change
|
68
|
+
end
|
69
|
+
|
70
|
+
fade1.object_context.should == context1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "classes using construct_with" do
|
31
75
|
let(:justice) { subject.get('and_justice_for_all') }
|
32
76
|
let(:ride) { subject.get('ride_the_lightning') }
|
33
77
|
|
34
78
|
it "automatically get a private accessor for object_context, even if not requested" do
|
35
|
-
justice.
|
36
|
-
ride.
|
79
|
+
justice.object_context.should == subject
|
80
|
+
ride.object_context.should == subject # watching out for interaction bugs wrt dependency construction
|
37
81
|
end
|
38
82
|
|
39
83
|
it "can use object_context in initialize" do
|
40
84
|
justice.init_time_object_context.should == subject
|
41
85
|
ride.init_time_object_context.should == subject # watching out for interaction bugs wrt dependency construction
|
42
86
|
end
|
87
|
+
|
88
|
+
it "will get object_context assigned as a result of being set into a context" do
|
89
|
+
obj = AndJusticeForAll.new(ride_the_lightning: 'doesnt matter')
|
90
|
+
obj.object_context.should == Conject.default_object_context
|
91
|
+
|
92
|
+
c2 = new_object_context
|
93
|
+
c2[:my_obj] = obj
|
94
|
+
obj.object_context.should == c2
|
95
|
+
end
|
43
96
|
end
|
44
97
|
|
45
|
-
describe "classes
|
98
|
+
describe "classes NOT using construct_with" do
|
46
99
|
let(:ride) { subject.get('ride_the_lightning') }
|
47
100
|
|
48
101
|
it "automatically get a private accessor for object_context, even if not requested" do
|
49
|
-
ride.
|
102
|
+
ride.object_context.should == subject
|
50
103
|
end
|
51
104
|
|
52
105
|
it "can use object_context in initialize" do
|
53
106
|
ride.init_time_object_context.should == subject
|
54
107
|
end
|
108
|
+
|
109
|
+
it "will get object_context assigned as a result of being set into a context" do
|
110
|
+
obj = KillEmAll.new
|
111
|
+
obj.object_context.should == Conject.default_object_context
|
112
|
+
|
113
|
+
c2 = new_object_context
|
114
|
+
c2[:my_obj] = obj
|
115
|
+
obj.object_context.should == c2
|
116
|
+
end
|
55
117
|
end
|
56
118
|
|
57
119
|
end
|
58
120
|
|
121
|
+
describe "OLD SCHOOL :this_object_context" do
|
122
|
+
it "ObjectContext caches a reference to itself using the name :this_object_context" do
|
123
|
+
subject[:this_object_context].should == subject
|
124
|
+
end
|
125
|
+
|
126
|
+
it "an object can inject :this_object_context as a reference to its constructing ObjectContext" do
|
127
|
+
master = subject.get('master_of_puppets')
|
128
|
+
master.this_object_context.should == subject
|
129
|
+
|
130
|
+
master.this_object_context.get('master_of_puppets').should == master
|
131
|
+
end
|
132
|
+
end
|
59
133
|
end
|
60
134
|
|
File without changes
|
@@ -87,6 +87,18 @@ describe Conject::ObjectContext do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
describe "#put?" do
|
91
|
+
it "raises an error if the context already has an object with the given name" do
|
92
|
+
subject[:jack] = :sparrow
|
93
|
+
lambda do subject[:jack] = :and_jill end.should raise_error /jack/
|
94
|
+
end
|
95
|
+
|
96
|
+
it "raises an error if the context has a config for the given name, even if no object has been instantiated or registered yet" do
|
97
|
+
subject.configure_objects davie: { cache: false }
|
98
|
+
lambda do subject[:davie] = :jones end.should raise_error /davie/
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
90
102
|
describe "#has?" do
|
91
103
|
describe "when the object exists in the cache" do
|
92
104
|
describe "due to #put" do
|
@@ -152,8 +164,16 @@ describe Conject::ObjectContext do
|
|
152
164
|
end
|
153
165
|
|
154
166
|
describe "when the object does NOT exist in the cache" do
|
155
|
-
|
156
|
-
|
167
|
+
describe "and there's no config for the object" do
|
168
|
+
it "returns false" do
|
169
|
+
subject.directly_has?(:a_clue).should == false
|
170
|
+
end
|
171
|
+
end
|
172
|
+
describe "and there IS a config for the object" do
|
173
|
+
it "returns true" do
|
174
|
+
subject.configure_objects :a_clue => { :cache => false }
|
175
|
+
subject.directly_has?(:a_clue).should == true
|
176
|
+
end
|
157
177
|
end
|
158
178
|
end
|
159
179
|
end
|
@@ -211,4 +231,13 @@ describe Conject::ObjectContext do
|
|
211
231
|
# end
|
212
232
|
|
213
233
|
end
|
234
|
+
|
235
|
+
describe "#inspect and #to_s" do
|
236
|
+
it "shows a custom string based on object_id" do
|
237
|
+
c = subject
|
238
|
+
obj_id_hex = c.object_id.to_s(16)
|
239
|
+
c.inspect.should == "<ObjectContext 0x#{obj_id_hex}>"
|
240
|
+
c.to_s.should == "<ObjectContext 0x#{obj_id_hex}>"
|
241
|
+
end
|
242
|
+
end
|
214
243
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -82,26 +82,25 @@ executables: []
|
|
82
82
|
extensions: []
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
|
-
- .gitignore
|
86
|
-
- .rvmrc
|
87
85
|
- CHANGELOG
|
88
86
|
- Gemfile
|
89
|
-
- NOTES.txt
|
90
87
|
- README.md
|
91
88
|
- Rakefile
|
92
|
-
- TODO
|
93
89
|
- conject.gemspec
|
94
90
|
- doc/inheritance_woes.txt
|
95
91
|
- lib/conject.rb
|
96
92
|
- lib/conject/borrowed_active_support_inflector.rb
|
97
93
|
- lib/conject/class_ext_construct_with.rb
|
94
|
+
- lib/conject/class_ext_object_context.rb
|
98
95
|
- lib/conject/class_ext_object_peers.rb
|
96
|
+
- lib/conject/class_ext_provide_with_objects.rb
|
99
97
|
- lib/conject/class_finder.rb
|
100
98
|
- lib/conject/composition_error.rb
|
101
99
|
- lib/conject/dependency_resolver.rb
|
102
100
|
- lib/conject/extended_metaid.rb
|
103
101
|
- lib/conject/object_context.rb
|
104
102
|
- lib/conject/object_definition.rb
|
103
|
+
- lib/conject/object_ext_object_context.rb
|
105
104
|
- lib/conject/object_factory.rb
|
106
105
|
- lib/conject/utilities.rb
|
107
106
|
- lib/conject/version.rb
|
@@ -118,7 +117,7 @@ files:
|
|
118
117
|
- scratch/sample.rb
|
119
118
|
- scratch/special_construct.rb
|
120
119
|
- spec/acceptance/dev/README
|
121
|
-
- spec/acceptance/dev/
|
120
|
+
- spec/acceptance/dev/provide_with_objects_spec.rb
|
122
121
|
- spec/acceptance/regression/README
|
123
122
|
- spec/acceptance/regression/basic_composition_spec.rb
|
124
123
|
- spec/acceptance/regression/basic_object_creation_spec.rb
|
@@ -126,6 +125,7 @@ files:
|
|
126
125
|
- spec/acceptance/regression/default_object_context_spec.rb
|
127
126
|
- spec/acceptance/regression/inherited_dependencies_spec.rb
|
128
127
|
- spec/acceptance/regression/inject_object_context_spec.rb
|
128
|
+
- spec/acceptance/regression/module_scoping_spec.rb
|
129
129
|
- spec/acceptance/regression/nested_contexts_spec.rb
|
130
130
|
- spec/acceptance/regression/non_singleton_spec.rb
|
131
131
|
- spec/acceptance/regression/object_peers_spec.rb
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- spec/test_data/basic_composition/front_desk.rb
|
149
149
|
- spec/test_data/basic_composition/grass.rb
|
150
150
|
- spec/test_data/basic_composition/guest.rb
|
151
|
+
- spec/test_data/basic_composition/kill_em_all.rb
|
151
152
|
- spec/test_data/basic_composition/lobby.rb
|
152
153
|
- spec/test_data/basic_composition/master_of_puppets.rb
|
153
154
|
- spec/test_data/basic_composition/nails.rb
|
@@ -162,6 +163,10 @@ files:
|
|
162
163
|
- spec/test_data/inheritance/malibu.rb
|
163
164
|
- spec/test_data/inheritance/vehicle.rb
|
164
165
|
- spec/test_data/inheritance/wheel.rb
|
166
|
+
- spec/test_data/lazy_resolution/hobbit/baggins.rb
|
167
|
+
- spec/test_data/lazy_resolution/hobbit/precious.rb
|
168
|
+
- spec/test_data/lazy_resolution/hobbit/shire.rb
|
169
|
+
- spec/test_data/lazy_resolution/hobbit/smeagol.rb
|
165
170
|
- spec/test_data/namespace/chart/model.rb
|
166
171
|
- spec/test_data/namespace/chart/presenter.rb
|
167
172
|
- spec/test_data/namespace/chart/view.rb
|
@@ -192,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
197
|
version: '0'
|
193
198
|
segments:
|
194
199
|
- 0
|
195
|
-
hash: -
|
200
|
+
hash: -4433957660980631745
|
196
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
202
|
none: false
|
198
203
|
requirements:
|
@@ -201,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
206
|
version: '0'
|
202
207
|
segments:
|
203
208
|
- 0
|
204
|
-
hash: -
|
209
|
+
hash: -4433957660980631745
|
205
210
|
requirements: []
|
206
211
|
rubyforge_project:
|
207
212
|
rubygems_version: 1.8.24
|
@@ -210,7 +215,7 @@ specification_version: 3
|
|
210
215
|
summary: Enable Guice-like dependency injection and contextual object interactions.
|
211
216
|
test_files:
|
212
217
|
- spec/acceptance/dev/README
|
213
|
-
- spec/acceptance/dev/
|
218
|
+
- spec/acceptance/dev/provide_with_objects_spec.rb
|
214
219
|
- spec/acceptance/regression/README
|
215
220
|
- spec/acceptance/regression/basic_composition_spec.rb
|
216
221
|
- spec/acceptance/regression/basic_object_creation_spec.rb
|
@@ -218,6 +223,7 @@ test_files:
|
|
218
223
|
- spec/acceptance/regression/default_object_context_spec.rb
|
219
224
|
- spec/acceptance/regression/inherited_dependencies_spec.rb
|
220
225
|
- spec/acceptance/regression/inject_object_context_spec.rb
|
226
|
+
- spec/acceptance/regression/module_scoping_spec.rb
|
221
227
|
- spec/acceptance/regression/nested_contexts_spec.rb
|
222
228
|
- spec/acceptance/regression/non_singleton_spec.rb
|
223
229
|
- spec/acceptance/regression/object_peers_spec.rb
|
@@ -240,6 +246,7 @@ test_files:
|
|
240
246
|
- spec/test_data/basic_composition/front_desk.rb
|
241
247
|
- spec/test_data/basic_composition/grass.rb
|
242
248
|
- spec/test_data/basic_composition/guest.rb
|
249
|
+
- spec/test_data/basic_composition/kill_em_all.rb
|
243
250
|
- spec/test_data/basic_composition/lobby.rb
|
244
251
|
- spec/test_data/basic_composition/master_of_puppets.rb
|
245
252
|
- spec/test_data/basic_composition/nails.rb
|
@@ -254,6 +261,10 @@ test_files:
|
|
254
261
|
- spec/test_data/inheritance/malibu.rb
|
255
262
|
- spec/test_data/inheritance/vehicle.rb
|
256
263
|
- spec/test_data/inheritance/wheel.rb
|
264
|
+
- spec/test_data/lazy_resolution/hobbit/baggins.rb
|
265
|
+
- spec/test_data/lazy_resolution/hobbit/precious.rb
|
266
|
+
- spec/test_data/lazy_resolution/hobbit/shire.rb
|
267
|
+
- spec/test_data/lazy_resolution/hobbit/smeagol.rb
|
257
268
|
- spec/test_data/namespace/chart/model.rb
|
258
269
|
- spec/test_data/namespace/chart/presenter.rb
|
259
270
|
- spec/test_data/namespace/chart/view.rb
|
data/.gitignore
DELETED
data/.rvmrc
DELETED
data/NOTES.txt
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
|
2
|
-
# Jan 2012
|
3
|
-
|
4
|
-
# Requesting an object from a Context
|
5
|
-
# if object exists in current context
|
6
|
-
# return it
|
7
|
-
# else
|
8
|
-
# if a super context has the object
|
9
|
-
# use the object from the super context
|
10
|
-
# else
|
11
|
-
# create the object
|
12
|
-
# store in this Context as a singleton
|
13
|
-
# return the object
|
14
|
-
#
|
15
|
-
# Special case: an object being created within a subcontext requires a
|
16
|
-
# component that SHOULD be defined in the supercontext
|
17
|
-
# BUT has not yet been created.
|
18
|
-
#
|
19
|
-
# Support a request-time option :from_super => [ :obj1, :obj2]
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# Special case: an object being created within a subcontext requires a
|
23
|
-
# component that SHOULD be defined in that SAME subcontext,
|
24
|
-
# but whose name overlaps with an object already defined in
|
25
|
-
# the SUPER context.
|
26
|
-
#
|
27
|
-
# Suppoer a request-time option :define_own => [ :obj1, :obj2]
|
28
|
-
# (:hide_in_super ? name debatable)
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
|
33
|
-
# Dec 2011
|
34
|
-
|
35
|
-
# Term: REGULAR OBJECT
|
36
|
-
# Instance of some class with 0 or more components
|
37
|
-
|
38
|
-
#
|
39
|
-
# Object definitions
|
40
|
-
# Manually add to context by name
|
41
|
-
# Indirectly added to context by meta programming in concerned class
|
42
|
-
# Generated defaults
|
43
|
-
#
|
44
|
-
# If no def exists
|
45
|
-
# if require_on_demand is true
|
46
|
-
# require guessed library name
|
47
|
-
# if def still not exist
|
48
|
-
# generate default def
|
49
|
-
#
|
50
|
-
# Use def to construct object
|
51
|
-
#
|
52
|
-
# ? when a class uses meta programming to define aspects of itself
|
53
|
-
# we are not yet in a context for certain.
|
54
|
-
# We could assume global context but that isn't always right.
|
55
|
-
#
|
56
|
-
# REAL QUESTION:
|
57
|
-
# How do we define non-global contexts conveniently?
|
58
|
-
# :w
|
59
|
-
#
|
60
|
-
|
61
|
-
|
data/TODO
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
ISSUE 2012-04-25: construct_with cyclic dependency checking! Eg. Presenter construc_with :presenter -> stack overlow
|
2
|
-
ISSUE 2012-04-30: prevent #put for already-existant objects
|
3
|
-
ISSUE 2012-04-30: prevent #configure_object(s) for already-existant objects
|
4
|
-
|
5
|
-
Features:
|
6
|
-
customer construction lambda via configure_objects
|
7
|
-
|
8
|
-
Class singletons:
|
9
|
-
use_class_in_context
|
10
|
-
class_depends_on
|
11
|
-
|
12
|
-
context.configure( :use_class_singletons => true)
|
13
|
-
|
14
|
-
ObjectContext#no_cache? <- reimplement for recursive upward search of object configs
|
15
|
-
|
16
|
-
contexts can accept configurations targeted at named subcontext
|
17
|
-
|
18
|
-
Support classes namespaced to modules
|
19
|
-
|
20
|
-
Conject.new_object_context (support no-args, default parent context to nil)
|
21
|
-
|
22
|
-
|
23
|
-
Tasks:
|
24
|
-
GET GOING IN TRAVIS CI
|
25
|
-
|
26
|
-
Cleanup meta programming in .construct_with it's NASTY
|
27
|
-
|
28
|
-
|