spank 1.0.1420314444 → 1.0.1441140793

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc301cc64728fac2deb1c9254d30d48ace7a1f1e
4
- data.tar.gz: 47933865366f32ed7f64d848aa2d202c1a0a1691
3
+ metadata.gz: 0369a59e61b3981593ebdc684f5a78789658613c
4
+ data.tar.gz: 814798d03866fe5717f33b324bc3b90e98ecbcaf
5
5
  SHA512:
6
- metadata.gz: 2b83330fc11559793975f6edc5fb7618ec274cfabfdab5b099d37ac7487b970b2b3bf636648619c7e5c8bf65c58a652086a436c450d8395696714ddaa9343c5b
7
- data.tar.gz: d89544b1e0ac1019b0a2c36a50ae5b8ec1d7646ff108773c3a816d9de8596f95acb6db07a040f80b0dff3fde66ac9a261c874ca7385fe85c72436b0a5af350b4
6
+ metadata.gz: 38fbb6a1f2d18dd2a5dbe963ec1686ff6b2ce1ace6112cc7cbed92b8322ec290b6b1b0e312a0af921b4895e6cafab133262d3c92119e08626652bed95e0ab358
7
+ data.tar.gz: 27f9c7a8b40ae0900292ce6cce20d603b82e661a510d3cb591fe4eeadac5489ffd80becca4519a41346ef5d466d21224ffa1ef4aef70479589bee8ce182d7b43
data/.travis.yml CHANGED
@@ -2,6 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.2.0
5
+ - 2.2.3
6
+ - jruby-9.0.0.0
5
7
  sudo: false
6
8
  deploy:
7
9
  provider: rubygems
@@ -11,3 +13,7 @@ deploy:
11
13
  on:
12
14
  tags: true
13
15
  repo: mokhan/spank
16
+ addons:
17
+ code_climate:
18
+ repo_token:
19
+ secure: O2jjrW6zXvSggDBsdASZzc4QT2s2n94IobQn8zAka4X1ZrTu+G4Cgt8cRWMw3W5/qNApUjlfTEO29gNMHURzHMlt4RLiahGIrziReDjYeF3OLbrZbs8AksUiMyLgfMb1vr4VGBVrR7OjOVk0T5VwnDA26LzEYG9PscdGnxn24TI=
data/README.md CHANGED
@@ -4,6 +4,8 @@ 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
6
  [![Code Climate](https://codeclimate.com/github/mokhan/spank.png)](https://codeclimate.com/github/mokhan/spank)
7
+ [![Test Coverage](https://codeclimate.com/github/mokhan/spank/badges/coverage.svg)](https://codeclimate.com/github/mokhan/spank)
8
+ [![Gem Version](https://badge.fury.io/rb/spank.svg)](http://badge.fury.io/rb/spank)
7
9
 
8
10
  ## Installation
9
11
 
data/lib/spank/ioc.rb CHANGED
@@ -6,16 +6,27 @@ module Spank
6
6
  end
7
7
 
8
8
  def resolve(symbol)
9
- raise create_error unless class_variable_defined?(:@@container)
9
+ ensure_initialized!
10
10
  @@container.resolve(symbol)
11
11
  end
12
12
 
13
+ def resolve_all(symbol)
14
+ ensure_initialized!
15
+ @@container.resolve_all(symbol)
16
+ end
17
+
13
18
  def unbind
14
- remove_class_variable(:@@container) if class_variable_defined?(:@@container)
19
+ if class_variable_defined?(:@@container)
20
+ remove_class_variable(:@@container)
21
+ end
15
22
  end
16
23
 
17
24
  private
18
25
 
26
+ def ensure_initialized!
27
+ raise create_error unless class_variable_defined?(:@@container)
28
+ end
29
+
19
30
  def create_error
20
31
  ContainerError.new("Spank::IOC.bind_to(container) has not been called.")
21
32
  end
data/spank.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", '~> 10.4'
24
24
  spec.add_development_dependency "rspec", '~> 3.1'
25
25
  spec.add_development_dependency "simplecov", '~> 0.9'
26
+ spec.add_development_dependency "codeclimate-test-reporter"
26
27
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'simplecov'
2
- SimpleCov.start
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
3
  require 'spank'
4
4
 
5
5
  RSpec.configure do |config|
@@ -6,22 +6,37 @@ describe Spank::IOC do
6
6
  context "when bound to a container" do
7
7
  let(:container) { double }
8
8
  let(:component) { double }
9
+ let(:jeans) { double }
10
+ let(:dress_pants) { double }
9
11
 
10
12
  before :each do
11
13
  allow(container).to receive(:resolve).
12
14
  with(:dbconnection).
13
15
  and_return(component)
16
+ allow(container).to receive(:resolve_all).
17
+ with(:pants).
18
+ and_return([jeans, dress_pants])
14
19
  Spank::IOC.bind_to(container)
15
20
  end
16
21
 
17
22
  it "resolves the item from the container" do
18
23
  expect(Spank::IOC.resolve(:dbconnection)).to eq(component)
19
24
  end
25
+
26
+ it "resolves all items from the container" do
27
+ expect(Spank::IOC.resolve_all(:pants)).to match_array([
28
+ jeans,
29
+ dress_pants
30
+ ])
31
+ end
20
32
  end
21
33
 
22
34
  context "when nothing is bound" do
23
35
  it "raises a meaningful exception" do
24
36
  expect { Spank::IOC.resolve(:food) }.to raise_error(Spank::ContainerError)
37
+ expect do
38
+ Spank::IOC.resolve_all(:pants)
39
+ end.to raise_error(Spank::ContainerError)
25
40
  end
26
41
  end
27
42
  end
@@ -31,14 +31,14 @@ module Spank
31
31
  proxy.each do |x|
32
32
  raise StandardError
33
33
  end
34
- end.to raise_error
34
+ end.to raise_error(StandardError)
35
35
  end
36
36
  end
37
37
  end
38
38
 
39
39
  context "when invoking a method that is not defined on the target" do
40
40
  it "raises an error" do
41
- expect { Proxy.new("blah").goodbye }.to raise_error
41
+ expect { Proxy.new("blah").goodbye }.to raise_error(NoMethodError)
42
42
  end
43
43
  end
44
44
  end
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: 1.0.1420314444
4
+ version: 1.0.1441140793
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-03 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: A lightweight ruby inversion of control (IOC) container
70
84
  email:
71
85
  - mo@mokhan.ca
@@ -117,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  version: '0'
118
132
  requirements: []
119
133
  rubyforge_project:
120
- rubygems_version: 2.4.5
134
+ rubygems_version: 2.4.8
121
135
  signing_key:
122
136
  specification_version: 4
123
137
  summary: spank!