poniard 1.0.0 → 1.0.1

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: b20dd7bc5a80523165730ffd2352ba33036988b2
4
- data.tar.gz: 9eb61c3e74958ace02b6865bb2d6ae0ed443b3a4
3
+ metadata.gz: 9a48046036fef997cfa02d4949ce2a26b1468e47
4
+ data.tar.gz: 6b452b4fb1adb6349c8523aab280e87a7a9ec4ed
5
5
  SHA512:
6
- metadata.gz: b5ec064ebc9ed82ca7b3dd47e1e321b062ef153f795513b86feb00d08b0f742cbae5f272dd2ddf4f2c01c2b0b62f62b57e735a8981f3f0eea43587c8eb700ec0
7
- data.tar.gz: bb8251380ad780db82f9a15171ba543787d78a25ee4c1368beffab81070d7ea4ff235333b99b74470d413cc34ebd926ee35299f8f43729b490cfe564a03086b6
6
+ metadata.gz: 81ce29dd7b8e9d5a3a91bad63000cab890fd4372bb2a0202c0ed95998e93def8585a499ee21bcfbd92370f805a91115043e22e0a9544c665403b6ba518af1ae9
7
+ data.tar.gz: 3a66f8a893495a00f746b0bdf66ae5f02e7c6203867210df41498568fc2b494682583b8afcaf3342a0632ad3a8032e2b7f40b3e9187a6d399c037a26489a097c
@@ -1,5 +1,9 @@
1
1
  # Poniard History
2
2
 
3
+ ## 1.0.1 - 4 May 2014
4
+
5
+ * 30% speedup in method dispatch.
6
+
3
7
  ## 1.0.0 - 20 April 2014
4
8
 
5
9
  * `respond_with` returns 406 for unknown formats.
data/README.md CHANGED
@@ -204,6 +204,11 @@ Developing
204
204
  Not widely used. May be some obvious things missing from built-in controller
205
205
  sources that you will have to add.
206
206
 
207
+ As far as I know Poniard has not been used on any high traffic applications, and
208
+ I wouldn't be surprised if there is a performance penalty for using it due to
209
+ the use of reflection. Please benchmark (and share!) before using in such an
210
+ environment.
211
+
207
212
  ### Compatibility
208
213
 
209
214
  Requires 1.9 or above.
@@ -45,8 +45,10 @@ module Poniard
45
45
  private
46
46
 
47
47
  def dispatch_method(method, unknown_param_f, overrides = {})
48
+ sources = sources_for(overrides)
49
+
48
50
  args = method.parameters.map {|_, name|
49
- source = sources_for(overrides).detect {|source|
51
+ source = sources.detect {|source|
50
52
  source.provides?(name)
51
53
  }
52
54
 
@@ -1,5 +1,5 @@
1
1
  # Top-level namespace for Poniard. See +README.md+ for library description.
2
2
  module Poniard
3
3
  # Current version of Poniard, in semantic versioning format.
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -23,5 +23,4 @@ Gem::Specification.new do |gem|
23
23
  gem.require_paths = ["lib"]
24
24
  gem.version = Poniard::VERSION
25
25
  gem.has_rdoc = false
26
- gem.add_development_dependency 'rspec', '~> 2.11'
27
26
  end
@@ -8,7 +8,7 @@ describe Poniard::Injector do
8
8
  it 'calls a lambda' do
9
9
  called = false
10
10
  described_class.new([]).dispatch -> { called = true }
11
- called.should == true
11
+ expect(called).to eq(true)
12
12
  end
13
13
 
14
14
  it 'calls a method' do
@@ -18,7 +18,9 @@ describe Poniard::Injector do
18
18
  end
19
19
  end.new
20
20
 
21
- described_class.new([]).dispatch(object.method(:a_number)).should == 12345
21
+ actual = described_class.new([]).dispatch(object.method(:a_number))
22
+
23
+ expect(actual).to eq(12345)
22
24
  end
23
25
 
24
26
  it 'calls a method with a parameter provided by a source' do
@@ -26,7 +28,7 @@ describe Poniard::Injector do
26
28
  described_class.new([
27
29
  thing: thing
28
30
  ]).dispatch ->(thing) { called = thing }
29
- called.should == thing
31
+ expect(called).to eq(thing)
30
32
  end
31
33
 
32
34
  it 'recursively injects sources' do
@@ -41,7 +43,7 @@ describe Poniard::Injector do
41
43
  {thing: thing},
42
44
  two_source
43
45
  ]).dispatch ->(two_things) { called = two_things }
44
- called.should == [thing, thing]
46
+ expect(called).to eq([thing, thing])
45
47
  end
46
48
 
47
49
  it 'uses the first source that provides a parameter' do
@@ -50,7 +52,7 @@ describe Poniard::Injector do
50
52
  {thing: thing},
51
53
  {thing: nil}
52
54
  ]).dispatch ->(thing) { called = thing }
53
- called.should == thing
55
+ expect(called).to eq(thing)
54
56
  end
55
57
 
56
58
  it 'allows sources to be overriden at dispatch' do
@@ -58,36 +60,36 @@ describe Poniard::Injector do
58
60
  described_class.new([
59
61
  {thing: nil}
60
62
  ]).dispatch ->(thing) { called = thing }, thing: thing
61
- called.should == thing
63
+ expect(called).to eq(thing)
62
64
  end
63
65
 
64
66
  it 'provides itself as a source' do
65
67
  called = false
66
68
  injector = described_class.new
67
69
  injector.dispatch ->(injector) { called = injector }
68
- called.should == injector
70
+ expect(called).to eq(injector)
69
71
  end
70
72
 
71
73
  it 'allows nil values in hash sources' do
72
74
  value = nil
73
75
  injector = described_class.new
74
76
  injector.dispatch ->(x) { value = x.nil? }, x: nil
75
- value.should == true
77
+ expect(value).to eq(true)
76
78
  end
77
79
 
78
80
  it 'yields a fail object when source is unknown' do
79
81
  called = false
80
82
  m = ->(unknown) {
81
- ->{
83
+ expect{
82
84
  unknown.bogus
83
- }.should raise_error(
85
+ }.to raise_error(
84
86
  Poniard::UnknownParam,
85
87
  "Tried to call method on an uninjected param: unknown"
86
88
  )
87
89
  called = true
88
90
  }
89
91
  described_class.new.dispatch(m)
90
- called.should be_true
92
+ expect(called).to eq(true)
91
93
  end
92
94
 
93
95
  describe '#eager_dispatch' do
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poniard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Shay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-20 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.11'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.11'
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: A dependency injector for Rails, allows you to write clean controllers.
28
14
  email:
29
15
  - contact@xaviershay.com
@@ -63,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
49
  version: '0'
64
50
  requirements: []
65
51
  rubyforge_project:
66
- rubygems_version: 2.2.0
52
+ rubygems_version: 2.2.2
67
53
  signing_key:
68
54
  specification_version: 4
69
55
  summary: A dependency injector for Rails, allows you to write clean controllers.