dependor 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dependor (0.0.3)
4
+ dependor (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -7,7 +7,9 @@ module Dependor
7
7
  autoload :CustomizedInjector, 'dependor/customized_injector'
8
8
  autoload :Injectable, 'dependor/injectable'
9
9
  autoload :Instantiator, 'dependor/instantiator'
10
+ autoload :Isolate, 'dependor/isolate'
10
11
  autoload :Let, 'dependor/let'
12
+ autoload :SendingInjector, 'dependor/sending_injector'
11
13
  autoload :Shorty, 'dependor/shorty'
12
14
  autoload :UnknownObject, 'dependor/exceptions'
13
15
  autoload :VERSION, 'dependor/version'
@@ -0,0 +1,7 @@
1
+ module Dependor::Isolate
2
+ def isolate(klass)
3
+ injector = Dependor::SendingInjector.new(self)
4
+ instantiator = Dependor::Instantiator.new(injector)
5
+ instantiator.instantiate(klass)
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Dependor::Isolate
3
+ end
@@ -0,0 +1,9 @@
1
+ class Dependor::SendingInjector
2
+ def initialize(context)
3
+ @context = context
4
+ end
5
+
6
+ def get(name)
7
+ @context.__send__(name)
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Dependor
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dependor::Isolate do
4
+ class ExampleSubject
5
+ takes :foo, :bar
6
+ end
7
+
8
+ class ExampleContext
9
+ include Dependor::Isolate
10
+
11
+ def subject
12
+ isolate(ExampleSubject)
13
+ end
14
+
15
+ def foo
16
+ "the foo stub"
17
+ end
18
+
19
+ def bar
20
+ "the bar stub"
21
+ end
22
+ end
23
+
24
+ it "injects the subject's dependencies using methods on context" do
25
+ context = ExampleContext.new
26
+
27
+ context.subject.foo.should == "the foo stub"
28
+ context.subject.bar.should == "the bar stub"
29
+ end
30
+ end
@@ -4,6 +4,7 @@ require 'rubygems'
4
4
  require 'rspec'
5
5
 
6
6
  require 'dependor'
7
+ require 'dependor/shorty'
7
8
 
8
9
  RSpec.configure do |c|
9
10
  c.color_enabled = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-06-18 00:00:00.000000000 Z
12
+ date: 2012-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -135,7 +135,10 @@ files:
135
135
  - lib/dependor/exceptions.rb
136
136
  - lib/dependor/injectable.rb
137
137
  - lib/dependor/instantiator.rb
138
+ - lib/dependor/isolate.rb
138
139
  - lib/dependor/let.rb
140
+ - lib/dependor/rspec.rb
141
+ - lib/dependor/sending_injector.rb
139
142
  - lib/dependor/shorty.rb
140
143
  - lib/dependor/version.rb
141
144
  - pelusa.sh
@@ -145,6 +148,7 @@ files:
145
148
  - spec/dependor/customized_injector_spec.rb
146
149
  - spec/dependor/injectable_spec.rb
147
150
  - spec/dependor/instantiator_spec.rb
151
+ - spec/dependor/isolate_spec.rb
148
152
  - spec/dependor/let_spec.rb
149
153
  - spec/dependor/shorty_spec.rb
150
154
  - spec/spec_helper.rb
@@ -162,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
166
  version: '0'
163
167
  segments:
164
168
  - 0
165
- hash: -216139779
169
+ hash: -869165773
166
170
  required_rubygems_version: !ruby/object:Gem::Requirement
167
171
  none: false
168
172
  requirements:
@@ -171,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
175
  version: '0'
172
176
  segments:
173
177
  - 0
174
- hash: -216139779
178
+ hash: -869165773
175
179
  requirements: []
176
180
  rubyforge_project: dependor
177
181
  rubygems_version: 1.8.24