unextendable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG.rdoc +5 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +133 -0
- data/Rakefile +10 -0
- data/VERSION +1 -0
- data/lib/unextendable/module.rb +11 -0
- data/lib/unextendable/object.rb +79 -0
- data/lib/unextendable/version.rb +3 -0
- data/lib/unextendable.rb +3 -0
- data/script/console +2 -0
- data/script/definitions.rb +25 -0
- data/test/module_test.rb +41 -0
- data/test/object_instance_test.rb +217 -0
- data/test/test_helper.rb +7 -0
- data/unextendable.gemspec +24 -0
- metadata +113 -0
data/.gitignore
ADDED
data/CHANGELOG.rdoc
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Paul Engel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
h1. Unextendable
|
2
|
+
|
3
|
+
A small gem making unextending extended module methods within object instances possible
|
4
|
+
|
5
|
+
h2. Introduction
|
6
|
+
|
7
|
+
Unextendable originated from the thought of being able to implement the "State pattern":http://tobyho.com/Design_Patterns_Revisited%3A_State within object instances using modules. In other words: I wanted object instances to behave dependent on their state using modules. I really want to use modules because they are commonly used to define a set of methods which you can extend within an object instance.
|
8
|
+
|
9
|
+
But unfortunately, you cannot just unexclude a module. So after searching the web for solutions, I came across the following:
|
10
|
+
|
11
|
+
*Mixology* - "Github repository":https://github.com/dan-manges/mixology
|
12
|
+
|
13
|
+
A gem that allows objects to effectively mixin and unmix modules. The downside is that it's only implemented for MRI 1.8.x, 1.9.x and JRuby 1.1.x.
|
14
|
+
|
15
|
+
*Evil-ruby* - "Github repository":https://github.com/yugui/evil-ruby
|
16
|
+
|
17
|
+
A gem that extends Ruby's semantics by accessing its internals from pure Ruby code. I do not want to mess with Ruby internals too much just for what I want to implement. As the name already, is it ethical or just evil? I will let you judge that. By the way, "evilr":https://github.com/jeremyevans/evilr is its brother written in C.
|
18
|
+
|
19
|
+
*StatePattern* - "Github repository":https://github.com/dcadenas/state_pattern
|
20
|
+
|
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
|
+
|
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*! ^^
|
24
|
+
|
25
|
+
h2. Installation
|
26
|
+
|
27
|
+
h3. Using Unextendable in Rails 3
|
28
|
+
|
29
|
+
Add Unextendable in @Gemfile@ as a gem dependency:
|
30
|
+
|
31
|
+
<pre>
|
32
|
+
gem "unextendable"
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
Run the following in your console to install with Bundler:
|
36
|
+
|
37
|
+
<pre>
|
38
|
+
bundle install
|
39
|
+
</pre>
|
40
|
+
|
41
|
+
h3. Using Unextendable in Rails 2
|
42
|
+
|
43
|
+
Add Unextendable in @environment.rb@ as a gem dependency:
|
44
|
+
|
45
|
+
<pre>
|
46
|
+
config.gem "unextendable"
|
47
|
+
</pre>
|
48
|
+
|
49
|
+
Run the following in your console:
|
50
|
+
|
51
|
+
<pre>
|
52
|
+
sudo rake gems:install
|
53
|
+
</pre>
|
54
|
+
|
55
|
+
h2. Example
|
56
|
+
|
57
|
+
Using Unextendable is pretty straightforward: just extend and unextend modules. A few module and class definitions:
|
58
|
+
|
59
|
+
<pre>
|
60
|
+
require "rubygems"
|
61
|
+
require "unextendable"
|
62
|
+
|
63
|
+
module A
|
64
|
+
def name
|
65
|
+
"A"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
module U
|
69
|
+
unextendable
|
70
|
+
def name
|
71
|
+
"U"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
module X
|
75
|
+
unextendable
|
76
|
+
def name
|
77
|
+
"X"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
class C
|
81
|
+
attr_accessor :title
|
82
|
+
def salutation
|
83
|
+
[title, name].reject{|x| x.nil? || x.empty?}.join " "
|
84
|
+
end
|
85
|
+
def name
|
86
|
+
"C"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
After that, you can do the following:
|
92
|
+
|
93
|
+
<pre>
|
94
|
+
c = C.new
|
95
|
+
c.title = "Mr."
|
96
|
+
c.salutation #=> "Mr. C"
|
97
|
+
c.extend U
|
98
|
+
c.salutation #=> "Mr. U"
|
99
|
+
c.extend X
|
100
|
+
c.salutation #=> "Mr. X"
|
101
|
+
c.extend U
|
102
|
+
c.salutation #=> "Mr. U"
|
103
|
+
c.unextend
|
104
|
+
c.salutation #=> "Mr. C"
|
105
|
+
c.extend A
|
106
|
+
c.salutation #=> "Mr. A"
|
107
|
+
c.extend X
|
108
|
+
c.salutation #=> "Mr. X"
|
109
|
+
c.unextend
|
110
|
+
c.salutation #=> "Mr. A" (because module A is NOT unextendable)
|
111
|
+
</pre>
|
112
|
+
|
113
|
+
h2. Last remarks
|
114
|
+
|
115
|
+
Please check out "https://github.com/archan937/unextendable/blob/master/test/object_instance_test.rb":https://github.com/archan937/unextendable/blob/master/test/object_instance_test.rb for most of the tests.
|
116
|
+
|
117
|
+
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.
|
118
|
+
|
119
|
+
h2. Contact me
|
120
|
+
|
121
|
+
For support, remarks and requests please mail me at "paul.engel@holder.nl":mailto:paul.engel@holder.nl.
|
122
|
+
|
123
|
+
h2. License
|
124
|
+
|
125
|
+
Copyright (c) 2011 Paul Engel, released under the MIT license
|
126
|
+
|
127
|
+
"http://holder.nl":http://holder.nl – "http://codehero.es":http://codehero.es – "http://gettopup.com":http://gettopup.com – "http://twitter.com/archan937":http://twitter.com/archan937 – "paul.engel@holder.nl":mailto:paul.engel@holder.nl
|
128
|
+
|
129
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
130
|
+
|
131
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
132
|
+
|
133
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class Object
|
2
|
+
|
3
|
+
def meta_class(&block)
|
4
|
+
class << self
|
5
|
+
yield if block_given?
|
6
|
+
self
|
7
|
+
end
|
8
|
+
end
|
9
|
+
alias :singleton_class :meta_class
|
10
|
+
|
11
|
+
meta_class do
|
12
|
+
def extended_modules
|
13
|
+
@extended_modules ||= []
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_procs
|
17
|
+
@method_procs ||= {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def extend(*modules)
|
22
|
+
modules.each do |mod|
|
23
|
+
wrap_unextendable_module mod if mod.unextendable?
|
24
|
+
add_extended_module mod
|
25
|
+
super(mod)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def unextend(*modules)
|
30
|
+
if modules.empty?
|
31
|
+
meta_class.extended_modules.delete_if{|mod| mod.unextendable?}
|
32
|
+
else
|
33
|
+
modules.each do |mod|
|
34
|
+
meta_class.extended_modules.delete mod
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def wrap_unextendable_module(mod)
|
42
|
+
return unless (mod.class == Module) && mod.unextendable?
|
43
|
+
|
44
|
+
mod.instance_methods.each do |method_name|
|
45
|
+
wrap_unextendable_method method_name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def wrap_unextendable_method(name)
|
50
|
+
return if meta_class.method_procs.key? name
|
51
|
+
|
52
|
+
meta_class.method_procs[name] = method(name).to_proc
|
53
|
+
|
54
|
+
instance_eval <<-CODE
|
55
|
+
def #{name}(*args, &block)
|
56
|
+
call_unextendable_method :#{name}, *args, &block
|
57
|
+
end
|
58
|
+
CODE
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_extended_module(mod)
|
62
|
+
meta_class.extended_modules.delete mod
|
63
|
+
meta_class.extended_modules.unshift mod
|
64
|
+
end
|
65
|
+
|
66
|
+
def call_unextendable_method(method_name, *args, &block)
|
67
|
+
method_for(method_name).call(*args, &block)
|
68
|
+
end
|
69
|
+
|
70
|
+
def method_for(method_name)
|
71
|
+
mod = meta_class.extended_modules.detect{|x| x.instance_methods.include? method_name.to_s}
|
72
|
+
mod ? mod.instance_method(method_name).bind(self) : proc_for(method_name)
|
73
|
+
end
|
74
|
+
|
75
|
+
def proc_for(method_name)
|
76
|
+
meta_class.method_procs[method_name.to_s] || method(method_name.to_s)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/lib/unextendable.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module A
|
2
|
+
def name
|
3
|
+
"A"
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module U
|
8
|
+
unextendable
|
9
|
+
def name
|
10
|
+
"U"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class C
|
15
|
+
attr_accessor :title
|
16
|
+
def salutation
|
17
|
+
[title, name].reject{|x| x.nil? || x.empty?}.join " "
|
18
|
+
end
|
19
|
+
def name
|
20
|
+
"C"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@c = C.new
|
25
|
+
@c.title = "Mr."
|
data/test/module_test.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path("../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class ModuleTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A module" do
|
6
|
+
setup do
|
7
|
+
module A
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
should "be able to be marked as unextendable" do
|
12
|
+
assert A.respond_to?(:unextendable)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "respond to :unextendable?" do
|
16
|
+
assert A.respond_to?(:unextendable?)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "which is not unextendable" do
|
20
|
+
should "return false when asked to be unextendable" do
|
21
|
+
assert !A.unextendable?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "which is unextendable" do
|
26
|
+
setup do
|
27
|
+
module U
|
28
|
+
unextendable
|
29
|
+
def name
|
30
|
+
"U"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
should "return true when asked to be unextendable" do
|
36
|
+
assert U.unextendable?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require File.expand_path("../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class ObjectInstanceTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "An object instance" do
|
6
|
+
setup do
|
7
|
+
module A
|
8
|
+
def name
|
9
|
+
"A"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
class C
|
13
|
+
attr_accessor :title
|
14
|
+
def salutation
|
15
|
+
[title, name].reject{|x| x.nil? || x.empty?}.join " "
|
16
|
+
end
|
17
|
+
def name
|
18
|
+
"C"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@c = C.new
|
22
|
+
@c.title = "Mr."
|
23
|
+
end
|
24
|
+
|
25
|
+
should "respond to meta_class and extended_modules" do
|
26
|
+
assert @c.respond_to?(:meta_class)
|
27
|
+
assert @c.meta_class.respond_to?(:extended_modules)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when extending modules" do
|
31
|
+
should "check whether a module is unextendable or not" do
|
32
|
+
module B; end
|
33
|
+
|
34
|
+
A.expects(:unextendable?).twice
|
35
|
+
B.expects(:unextendable?)
|
36
|
+
|
37
|
+
@c.extend A
|
38
|
+
@c.extend A, B
|
39
|
+
|
40
|
+
assert @c.meta_class.included_modules.include?(A)
|
41
|
+
assert @c.meta_class.included_modules.include?(B)
|
42
|
+
end
|
43
|
+
|
44
|
+
context "which are not unextendable" do
|
45
|
+
should "behave as normal when the module is not unextendable" do
|
46
|
+
A.expects(:wrap_unextendable_module).never
|
47
|
+
@c.extend A
|
48
|
+
assert @c.meta_class.included_modules.include?(A)
|
49
|
+
assert @c.meta_class.extended_modules.include?(A)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "behave as expected" do
|
53
|
+
assert_equal "Mr. C", @c.salutation
|
54
|
+
|
55
|
+
@c.extend A
|
56
|
+
assert_equal "Mr. A", @c.salutation
|
57
|
+
|
58
|
+
@c.unextend
|
59
|
+
assert_equal "Mr. A", @c.salutation
|
60
|
+
|
61
|
+
@d = C.new
|
62
|
+
@d.title = "Mr."
|
63
|
+
assert_equal "Mr. C", @d.salutation
|
64
|
+
|
65
|
+
@d.extend A
|
66
|
+
assert_equal "Mr. A", @d.salutation
|
67
|
+
|
68
|
+
@d.unextend A
|
69
|
+
assert_equal "Mr. A", @d.salutation
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "which are unextendable" do
|
74
|
+
setup do
|
75
|
+
module U
|
76
|
+
unextendable
|
77
|
+
def name
|
78
|
+
"U"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
should "call wrap_unextendable_module" do
|
84
|
+
@c.expects(:wrap_unextendable_module)
|
85
|
+
@c.extend A, U
|
86
|
+
end
|
87
|
+
|
88
|
+
should "call wrap_unextendable_method" do
|
89
|
+
@c.expects(:wrap_unextendable_method)
|
90
|
+
@c.extend U
|
91
|
+
end
|
92
|
+
|
93
|
+
should "add the module to extended_modules" do
|
94
|
+
assert @c.meta_class.extended_modules.empty?
|
95
|
+
@c.extend U
|
96
|
+
assert @c.meta_class.extended_modules.include?(U)
|
97
|
+
end
|
98
|
+
|
99
|
+
should "add method proc to method_procs" do
|
100
|
+
assert @c.meta_class.send(:method_procs).empty?
|
101
|
+
@c.extend U
|
102
|
+
assert_equal 1, @c.meta_class.send(:method_procs).size
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when calling an unextendable method" do
|
106
|
+
should "call call_unextendable_method" do
|
107
|
+
@c.extend U
|
108
|
+
@c.expects(:call_unextendable_method).with(:name)
|
109
|
+
@c.name
|
110
|
+
end
|
111
|
+
|
112
|
+
should "call method_for" do
|
113
|
+
method = @c.meta_class.instance_method(:name).bind(@c)
|
114
|
+
@c.extend U
|
115
|
+
@c.expects(:method_for).with(:name).returns(method)
|
116
|
+
@c.name
|
117
|
+
end
|
118
|
+
|
119
|
+
should "match the expected method" do
|
120
|
+
assert_equal @c.method(:name), @c.send(:method_for, :name)
|
121
|
+
@c.extend U
|
122
|
+
assert_equal U.instance_method(:name).bind(@c), @c.send(:method_for, :name)
|
123
|
+
end
|
124
|
+
|
125
|
+
should "return the expected value" do
|
126
|
+
assert_equal "Mr. C", @c.salutation
|
127
|
+
@c.extend U
|
128
|
+
assert_equal "Mr. U", @c.salutation
|
129
|
+
|
130
|
+
@d = C.new
|
131
|
+
assert_equal "C", @d.salutation
|
132
|
+
@d.extend U
|
133
|
+
assert_equal "U", @d.salutation
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when unextending the module afterwards" do
|
138
|
+
should "remove the module from extended_modules" do
|
139
|
+
@c.extend U
|
140
|
+
assert @c.meta_class.extended_modules.include?(U)
|
141
|
+
|
142
|
+
@c.unextend U
|
143
|
+
assert !@c.meta_class.extended_modules.include?(U)
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when calling an unextendable method" do
|
147
|
+
should "match the expected method" do
|
148
|
+
assert_equal @c.method(:name), @c.send(:method_for, :name)
|
149
|
+
|
150
|
+
@c.extend U
|
151
|
+
assert_equal U.instance_method(:name).bind(@c), @c.send(:method_for, :name)
|
152
|
+
|
153
|
+
@c.unextend U
|
154
|
+
assert_equal Proc, @c.send(:method_for, :name).class
|
155
|
+
end
|
156
|
+
|
157
|
+
should "behave as expected" do
|
158
|
+
assert_equal "Mr. C", @c.salutation
|
159
|
+
@c.title = "Dr."
|
160
|
+
assert_equal "Dr. C", @c.salutation
|
161
|
+
|
162
|
+
@c.extend U
|
163
|
+
assert_equal "Dr. U", @c.salutation
|
164
|
+
@c.title = "Sir"
|
165
|
+
assert_equal "Sir U", @c.salutation
|
166
|
+
|
167
|
+
@c.unextend U
|
168
|
+
assert_equal "Sir C", @c.salutation
|
169
|
+
@c.title = ""
|
170
|
+
assert_equal "C", @c.salutation
|
171
|
+
|
172
|
+
@c.extend U
|
173
|
+
assert_equal "U", @c.salutation
|
174
|
+
@c.title = "Ms."
|
175
|
+
assert_equal "Ms. U", @c.salutation
|
176
|
+
|
177
|
+
@c.unextend
|
178
|
+
assert_equal "Ms. C", @c.salutation
|
179
|
+
|
180
|
+
module D
|
181
|
+
unextendable
|
182
|
+
def name
|
183
|
+
"D"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
@c.extend D
|
188
|
+
assert_equal "Ms. D", @c.salutation
|
189
|
+
|
190
|
+
@c.extend U
|
191
|
+
assert_equal "Ms. U", @c.salutation
|
192
|
+
|
193
|
+
@c.extend D
|
194
|
+
assert_equal "Ms. D", @c.salutation
|
195
|
+
|
196
|
+
@c.unextend
|
197
|
+
assert_equal "Ms. C", @c.salutation
|
198
|
+
|
199
|
+
@c.extend A
|
200
|
+
assert_equal "Ms. A", @c.salutation
|
201
|
+
|
202
|
+
@c.unextend
|
203
|
+
assert_equal "Ms. A", @c.salutation
|
204
|
+
|
205
|
+
@c.extend D
|
206
|
+
assert_equal "Ms. D", @c.salutation
|
207
|
+
|
208
|
+
@c.unextend
|
209
|
+
assert_equal "Ms. A", @c.salutation
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "unextendable/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "unextendable"
|
7
|
+
s.version = Unextendable::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Paul Engel"]
|
10
|
+
s.email = ["paul.engel@holder.nl"]
|
11
|
+
s.homepage = "https://github.com/archan937/unextendable"
|
12
|
+
s.summary = %q{A small gem making unextending extended module methods within object instances possible}
|
13
|
+
s.description = %q{Unextendable originated from the thought of being able to implement the "State pattern":http://tobyho.com/Design_Patterns_Revisited%3A_State within object instances using modules. In other words: I wanted object instances to behave dependent on their state using modules. I really want to use modules because they are commonly used to define a set of methods which you can extend within an object instance. Unfortunately, you cannot just unexclude a module. So after searching the web for solutions, I came across Mixology, evil-ruby and StatePattern. But they slightly did not fit the picture. So after doing some research, I came up with Unextendable.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "unextendable"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "shoulda"
|
23
|
+
s.add_development_dependency "mocha"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: unextendable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Paul Engel
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-01 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mocha
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: "Unextendable originated from the thought of being able to implement the \"State pattern\":http://tobyho.com/Design_Patterns_Revisited%3A_State within object instances using modules. In other words: I wanted object instances to behave dependent on their state using modules. I really want to use modules because they are commonly used to define a set of methods which you can extend within an object instance. Unfortunately, you cannot just unexclude a module. So after searching the web for solutions, I came across Mixology, evil-ruby and StatePattern. But they slightly did not fit the picture. So after doing some research, I came up with Unextendable."
|
50
|
+
email:
|
51
|
+
- paul.engel@holder.nl
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- CHANGELOG.rdoc
|
61
|
+
- Gemfile
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.textile
|
64
|
+
- Rakefile
|
65
|
+
- VERSION
|
66
|
+
- lib/unextendable.rb
|
67
|
+
- lib/unextendable/module.rb
|
68
|
+
- lib/unextendable/object.rb
|
69
|
+
- lib/unextendable/version.rb
|
70
|
+
- script/console
|
71
|
+
- script/definitions.rb
|
72
|
+
- test/module_test.rb
|
73
|
+
- test/object_instance_test.rb
|
74
|
+
- test/test_helper.rb
|
75
|
+
- unextendable.gemspec
|
76
|
+
has_rdoc: true
|
77
|
+
homepage: https://github.com/archan937/unextendable
|
78
|
+
licenses: []
|
79
|
+
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project: unextendable
|
106
|
+
rubygems_version: 1.6.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: A small gem making unextending extended module methods within object instances possible
|
110
|
+
test_files:
|
111
|
+
- test/module_test.rb
|
112
|
+
- test/object_instance_test.rb
|
113
|
+
- test/test_helper.rb
|