multimethod 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -2
- data/README.txt +2 -2
- data/Rakefile +11 -1
- data/Releases.txt +5 -0
- data/lib/multimethod/multimethod_version.rb +1 -1
- data/lib/multimethod/signature.rb +11 -3
- data/test/signature_test.rb +40 -0
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
2006-12-02 Kurt A. Stephens <kurt@umleta.com>
|
2
|
+
|
3
|
+
* Fixed non-alpha method names.
|
4
|
+
|
1
5
|
2006-12-01 Kurt A. Stephens <kurt@umleta.com>
|
2
6
|
|
3
7
|
* Fixed ambigous method testing.
|
4
8
|
|
5
9
|
2006-11-29 Kurt A. Stephens <kurt@umleta.com>
|
6
10
|
|
7
|
-
* Major cleanup and documentation
|
11
|
+
* Major cleanup and documentation.
|
8
12
|
* Fixed default parameter scoring.
|
9
13
|
|
10
14
|
2006-11-18 Kurt A. Stephens <kurt@umleta.com>
|
11
15
|
|
12
|
-
* Initial release
|
16
|
+
* Initial release.
|
17
|
+
|
data/README.txt
CHANGED
@@ -8,9 +8,9 @@ gem install multimethod
|
|
8
8
|
|
9
9
|
== Documentation
|
10
10
|
|
11
|
-
|
11
|
+
{Project Info}:http://rubyforge.org/projects/multimethod/
|
12
12
|
|
13
|
-
|
13
|
+
{API Documentation}:http://multimethod.rubyforge.org/
|
14
14
|
|
15
15
|
The RubyForge package multimethod
|
16
16
|
implements multi-method dispatching on argument types.
|
data/Rakefile
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# Rakefile for ruby-multimethods -*- ruby -*-
|
2
2
|
# Adapted from RubyGems/Rakefile
|
3
|
-
|
3
|
+
|
4
|
+
# For release
|
5
|
+
"
|
6
|
+
svn status
|
7
|
+
rake update_version
|
8
|
+
rake package
|
9
|
+
rake release VERSION=x.x.x
|
10
|
+
rake svn_release
|
11
|
+
rake publish_docs
|
12
|
+
rake announce
|
13
|
+
"
|
4
14
|
|
5
15
|
#################################################################
|
6
16
|
|
data/Releases.txt
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
= Multimethod Release History
|
2
2
|
|
3
|
+
== Release 0.2.2: 2006/12/02
|
4
|
+
|
5
|
+
* Fixed non-alpha method names.
|
6
|
+
|
3
7
|
== Release 0.2.1: 2006/12/01
|
4
8
|
|
5
9
|
* Fixed ambiguous method testing.
|
@@ -26,3 +30,4 @@
|
|
26
30
|
* Initial Release
|
27
31
|
* TODO
|
28
32
|
* Fix how default parameters are scored.
|
33
|
+
|
@@ -109,16 +109,24 @@ module Multimethod
|
|
109
109
|
|
110
110
|
str.sub!(/\A\s+/, '')
|
111
111
|
|
112
|
-
if md = /\
|
112
|
+
if @mod && md = /\Adef\s+(self\.)?([^\s\(]+)/.match(str)
|
113
|
+
str = md.post_match
|
114
|
+
@class_method = ! ! md[1]
|
115
|
+
@name = md[2]
|
116
|
+
elsif @mod && md = /\A(self\.)?([^\s\(]+)/.match(str)
|
117
|
+
str = md.post_match
|
118
|
+
@class_method = ! ! md[1]
|
119
|
+
@name = md[2]
|
120
|
+
elsif md = /\A(\w+(::\w+)*)#([^\s\(]+)/.match(str)
|
113
121
|
str = md.post_match
|
114
122
|
@mod = md[1] unless @mod
|
115
123
|
@name = md[3]
|
116
|
-
elsif md = /\A(\w+(::\w+)*)\.(\
|
124
|
+
elsif md = /\A(\w+(::\w+)*)\.([^\s\(]+)/.match(str)
|
117
125
|
str = md.post_match
|
118
126
|
@mod = md[1] unless @mod
|
119
127
|
@class_method = true
|
120
128
|
@name = md[3]
|
121
|
-
elsif md
|
129
|
+
elsif md = /\A((\w+(::\w+)*)\s+)?def\s+(self\.)?([^\s\(]+)/.match(str)
|
122
130
|
str = md.post_match
|
123
131
|
@mod = md[2] unless @mod
|
124
132
|
@class_method = ! ! md[4]
|
data/test/signature_test.rb
CHANGED
@@ -123,6 +123,14 @@ module Multimethod
|
|
123
123
|
end
|
124
124
|
|
125
125
|
|
126
|
+
def test_scan_string_mod
|
127
|
+
assert_not_nil m1 = Signature.new(:mod => Object, :string => 'm(A a, B b, c = nil, *d)')
|
128
|
+
|
129
|
+
assert_signature m1
|
130
|
+
assert ! m1.class_method
|
131
|
+
end
|
132
|
+
|
133
|
+
|
126
134
|
def test_scan_string_class_method
|
127
135
|
assert_not_nil m1 = Signature.new(:string => 'Object.m(A a, B b, c = nil, *d)')
|
128
136
|
|
@@ -149,6 +157,7 @@ module Multimethod
|
|
149
157
|
assert_equal 'call_method(foo(bar, "45,67"), \',\')', m1.parameter[2].default
|
150
158
|
end
|
151
159
|
|
160
|
+
|
152
161
|
def test_scan_default_at_end
|
153
162
|
assert_not_nil m1 = Signature.new(:string => 'Object.m(A a, B b = call_method(foo(bar, "45,67"), \',\'), c = nil)')
|
154
163
|
|
@@ -159,6 +168,37 @@ module Multimethod
|
|
159
168
|
end
|
160
169
|
|
161
170
|
|
171
|
+
def test_scan_special_chars
|
172
|
+
assert_not_nil m1 = Signature.new(:string => 'A#+(A a)')
|
173
|
+
assert_equal '+', m1.name
|
174
|
+
assert ! m1.class_method
|
175
|
+
assert_equal 2, m1.parameter.size
|
176
|
+
assert_equal ::A, m1.parameter[0].type_object
|
177
|
+
assert_equal ::A, m1.parameter[1].type_object
|
178
|
+
|
179
|
+
|
180
|
+
assert_not_nil m1 = Signature.new(:string => 'A#foo=(A a)')
|
181
|
+
assert_equal 'foo=', m1.name
|
182
|
+
assert ! m1.class_method
|
183
|
+
assert_equal 2, m1.parameter.size
|
184
|
+
assert_equal ::A, m1.parameter[0].type_object
|
185
|
+
assert_equal ::A, m1.parameter[1].type_object
|
186
|
+
|
187
|
+
assert_not_nil m1 = Signature.new(:string => 'String#sub!(Regexp a)')
|
188
|
+
assert_equal 'sub!', m1.name
|
189
|
+
assert ! m1.class_method
|
190
|
+
assert_equal 2, m1.parameter.size
|
191
|
+
assert_equal ::String, m1.parameter[0].type_object
|
192
|
+
assert_equal ::Regexp, m1.parameter[1].type_object
|
193
|
+
|
194
|
+
assert_not_nil m1 = Signature.new(:string => 'String#empty?')
|
195
|
+
assert_equal 'empty?', m1.name
|
196
|
+
assert ! m1.class_method
|
197
|
+
assert_equal 1, m1.parameter.size
|
198
|
+
assert_equal ::String, m1.parameter[0].type_object
|
199
|
+
end
|
200
|
+
|
201
|
+
|
162
202
|
def test_cmp
|
163
203
|
assert_not_nil m1 = Signature.new(:string => 'Object#m(A a, B b, c = nil, *d)')
|
164
204
|
assert_not_nil m2 = Signature.new(:string => 'Object#m(A a, B b, c = nil, *d)')
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: multimethod
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2006-12-
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2006-12-04 00:00:00 -05:00
|
8
8
|
summary: "Supports Multimethod dispatching. For more details, see: http://multimethod.rubyforge.org/files/lib/multimethod_rb.html http://multimethod.rubyforge.org/files/README.txt http://multimethod.rubyforge.org/"
|
9
9
|
require_paths:
|
10
10
|
- lib
|