spank 0.0.1369197619 → 0.0.1385937112
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +1 -0
- data/lib/spank/interceptor_chain.rb +8 -0
- data/lib/spank/ioc.rb +1 -0
- data/lib/spank/proxy.rb +1 -3
- data/spank.gemspec +0 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/container_spec.rb +5 -5
- data/spec/unit/ioc_spec.rb +2 -2
- data/spec/unit/proxy_spec.rb +4 -3
- metadata +3 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e5f65fe9fa7c155adee5d30355d7ca5c69eb632
|
4
|
+
data.tar.gz: 8d5bb20f797d908b152354e2bb3c034db027050a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63edc02dcbf896d4a999e3eda1652d4302e06f987984fec2085f84cd7d2a343e309b611bc053ffc1f543fb6ad851d028ad4565e618dcadb56a015627b2f0e78f
|
7
|
+
data.tar.gz: 2a1a0a780824fb18b98462617105e7cc997ab053bfd895db9f5fe3318e23fb834078fea8e522956a066dc6216c65d23e36c827182c2b48acce74db7726d65733
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.0.0-
|
1
|
+
ruby-2.0.0-p353
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
A simple light weight inversion of control container written in ruby.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/mokhan/spank.png)](https://travis-ci.org/mokhan/spank)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/mokhan/spank.png)](https://codeclimate.com/github/mokhan/spank)
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
module Spank
|
1
2
|
class InterceptorChain
|
2
3
|
def initialize(interceptors = [])
|
3
4
|
@interceptors = interceptors
|
@@ -10,4 +11,11 @@
|
|
10
11
|
def each(&block)
|
11
12
|
@interceptors.each(&block)
|
12
13
|
end
|
14
|
+
|
15
|
+
def intercept(invocation)
|
16
|
+
each do |interceptor|
|
17
|
+
interceptor.intercept(invocation)
|
18
|
+
end
|
19
|
+
end
|
13
20
|
end
|
21
|
+
end
|
data/lib/spank/ioc.rb
CHANGED
data/lib/spank/proxy.rb
CHANGED
@@ -29,9 +29,7 @@ module Spank
|
|
29
29
|
Module.new do
|
30
30
|
define_method(method.to_sym) do |*args, &block|
|
31
31
|
invocation = create_invocation_for(method, args, block)
|
32
|
-
@interceptor_chain.
|
33
|
-
interceptor.intercept(invocation)
|
34
|
-
end
|
32
|
+
@interceptor_chain.intercept(invocation)
|
35
33
|
invocation.result
|
36
34
|
end
|
37
35
|
end
|
data/spank.gemspec
CHANGED
@@ -22,6 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "rspec-fakes"
|
26
25
|
spec.add_development_dependency "simplecov"
|
27
26
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/container_spec.rb
CHANGED
@@ -27,8 +27,8 @@ module Spank
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "when multiple items are registered with the same key" do
|
30
|
-
let(:jeans) {
|
31
|
-
let(:dress_pants) {
|
30
|
+
let(:jeans) { double("jeans") }
|
31
|
+
let(:dress_pants) { double("dress pants") }
|
32
32
|
|
33
33
|
before :each do
|
34
34
|
sut.register(:pants) { jeans }
|
@@ -60,7 +60,7 @@ module Spank
|
|
60
60
|
|
61
61
|
context "when a component is registered as a singleton" do
|
62
62
|
before :each do
|
63
|
-
sut.register(:singleton) {
|
63
|
+
sut.register(:singleton) { Object.new }.as_singleton
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should return the same instance of that component each time it is resolved" do
|
@@ -88,8 +88,8 @@ module Spank
|
|
88
88
|
end
|
89
89
|
|
90
90
|
context "when the dependencies have been registered" do
|
91
|
-
let(:mom) {
|
92
|
-
let(:dad) {
|
91
|
+
let(:mom) { double("mom") }
|
92
|
+
let(:dad) { double("dad") }
|
93
93
|
|
94
94
|
before :each do
|
95
95
|
sut.register(:mom) { mom }
|
data/spec/unit/ioc_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Spank::IOC do
|
4
4
|
context "when bound to a container" do
|
5
|
-
let(:container) {
|
6
|
-
let(:component) {
|
5
|
+
let(:container) { double }
|
6
|
+
let(:component) { double }
|
7
7
|
|
8
8
|
before :each do
|
9
9
|
container.stub(:resolve).with(:idbconnection).and_return(component)
|
data/spec/unit/proxy_spec.rb
CHANGED
@@ -3,19 +3,19 @@ require "spec_helper"
|
|
3
3
|
module Spank
|
4
4
|
describe Proxy do
|
5
5
|
let(:sut) { Proxy.new(target) }
|
6
|
-
let(:target) {
|
6
|
+
let(:target) { double("target", :greet => nil) }
|
7
7
|
|
8
8
|
context "when invoking a method" do
|
9
9
|
before { sut.greet('blah') }
|
10
10
|
|
11
11
|
it "should send the message to the target" do
|
12
|
-
target.should have_received(:greet
|
12
|
+
target.should have_received(:greet).with('blah')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
context "when an interceptor is registered" do
|
17
17
|
context "when invoking a method" do
|
18
|
-
let(:interceptor) {
|
18
|
+
let(:interceptor) { double('interceptor', :intercept => "") }
|
19
19
|
|
20
20
|
before :each do
|
21
21
|
sut.add_interceptor(:greet, interceptor)
|
@@ -25,6 +25,7 @@ module Spank
|
|
25
25
|
interceptor.should have_received(:intercept)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
28
29
|
context "when invoking a method with a block" do
|
29
30
|
it "should pass the block to the target" do
|
30
31
|
proxy = Proxy.new([])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1385937112
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-fakes
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: simplecov
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +78,6 @@ files:
|
|
92
78
|
- .ruby-version
|
93
79
|
- .travis.yml
|
94
80
|
- Gemfile
|
95
|
-
- Gemfile.lock
|
96
81
|
- LICENSE.txt
|
97
82
|
- README.md
|
98
83
|
- Rakefile
|
@@ -131,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
116
|
version: '0'
|
132
117
|
requirements: []
|
133
118
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.1.11
|
135
120
|
signing_key:
|
136
121
|
specification_version: 4
|
137
122
|
summary: spank!
|