unextendable 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = Unextendable CHANGELOG
2
2
 
3
+ == Version 0.1.5 (July 1, 2011)
4
+
5
+ * Fixed bug: respond_to? did not return true for a non-overridden instance method after extending an unextendable module
6
+
3
7
  == Version 0.1.4 (May 4, 2011)
4
8
 
5
9
  * Made Unextendable Ruby 1.9.2 compatible, booya! (Module.instance_methods within Ruby 1.9.2 returns symbols opposed to Ruby 1.8.7 which returns strings)
data/README.textile CHANGED
@@ -20,7 +20,13 @@ A gem that extends Ruby's semantics by accessing its internals from pure Ruby co
20
20
 
21
21
  A gem that implements the Ruby state pattern. Ouch! I know what you are thinking: "Dude! Didn't you want to implement the state pattern?". Yes, but as I already mentioned I want to use modules and also, I want to implement it as unobtrusive as possible.
22
22
 
23
- So the gems can do the trick, but slightly did not fit the picture. After some further research on Ruby core classes, I got inspired by "Jay Fields' blog article":http://blog.jayfields.com/2007/08/ruby-calling-methods-of-specific.html and "Facets":https://github.com/rubyworks/facets and wrote *Unextendable*! ^^
23
+ So the gems can do the trick, but slightly did not fit the picture. After some further research on Ruby core classes, I got inspired by "Jay Fields' blog article":http://blog.jayfields.com/2007/08/ruby-calling-methods-of-specific.html and "Facets":https://github.com/rubyworks/facets and wrote this gem.
24
+
25
+ h3. Unextendable's advantages
26
+
27
+ * It does not require altering your Ruby installation
28
+ * It should work on every Ruby installation (the tests are running successfully using *Ruby 1.8.7* and *Ruby 1.9.2*)
29
+ * Implementing Unextendable is straightforward and unobtrusive
24
30
 
25
31
  h2. Installation
26
32
 
@@ -122,6 +128,8 @@ Please check out "https://github.com/archan937/unextendable/blob/master/test/obj
122
128
 
123
129
  Also, the Unextendable repo is provided with @script/console@ which you can run for testing purposes. The module and class definitions are already defined when starting up and the object instance <code>@c</code> of the class @C@ is also defined.
124
130
 
131
+ Note: *Unextendable is successfully tested using Ruby 1.8.7 and Ruby 1.9.2*
132
+
125
133
  h2. Contact me
126
134
 
127
135
  For support, remarks and requests please mail me at "paul.engel@holder.nl":mailto:paul.engel@holder.nl.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -47,7 +47,14 @@ private
47
47
 
48
48
  instance_eval <<-CODE
49
49
  def respond_to?(symbol, include_private = false)
50
- meta_class.extended_modules.detect{|x| x.instance_methods.collect(&:to_s).include? symbol.to_s} || meta_class.method_procs[symbol.to_s].class == Proc
50
+ meta_class.extended_modules.any?{|x| x.instance_methods.collect(&:to_s).include? symbol.to_s} ||
51
+ begin
52
+ if meta_class.method_procs.has_key? symbol.to_s
53
+ meta_class.method_procs[symbol.to_s].class == Proc
54
+ else
55
+ self.class.instance_methods.collect(&:to_s).include? symbol.to_s
56
+ end
57
+ end
51
58
  end
52
59
  CODE
53
60
 
@@ -1,7 +1,7 @@
1
1
  module Unextendable
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 4
4
+ TINY = 5
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -83,6 +83,12 @@ class ObjectInstanceTest < Test::Unit::TestCase
83
83
  end
84
84
  end
85
85
 
86
+ should "respond to a non-extended instance method after extending" do
87
+ assert @c.respond_to?(:salutation)
88
+ @c.extend U
89
+ assert @c.respond_to?(:salutation)
90
+ end
91
+
86
92
  should "call wrap_unextendable_module" do
87
93
  @c.expects(:wrap_unextendable_module)
88
94
  @c.extend A, U
@@ -195,6 +201,7 @@ class ObjectInstanceTest < Test::Unit::TestCase
195
201
  @c.title = "Sir"
196
202
  assert_equal "Sir U", @c.salutation
197
203
 
204
+ assert @c.respond_to?(:salutation)
198
205
  assert @c.respond_to?(:foo)
199
206
  assert_nothing_raised NoMethodError do
200
207
  @c.foo
@@ -206,6 +213,7 @@ class ObjectInstanceTest < Test::Unit::TestCase
206
213
  @c.title = ""
207
214
  assert_equal "C", @c.salutation
208
215
 
216
+ assert @c.respond_to?(:salutation)
209
217
  assert !@c.respond_to?(:foo)
210
218
  assert_raise NoMethodError do
211
219
  @c.foo
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: unextendable
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.4
5
+ version: 0.1.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Engel
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-04 00:00:00 +02:00
13
+ date: 2011-07-01 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency