rkh-chainable 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- metadata +90 -3
- data/LICENSE +0 -27
- data/README.rdoc +0 -92
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rkh-chainable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -29,8 +29,95 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
-
-
|
33
|
-
-
|
32
|
+
- tmp/rkh/chainable/lib/chainable.rb
|
33
|
+
- tmp/rkh/chainable/spec/chainable/chain_method_spec.rb
|
34
|
+
- tmp/rkh/chainable/spec/chainable/auto_chain_spec.rb
|
35
|
+
- tmp/rkh/chainable/benchmark/chainable.rb
|
36
|
+
- rack/lib/rack/cascade.rb
|
37
|
+
- rack/lib/rack/auth/digest/nonce.rb
|
38
|
+
- rack/lib/rack/auth/digest/md5.rb
|
39
|
+
- rack/lib/rack/auth/digest/request.rb
|
40
|
+
- rack/lib/rack/auth/digest/params.rb
|
41
|
+
- rack/lib/rack/auth/abstract/handler.rb
|
42
|
+
- rack/lib/rack/auth/abstract/request.rb
|
43
|
+
- rack/lib/rack/auth/openid.rb
|
44
|
+
- rack/lib/rack/auth/basic.rb
|
45
|
+
- rack/lib/rack/recursive.rb
|
46
|
+
- rack/lib/rack/response.rb
|
47
|
+
- rack/lib/rack/reloader.rb
|
48
|
+
- rack/lib/rack/urlmap.rb
|
49
|
+
- rack/lib/rack/commonlogger.rb
|
50
|
+
- rack/lib/rack/session/cookie.rb
|
51
|
+
- rack/lib/rack/session/abstract/id.rb
|
52
|
+
- rack/lib/rack/session/pool.rb
|
53
|
+
- rack/lib/rack/session/memcache.rb
|
54
|
+
- rack/lib/rack/lint.rb
|
55
|
+
- rack/lib/rack/showstatus.rb
|
56
|
+
- rack/lib/rack/showexceptions.rb
|
57
|
+
- rack/lib/rack/file.rb
|
58
|
+
- rack/lib/rack/mock.rb
|
59
|
+
- rack/lib/rack/builder.rb
|
60
|
+
- rack/lib/rack/lobster.rb
|
61
|
+
- rack/lib/rack/handler/mongrel.rb
|
62
|
+
- rack/lib/rack/handler/scgi.rb
|
63
|
+
- rack/lib/rack/handler/fastcgi.rb
|
64
|
+
- rack/lib/rack/handler/webrick.rb
|
65
|
+
- rack/lib/rack/handler/lsws.rb
|
66
|
+
- rack/lib/rack/handler/cgi.rb
|
67
|
+
- rack/lib/rack/adapter/camping.rb
|
68
|
+
- rack/lib/rack/request.rb
|
69
|
+
- rack/lib/rack/static.rb
|
70
|
+
- rack/lib/rack/utils.rb
|
71
|
+
- rack/lib/rack.rb
|
72
|
+
- rack/test/spec_rack_session_pool.rb
|
73
|
+
- rack/test/spec_rack_mongrel.rb
|
74
|
+
- rack/test/spec_rack_utils.rb
|
75
|
+
- rack/test/spec_rack_urlmap.rb
|
76
|
+
- rack/test/spec_rack_fastcgi.rb
|
77
|
+
- rack/test/spec_rack_showexceptions.rb
|
78
|
+
- rack/test/spec_rack_lint.rb
|
79
|
+
- rack/test/spec_rack_camping.rb
|
80
|
+
- rack/test/spec_rack_recursive.rb
|
81
|
+
- rack/test/spec_rack_webrick.rb
|
82
|
+
- rack/test/spec_rack_auth_digest.rb
|
83
|
+
- rack/test/spec_rack_file.rb
|
84
|
+
- rack/test/spec_rack_builder.rb
|
85
|
+
- rack/test/spec_rack_session_memcache.rb
|
86
|
+
- rack/test/spec_rack_mock.rb
|
87
|
+
- rack/test/spec_rack_lobster.rb
|
88
|
+
- rack/test/spec_rack_request.rb
|
89
|
+
- rack/test/spec_rack_auth_basic.rb
|
90
|
+
- rack/test/testrequest.rb
|
91
|
+
- rack/test/spec_rack_cgi.rb
|
92
|
+
- rack/test/spec_rack_showstatus.rb
|
93
|
+
- rack/test/spec_rack_session_cookie.rb
|
94
|
+
- rack/test/spec_rack_response.rb
|
95
|
+
- rack/test/spec_rack_static.rb
|
96
|
+
- rack/test/spec_rack_cascade.rb
|
97
|
+
- rack/test/spec_rack_commonlogger.rb
|
98
|
+
- rack/example/protectedlobster.rb
|
99
|
+
- sinatra/lib/sinatra/test/methods.rb
|
100
|
+
- sinatra/lib/sinatra/test/spec.rb
|
101
|
+
- sinatra/lib/sinatra/test/unit.rb
|
102
|
+
- sinatra/lib/sinatra.rb
|
103
|
+
- sinatra/test/use_in_file_templates_test.rb
|
104
|
+
- sinatra/test/app_test.rb
|
105
|
+
- sinatra/test/rest_test.rb
|
106
|
+
- sinatra/test/custom_error_test.rb
|
107
|
+
- sinatra/test/sym_params_test.rb
|
108
|
+
- sinatra/test/diddy_test.rb
|
109
|
+
- sinatra/test/template_test.rb
|
110
|
+
- sinatra/test/haml_test.rb
|
111
|
+
- sinatra/test/streaming_test.rb
|
112
|
+
- sinatra/test/erb_test.rb
|
113
|
+
- sinatra/test/event_context_test.rb
|
114
|
+
- sinatra/test/builder_test.rb
|
115
|
+
- sinatra/test/sass_test.rb
|
116
|
+
- sinatra/test/events_test.rb
|
117
|
+
- sinatra/test/mapped_error_test.rb
|
118
|
+
- sinatra/test/helper.rb
|
119
|
+
- sinatra/test/sessions_test.rb
|
120
|
+
- sinatra/test/application_test.rb
|
34
121
|
files:
|
35
122
|
- tmp/rkh/chainable/lib/chainable.rb
|
36
123
|
- tmp/rkh/chainable/spec/chainable/chain_method_spec.rb
|
data/LICENSE
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
copyright (c) 2009 Konstantin Haase. All rights reserved.
|
2
|
-
|
3
|
-
Developed by: Konstantin Haase
|
4
|
-
http://github.com/rkh/chainable
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
of this software and associated documentation files (the "Software"), to
|
8
|
-
deal with the Software without restriction, including without limitation the
|
9
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
11
|
-
furnished to do so, subject to the following conditions:
|
12
|
-
1. Redistributions of source code must retain the above copyright notice,
|
13
|
-
this list of conditions and the following disclaimers.
|
14
|
-
2. Redistributions in binary form must reproduce the above copyright
|
15
|
-
notice, this list of conditions and the following disclaimers in the
|
16
|
-
documentation and/or other materials provided with the distribution.
|
17
|
-
3. Neither the name of Konstantin Haase, nor the names of other contributors
|
18
|
-
may be used to endorse or promote products derived from this Software without
|
19
|
-
specific prior written permission.
|
20
|
-
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
-
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
26
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
27
|
-
WITH THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
<b>A word of warning:</b>
|
2
|
-
|
3
|
-
This is heavy ruby abuse. It even got the Evil of the Day Award™ from zenspider.
|
4
|
-
|
5
|
-
== Thou shalt not use alias_method_chain!
|
6
|
-
- http://yehudakatz.com/2009/03/06/alias_method_chain-in-models
|
7
|
-
- http://yehudakatz.com/2009/01/18/other-ways-to-wrap-a-method
|
8
|
-
- http://www.codefluency.com/articles/2009/01/03/wrapping-a-method-in-ruby
|
9
|
-
|
10
|
-
== What it does
|
11
|
-
Chainable is an alternative to alias_method_chain, that uses inheritance, rather
|
12
|
-
than aliasing. It does the following when "chaining" a method:
|
13
|
-
|
14
|
-
- copy the original method to a new model
|
15
|
-
- include the model
|
16
|
-
- overwrite the method
|
17
|
-
|
18
|
-
Thus you can use super and keep your method list clean, too!
|
19
|
-
It even supports a (rather dangerous) auto chaining mode, so you do not have
|
20
|
-
to explicitly chain a method, but chain a method whenever it would be
|
21
|
-
overwritten instead.
|
22
|
-
|
23
|
-
|
24
|
-
Example:
|
25
|
-
|
26
|
-
class Foo
|
27
|
-
|
28
|
-
def foo
|
29
|
-
10
|
30
|
-
end
|
31
|
-
|
32
|
-
# now chain to foo
|
33
|
-
chain_method :foo do
|
34
|
-
super + 3
|
35
|
-
end
|
36
|
-
|
37
|
-
# or turn on auto chaining
|
38
|
-
auto_chain do
|
39
|
-
|
40
|
-
def bar
|
41
|
-
10
|
42
|
-
end
|
43
|
-
|
44
|
-
def bar
|
45
|
-
super + 1
|
46
|
-
end
|
47
|
-
|
48
|
-
def bar
|
49
|
-
super ** 2
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
# or chain multiple methods at once
|
55
|
-
chain_method :foo, :bar do
|
56
|
-
super.to_s
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
f = Foo.new
|
62
|
-
puts f.foo # => 13
|
63
|
-
puts f.bar # => 121
|
64
|
-
|
65
|
-
Of course you can do this with any class (or module):
|
66
|
-
|
67
|
-
Array.class_eval do
|
68
|
-
chain_method :each
|
69
|
-
def each
|
70
|
-
return super if block_given? or RUBY_VERSION >= "1.8.7"
|
71
|
-
MyStuff::Enumerator.new self, :each
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
Note that there is a speed advantage when using chain_method without a block
|
76
|
-
and doing a "def", since chain_method will use define_method if a block is
|
77
|
-
given, which produces slower methods (but makes the method a real closure).
|
78
|
-
|
79
|
-
== Benchmark
|
80
|
-
chain_method tends do produce slightly faster methods than alias_method_chain:
|
81
|
-
user system total real
|
82
|
-
chainable (define_method) 0.160000 0.010000 0.170000 ( 0.183363)
|
83
|
-
chainable (def & eval) 0.170000 0.010000 0.180000 ( 0.177084)
|
84
|
-
alias_method_chain (define_method) 0.570000 0.030000 0.600000 ( 0.607330)
|
85
|
-
alias_method_chain (def & eval) 0.170000 0.020000 0.190000 ( 0.190048)
|
86
|
-
|
87
|
-
== Installation
|
88
|
-
Add github gems, if you haven't already:
|
89
|
-
gem sources -a http://gems.github.com
|
90
|
-
|
91
|
-
Install gem:
|
92
|
-
gem install rkh-chainable
|