proxeze 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/proxeze.rb +19 -1
- data/proxeze.gemspec +4 -5
- data/spec/definitions.rb +4 -0
- data/spec/proxeze_spec.rb +6 -0
- metadata +175 -202
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/proxeze.rb
CHANGED
@@ -24,12 +24,20 @@ module Proxeze
|
|
24
24
|
# Typically, only the Proxeze.for method should pass in
|
25
25
|
# redefine_new_method=false here.
|
26
26
|
def self.proxy target_class, redefine_new_method = true
|
27
|
-
cls_name = target_class.name.gsub '::', ''
|
27
|
+
cls_name = target_class.name.gsub( '::', '' )
|
28
28
|
unless self.class_defined? cls_name
|
29
29
|
cls = DelegateClass target_class
|
30
30
|
cls.send :include, self
|
31
31
|
self.const_set cls_name, cls
|
32
32
|
end
|
33
|
+
|
34
|
+
cls = self.const_get cls_name
|
35
|
+
(target_class.methods - Object.methods - [:new, :public_api, :delegating_block]).each do |method|
|
36
|
+
blk = class_delegating_block(method, target_class)
|
37
|
+
(class << cls; self; end).instance_eval do
|
38
|
+
define_method(method, &blk)
|
39
|
+
end
|
40
|
+
end
|
33
41
|
|
34
42
|
# we have to collect the methods as Strings here because
|
35
43
|
# 1.9 changed the implementation to return Symbols instead of Strings
|
@@ -47,6 +55,16 @@ module Proxeze
|
|
47
55
|
self.const_get cls_name
|
48
56
|
end
|
49
57
|
|
58
|
+
def self.class_delegating_block mid, target
|
59
|
+
lambda do |*args, &block|
|
60
|
+
begin
|
61
|
+
target.__send__(mid, *args, &block)
|
62
|
+
ensure
|
63
|
+
$@.delete_if {|t| /\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:/o =~ t} if $@
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
50
68
|
# create a proxy object for the given object
|
51
69
|
def self.for object
|
52
70
|
self.proxy( object.class, false ).new( object )
|
data/proxeze.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{proxeze}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jason Rogers"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-04}
|
13
13
|
s.description = %q{A basic proxy/delegate framework for Ruby that will allow you to wrap any object with a proxy instance. For more information about the Proxy and Delegate patterns, check out http://en.wikipedia.org/wiki/Proxy_pattern and http://en.wikipedia.org/wiki/Delegation_pattern respectively.}
|
14
14
|
s.email = %q{jacaetevha@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.homepage = %q{http://github.com/jacaetevha/proxeze}
|
41
41
|
s.licenses = ["MIT"]
|
42
42
|
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.
|
43
|
+
s.rubygems_version = %q{1.5.0}
|
44
44
|
s.summary = %q{A basic proxy/delegate framework for Ruby that will allow you to wrap any object with a proxy instance.}
|
45
45
|
s.test_files = [
|
46
46
|
"examples/sinatra/app.rb",
|
@@ -50,10 +50,9 @@ Gem::Specification.new do |s|
|
|
50
50
|
]
|
51
51
|
|
52
52
|
if s.respond_to? :specification_version then
|
53
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
53
|
s.specification_version = 3
|
55
54
|
|
56
|
-
if Gem::Version.new(Gem::
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
56
|
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
58
57
|
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
59
58
|
s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
|
data/spec/definitions.rb
CHANGED
data/spec/proxeze_spec.rb
CHANGED
@@ -148,4 +148,10 @@ describe Proxeze do
|
|
148
148
|
proxy = Proxeze.for(1)
|
149
149
|
proxy.should be_kind_of(Proxeze::Fixnum)
|
150
150
|
end
|
151
|
+
|
152
|
+
it "should proxy class methods also" do
|
153
|
+
proxy_class = Proxeze.proxy ClassWithClassMethods
|
154
|
+
Proxeze::ClassWithClassMethods.should respond_to(:foo)
|
155
|
+
Proxeze::ClassWithClassMethods.foo.should == ClassWithClassMethods.foo
|
156
|
+
end
|
151
157
|
end
|
metadata
CHANGED
@@ -1,178 +1,150 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxeze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 4
|
8
|
-
- 0
|
9
|
-
version: 0.4.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.5.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
|
-
|
8
|
+
- Jason Rogers
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-04 00:00:00 -05:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
version_requirements: &id011 !ruby/object:Gem::Requirement
|
153
|
-
requirements:
|
154
|
-
- - ~>
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
segments:
|
157
|
-
- 1
|
158
|
-
- 5
|
159
|
-
- 2
|
160
|
-
version: 1.5.2
|
161
|
-
requirement: *id011
|
162
|
-
prerelease: false
|
163
|
-
type: :development
|
164
|
-
- !ruby/object:Gem::Dependency
|
165
|
-
name: rcov
|
166
|
-
version_requirements: &id012 !ruby/object:Gem::Requirement
|
167
|
-
requirements:
|
168
|
-
- - ">="
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
segments:
|
171
|
-
- 0
|
172
|
-
version: "0"
|
173
|
-
requirement: *id012
|
174
|
-
prerelease: false
|
175
|
-
type: :development
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: ruby-debug19
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-debug
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: jruby-openssl
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: ruby-debug
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.4.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: bundler
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.0.0
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: jeweler
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.5.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rcov
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
type: :development
|
102
|
+
prerelease: false
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rspec
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 2.4.0
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: bundler
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.0.0
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *id010
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: jeweler
|
128
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.5.2
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: *id011
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rcov
|
139
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: "0"
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: *id012
|
176
148
|
description: A basic proxy/delegate framework for Ruby that will allow you to wrap any object with a proxy instance. For more information about the Proxy and Delegate patterns, check out http://en.wikipedia.org/wiki/Proxy_pattern and http://en.wikipedia.org/wiki/Delegation_pattern respectively.
|
177
149
|
email: jacaetevha@gmail.com
|
178
150
|
executables: []
|
@@ -180,60 +152,61 @@ executables: []
|
|
180
152
|
extensions: []
|
181
153
|
|
182
154
|
extra_rdoc_files:
|
183
|
-
|
184
|
-
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.rdoc
|
185
157
|
files:
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
158
|
+
- Gemfile
|
159
|
+
- Gemfile.lock
|
160
|
+
- LICENSE.txt
|
161
|
+
- README.rdoc
|
162
|
+
- Rakefile
|
163
|
+
- VERSION
|
164
|
+
- examples/sinatra/app.rb
|
165
|
+
- examples/sinatra/config.ru
|
166
|
+
- examples/sinatra/public/app.css
|
167
|
+
- examples/sinatra/public/app.js
|
168
|
+
- examples/sinatra/public/favicon.ico
|
169
|
+
- examples/sinatra/public/nested_directory/file_inside_nested_directory.txt
|
170
|
+
- examples/sinatra/views/index.haml
|
171
|
+
- examples/sinatra/views/layout.haml
|
172
|
+
- lib/proxeze.rb
|
173
|
+
- proxeze.gemspec
|
174
|
+
- spec/definitions.rb
|
175
|
+
- spec/proxeze_spec.rb
|
176
|
+
- spec/spec_helper.rb
|
205
177
|
has_rdoc: true
|
206
178
|
homepage: http://github.com/jacaetevha/proxeze
|
207
179
|
licenses:
|
208
|
-
|
180
|
+
- MIT
|
209
181
|
post_install_message:
|
210
182
|
rdoc_options: []
|
211
183
|
|
212
184
|
require_paths:
|
213
|
-
|
185
|
+
- lib
|
214
186
|
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
215
188
|
requirements:
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
hash: -744132594254975345
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
version: "0"
|
221
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
222
197
|
requirements:
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
- 0
|
227
|
-
version: "0"
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: "0"
|
228
201
|
requirements: []
|
229
202
|
|
230
203
|
rubyforge_project:
|
231
|
-
rubygems_version: 1.
|
204
|
+
rubygems_version: 1.5.0
|
232
205
|
signing_key:
|
233
206
|
specification_version: 3
|
234
207
|
summary: A basic proxy/delegate framework for Ruby that will allow you to wrap any object with a proxy instance.
|
235
208
|
test_files:
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
209
|
+
- examples/sinatra/app.rb
|
210
|
+
- spec/definitions.rb
|
211
|
+
- spec/proxeze_spec.rb
|
212
|
+
- spec/spec_helper.rb
|