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 CHANGED
@@ -1 +1 @@
1
- 0.4.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.4.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-03}
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.3.6}
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::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
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
@@ -39,6 +39,10 @@ end
39
39
  class ClassForProxyingAfterAnInstanceWasProxied
40
40
  end
41
41
 
42
+ class ClassWithClassMethods
43
+ def self.foo; 1; end
44
+ end
45
+
42
46
  class Category
43
47
  attr_accessor :categories
44
48
  attr_reader :name
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: false
5
- segments:
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
- - Jason Rogers
8
+ - Jason Rogers
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-02-03 00:00:00 -05:00
13
+ date: 2011-02-04 00:00:00 -05:00
18
14
  default_executable:
19
15
  dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: ruby-debug19
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- segments:
27
- - 0
28
- version: "0"
29
- requirement: *id001
30
- prerelease: false
31
- type: :development
32
- - !ruby/object:Gem::Dependency
33
- name: ruby-debug
34
- version_requirements: &id002 !ruby/object:Gem::Requirement
35
- requirements:
36
- - - ">="
37
- - !ruby/object:Gem::Version
38
- segments:
39
- - 0
40
- version: "0"
41
- requirement: *id002
42
- prerelease: false
43
- type: :development
44
- - !ruby/object:Gem::Dependency
45
- name: jruby-openssl
46
- version_requirements: &id003 !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- segments:
51
- - 0
52
- version: "0"
53
- requirement: *id003
54
- prerelease: false
55
- type: :development
56
- - !ruby/object:Gem::Dependency
57
- name: ruby-debug
58
- version_requirements: &id004 !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- segments:
63
- - 0
64
- version: "0"
65
- requirement: *id004
66
- prerelease: false
67
- type: :development
68
- - !ruby/object:Gem::Dependency
69
- name: rspec
70
- version_requirements: &id005 !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ~>
73
- - !ruby/object:Gem::Version
74
- segments:
75
- - 2
76
- - 4
77
- - 0
78
- version: 2.4.0
79
- requirement: *id005
80
- prerelease: false
81
- type: :development
82
- - !ruby/object:Gem::Dependency
83
- name: bundler
84
- version_requirements: &id006 !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ~>
87
- - !ruby/object:Gem::Version
88
- segments:
89
- - 1
90
- - 0
91
- - 0
92
- version: 1.0.0
93
- requirement: *id006
94
- prerelease: false
95
- type: :development
96
- - !ruby/object:Gem::Dependency
97
- name: jeweler
98
- version_requirements: &id007 !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ~>
101
- - !ruby/object:Gem::Version
102
- segments:
103
- - 1
104
- - 5
105
- - 2
106
- version: 1.5.2
107
- requirement: *id007
108
- prerelease: false
109
- type: :development
110
- - !ruby/object:Gem::Dependency
111
- name: rcov
112
- version_requirements: &id008 !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- segments:
117
- - 0
118
- version: "0"
119
- requirement: *id008
120
- prerelease: false
121
- type: :development
122
- - !ruby/object:Gem::Dependency
123
- name: rspec
124
- version_requirements: &id009 !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ~>
127
- - !ruby/object:Gem::Version
128
- segments:
129
- - 2
130
- - 4
131
- - 0
132
- version: 2.4.0
133
- requirement: *id009
134
- prerelease: false
135
- type: :development
136
- - !ruby/object:Gem::Dependency
137
- name: bundler
138
- version_requirements: &id010 !ruby/object:Gem::Requirement
139
- requirements:
140
- - - ~>
141
- - !ruby/object:Gem::Version
142
- segments:
143
- - 1
144
- - 0
145
- - 0
146
- version: 1.0.0
147
- requirement: *id010
148
- prerelease: false
149
- type: :development
150
- - !ruby/object:Gem::Dependency
151
- name: jeweler
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
- - LICENSE.txt
184
- - README.rdoc
155
+ - LICENSE.txt
156
+ - README.rdoc
185
157
  files:
186
- - Gemfile
187
- - Gemfile.lock
188
- - LICENSE.txt
189
- - README.rdoc
190
- - Rakefile
191
- - VERSION
192
- - examples/sinatra/app.rb
193
- - examples/sinatra/config.ru
194
- - examples/sinatra/public/app.css
195
- - examples/sinatra/public/app.js
196
- - examples/sinatra/public/favicon.ico
197
- - examples/sinatra/public/nested_directory/file_inside_nested_directory.txt
198
- - examples/sinatra/views/index.haml
199
- - examples/sinatra/views/layout.haml
200
- - lib/proxeze.rb
201
- - proxeze.gemspec
202
- - spec/definitions.rb
203
- - spec/proxeze_spec.rb
204
- - spec/spec_helper.rb
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
- - MIT
180
+ - MIT
209
181
  post_install_message:
210
182
  rdoc_options: []
211
183
 
212
184
  require_paths:
213
- - lib
185
+ - lib
214
186
  required_ruby_version: !ruby/object:Gem::Requirement
187
+ none: false
215
188
  requirements:
216
- - - ">="
217
- - !ruby/object:Gem::Version
218
- segments:
219
- - 0
220
- version: "0"
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
- - !ruby/object:Gem::Version
225
- segments:
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.3.6
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
- - examples/sinatra/app.rb
237
- - spec/definitions.rb
238
- - spec/proxeze_spec.rb
239
- - spec/spec_helper.rb
209
+ - examples/sinatra/app.rb
210
+ - spec/definitions.rb
211
+ - spec/proxeze_spec.rb
212
+ - spec/spec_helper.rb