patternmatching 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.1.3 2007-06-05
2
+
3
+ * 1 minor enhancement:
4
+ * Document refinement
5
+
1
6
  == 0.1.2 2007-06-04
2
7
 
3
8
  * 1 minor enhancement:
data/Manifest.txt CHANGED
@@ -5,6 +5,7 @@ README.txt
5
5
  Rakefile
6
6
  examples/enumerable_matching.rb
7
7
  examples/hash_matching.rb
8
+ examples/match_inside_class.rb
8
9
  examples/matching.rb
9
10
  examples/object_matching.rb
10
11
  examples/partial_style_method.rb
data/README.txt CHANGED
@@ -1,171 +1,174 @@
1
- h1. PatternMatching module
1
+ = PatternMatching module
2
2
 
3
- h1. → 'patternmatching'
4
3
 
5
- h2. What
4
+ == What
6
5
 
7
6
  Provides a pure ruby module that:
8
7
  * can build structured objects easily
9
8
  * can enable pattern match of objects
10
9
  * can define method as a partial function style
11
10
 
12
- h2. Installing
11
+ == Installing
13
12
 
14
- <pre syntax="ruby">sudo gem install patternmatching</pre>
13
+ sudo gem install patternmatching
15
14
 
16
- h2. The basics
15
+ == The basics
17
16
 
18
17
  This module provides methods for tree pattern matching features.
19
18
 
20
- * For detail, see Wikipedia: "Pattern matching":http://en.wikipedia.org/wiki/Pattern_matching
19
+ * For detail, see {Wikipedia: Pattern matching}[http://en.wikipedia.org/wiki/Pattern_matching]
21
20
  * Syntax based on meta-programming, like "rspec", and so on.
22
21
 
23
22
  Note: Default equivalence used in structured pattern matching is
24
- based on "<code>pattern === data</code>",
25
- so "<code>foo(Numeric)</code>" matches "<code>foo(100)</code>".
23
+ based on "pattern === data",
24
+ so "foo(Numeric)" matches "foo(100)".
26
25
 
27
26
  Notice: Current implementation is not thread safe now.
28
27
  Need the receiver object(NOT an argument) calling pattern matching
29
28
  synchronized when multi-threaded access.
30
29
 
31
- h2. Demonstration of usage
30
+ == Demonstration of usage
32
31
 
33
- Symbols(e.g. <code>:a</code>, <code>:right_value</code>)
32
+ Symbols(e.g. ":a", ":right_value")
34
33
  in patterns is passed as variable
35
34
  to the following block when the pattern matched.
36
35
 
37
- <h3>Pattern matching expression</h3>
38
- <pre>
39
- require "patternmatching"
40
-
41
- # For DSL style code, include PatternMatching
42
- include PatternMatching
43
-
44
- # match example
45
- def calc(code)
46
- make(code) {
47
- seems as {plus(:a, :b)} do calc(a) + calc(b) end
48
- seems as {mul(:a, :b)} do calc(a) * calc(b) end
49
- seems something do code end
50
- }
51
- end
52
-
53
- code = build {plus(mul(100, 100), 200)}
54
- p calc(code) #=> 10200
55
- </pre>
56
-
57
- <h3>Partial style method</h3>
58
- <pre>
59
- require "patternmatching"
60
-
61
- # Structured data builder
62
- code = PatternMatching.build {plus(mul(100, 100), 200)}
63
-
64
- # Partial style method example
65
- class Calc
66
- # At first, extends with the module
67
- extend PatternMatching
68
-
69
- # def calcm(o), as 3 partial styles
70
- func(:calcm).seems as {plus(:a, :a)} do
71
- calcm(b) + calcm(b)
72
- end
73
- func(:calcm).seems as {mul(:a, :b)} do
74
- calcm(a) * calcm(b)
75
- end
76
- func(:calcm).seems as {:value} do
77
- value
78
- end
79
- end
80
-
81
- # use as standard method
82
- p Calc.new.calcm(code) #=> 10200
83
- </pre>
84
-
85
- <h3>Array/Enumerable pattern</h3>
86
- <pre>
87
- require "patternmatching"
88
-
89
- include PatternMatching
90
-
91
- # Example for matching Enumerable
92
- is = build { exact([1,2,3,4,5]) }
93
- make is do
94
- # _! matches rest of lists
95
- seems as {exact([:a,:b, _!(:c)])} do
96
- puts a.to_s + ", " + b.to_s + " and " + c.to_s
97
- end
98
- seems something do
99
- puts "not matched"
100
- end
101
- end # => "1, 2, and 345"
102
- </pre>
103
-
104
- <h3>Hash pattern</h3>
105
- <pre>
106
- require "patternmatching"
107
-
108
- include PatternMatching
109
-
110
- # Example for matching Hash
111
- dict = build { {:name => "Taro", :age => 5} }
112
- make dict do
113
- seems as {{:name => :name}} do
114
- puts "He is " + name
115
- end
116
- seems something do
117
- puts "no name"
118
- end
119
- end # => "He is Taro"
120
- </pre>
121
-
122
- <h3>Non-Hash/Object pattern</h3>
123
- <pre>
124
- require "patternmatching"
125
-
126
- include PatternMatching
127
-
128
- class Person
129
- def initialize(name, age)
130
- @name = name
131
- @age = age
132
- end
133
- attr :name
134
- attr :age
135
- end
136
-
137
- # Example for matching Object except Hash
138
- person = Person.new("Jiro", 3)
139
- make person do
140
- seems as {{:name => :name}} do
141
- puts "He is " + name
142
- end
143
- seems something do
144
- puts "no name"
145
- end
146
- end # => "He is Jiro"
147
- </pre>
148
-
149
- h2. Forum
150
-
151
- Visit RubyForge project forum.
152
-
153
- h2. How to submit patches
154
-
155
- Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
156
-
157
- The trunk repository is <code>svn://rubyforge.org/var/svn/patternmatching/trunk</code> for anonymous access.
158
-
159
- h2. License
36
+ === Pattern matching expression
37
+ # If installed from gem
38
+ # require "rubygems"
39
+ # gem "patternmatching"
40
+ require "patternmatching"
41
+
42
+ # For DSL style code, include PatternMatching
43
+ include PatternMatching
44
+
45
+ # match example
46
+ def calc(code)
47
+ make(code) {
48
+ seems as {plus(:a, :b)} do calc(a) + calc(b) end
49
+ seems as {mul(:a, :b)} do calc(a) * calc(b) end
50
+ seems something do code end
51
+ }
52
+ end
53
+
54
+ code = build {plus(mul(100, 100), 200)}
55
+ p calc(code) #=> 10200
56
+
57
+ === Partial style method
58
+
59
+ require "patternmatching"
60
+
61
+ # Structured data builder
62
+ code = PatternMatching.build {plus(mul(100, 100), 200)}
63
+
64
+ # Partial style method example
65
+ class Calc
66
+ # At first, extends with the module
67
+ extend PatternMatching
68
+
69
+ # def calcm(o), as 3 partial styles
70
+ func(:calcm).seems as {plus(:a, :b)} do
71
+ calcm(b) + calcm(b)
72
+ end
73
+ func(:calcm).seems as {mul(:a, :b)} do
74
+ calcm(a) * calcm(b)
75
+ end
76
+ func(:calcm).seems as {:value} do
77
+ value
78
+ end
79
+ end
80
+
81
+ # use as standard method
82
+ p Calc.new.calcm(code) #=> 10200
83
+
84
+ === Array/Enumerable pattern
85
+
86
+ require "patternmatching"
87
+
88
+ include PatternMatching
89
+
90
+ # Example for matching Enumerable
91
+ is = build { exact([1,2,3,4,5]) }
92
+ make is do
93
+ # _! matches rest of lists
94
+ seems as {exact([:a,:b, _!(:c)])} do
95
+ puts a.to_s + ", " + b.to_s + " and " + c.to_s
96
+ end
97
+ seems something do
98
+ puts "not matched"
99
+ end
100
+ end # => "1, 2, and 345"
101
+
102
+ === Hash pattern
103
+
104
+ require "patternmatching"
105
+
106
+ include PatternMatching
107
+
108
+ # Example for matching Hash
109
+ dict = build { {:name => "Taro", :age => 5} }
110
+ make dict do
111
+ seems as {{:name => :name}} do
112
+ puts "He is " + name
113
+ end
114
+ seems something do
115
+ puts "no name"
116
+ end
117
+ end # => "He is Taro"
118
+
119
+ === Non-Hash/Object pattern
120
+
121
+ require "patternmatching"
122
+
123
+ include PatternMatching
124
+
125
+ class Person
126
+ def initialize(name, age)
127
+ @name = name
128
+ @age = age
129
+ end
130
+ attr :name
131
+ attr :age
132
+ end
133
+
134
+ # Example for matching Object except Hash
135
+ person = Person.new("Jiro", 3)
136
+ make person do
137
+ seems as {{:name => :name}} do
138
+ puts "He is " + name
139
+ end
140
+ seems something do
141
+ puts "no name"
142
+ end
143
+ end # => "He is Jiro"
144
+
145
+ == Forum
146
+
147
+ Visit the project forum in RubyForge.
148
+
149
+ == How to submit patches
150
+
151
+ Read the {8 steps for fixing other people's code}[http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/] and for section {8b: Submit patch to Google Groups}[http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups], use the forum above.
152
+
153
+ The trunk repository is
154
+ svn://rubyforge.org/var/svn/patternmatching/trunk
155
+ for anonymous access.
156
+
157
+ == License
160
158
 
161
159
  This code is free to use under the terms of the MIT license.
162
160
 
163
- h2. Link
161
+ == Link
164
162
 
165
- * "Web Site":http://patternmatching.rubyforge.org/
166
- * "Project Page":http://rubyforge.org/projects/patternmatching/
163
+ * Web Site: http://patternmatching.rubyforge.org/
164
+ * Project Page: http://rubyforge.org/projects/patternmatching/
167
165
 
168
- h2. Contact
166
+ == Contact
169
167
 
170
- Comments are welcome. Send an email to "ICHIYAMA Ryoichi":mailto:bellbind@gmail.com. "My blog":http://d.hatena.ne.jp/bellbind (written in Japanese) could be help you.
168
+ Comments are welcome. Send a message to the forum.
169
+ {My blog}[http://d.hatena.ne.jp/bellbind/] (written in Japanese)
170
+ could be help you.
171
171
 
172
+ == Authors
173
+
174
+ * ICHIYAMA Ryoichi: bellbind at gmail dot com
data/Rakefile CHANGED
@@ -59,7 +59,8 @@ RDOC_OPTS = ['--quiet', '--title', 'patternmatching documentation',
59
59
  "--opname", "index.html",
60
60
  "--line-numbers",
61
61
  "--main", "README",
62
- "--inline-source"]
62
+ "--inline-source",
63
+ "--all" ]
63
64
 
64
65
  class Hoe
65
66
  def extra_deps
@@ -0,0 +1,28 @@
1
+ require "patternmatching"
2
+
3
+ include PatternMatching
4
+
5
+ class Foo
6
+ def initialize
7
+ @name = "Foo"
8
+ end
9
+ attr :name
10
+
11
+ def bar
12
+ make "bar" do
13
+ seems as {:val} do
14
+ @name = val
15
+ end
16
+ end
17
+ end
18
+
19
+ func(:buzz).seems as {:val} do
20
+ @name = val
21
+ end
22
+ end
23
+
24
+ o = Foo.new
25
+ o.bar
26
+ p o.name #=> "bar"
27
+ o.buzz("buzz")
28
+ p o.name #=> "buzz"
@@ -1,14 +1,18 @@
1
1
 
2
2
  module PatternMatching
3
+ #Private Exception for stop matching
3
4
  class NotMatched < Exception
4
5
  end
5
6
 
7
+ #Private class for build structured data
6
8
  class NodeBuilder
9
+ private
7
10
  def method_missing(name, *args)
8
11
  Node.new(name, args)
9
12
  end
10
13
  end
11
14
 
15
+ #Class for structured data/patterns
12
16
  class Node
13
17
  def initialize(name, children)
14
18
  @name = name
@@ -23,7 +27,8 @@ module PatternMatching
23
27
  end
24
28
  end
25
29
 
26
- class Collector
30
+ #Private module for pattern matching and to collect var/val pairs
31
+ module Collector
27
32
  def self.walk(source, target, list)
28
33
  case source
29
34
  when Symbol
@@ -99,6 +104,7 @@ module PatternMatching
99
104
  end
100
105
  end
101
106
 
107
+ #Private class to run pattern matching
102
108
  class MatchExec
103
109
  def self.exec_as(target, patterns, receiver)
104
110
  patterns.each do |pair|
@@ -115,6 +121,8 @@ module PatternMatching
115
121
  end
116
122
  end
117
123
 
124
+ #Private class enabling to use the name of symbols in patterns
125
+ #like a local variables in action blocks
118
126
  class ExecuteAs
119
127
  def initialize(args, receiver)
120
128
  @this = receiver
@@ -141,6 +149,7 @@ module PatternMatching
141
149
  end
142
150
  end
143
151
 
152
+ #Private class for collecting pattern/action fragments
144
153
  class PatternFragments
145
154
  def initialize(patterns)
146
155
  @patterns = patterns
@@ -157,141 +166,79 @@ module PatternMatching
157
166
  end
158
167
  end
159
168
 
160
- # DSL element
161
- def build(&block)
162
- NodeBuilder.new.instance_eval(&block)
163
- end
164
- def self.build(&block)
165
- NodeBuilder.new.instance_eval(&block)
166
- end
167
- def make(target, &block)
168
- patterns = []
169
- PatternFragments.new(patterns).instance_eval(&block)
170
- MatchExec.exec_as(target, patterns, self)
171
- end
172
- def as(&block)
173
- block
174
- end
175
- def something
176
- proc {_}
177
- end
178
- def func(name, &block)
179
- pattern_name = ("@_pattern_" + name.to_s ).to_sym
180
- unless method_defined?(name)
169
+ # Domain Specific Language style methods
170
+ module DSL
171
+ #Build structured data
172
+ #=== Usage
173
+ # build {[foo(bar, 100), foo(buzz, "abc")]}
174
+ def build(&block)
175
+ NodeBuilder.new.instance_eval(&block)
176
+ end
177
+
178
+ #Build structured data
179
+ #=== Usage
180
+ # PatternMatching.build {[foo(bar, 100), foo(buzz, "abc")]}
181
+ def self.build(&block)
182
+ NodeBuilder.new.instance_eval(&block)
183
+ end
184
+
185
+ #Do pattern matching
186
+ #===Usage
187
+ # make TARGET do
188
+ # seems as {PATTERN_1} do ACTION_1 end
189
+ # seems as {PATTERN_2} do ACTION_2 end
190
+ # seems something do ACTION_DEFAULT end
191
+ # end
192
+ def make(target, &block)
181
193
  patterns = []
182
- instance_variable_set(pattern_name, patterns)
183
- define_method(name) do |target|
184
- MatchExec.exec_as(target, patterns, self)
185
- end
194
+ PatternFragments.new(patterns).instance_eval(&block)
195
+ MatchExec.exec_as(target, patterns, self)
186
196
  end
187
- patterns = instance_variable_get(pattern_name)
188
- fragments = PatternFragments.new(patterns)
189
- if block
190
- fragments.instance_eval(&block)
197
+
198
+ #A pattern matches description inside block
199
+ #=== Usage
200
+ # seems as {some pattern...} do ... end
201
+ def as(&block)
202
+ block
191
203
  end
192
- fragments
193
- end
194
- end
195
-
196
- =begin
197
- # If installed from rubygems
198
- require "rubygems"
199
- gem "patternmatching"
200
-
201
- # for use
202
- require "patternmatching"
203
-
204
-
205
- # partial func example
206
- class Calc
207
- extend PatternMatching
208
-
209
- func(:calcm).seems as {plus(:a, :b)} do
210
- calcm(a) + calcm(b)
211
- end
212
- func(:calcm).seems as {mul(:a, :b)} do
213
- calcm(a) * calcm(b)
214
- end
215
- func(:calcm).seems as {:value} do
216
- value
217
- end
218
- end
219
-
220
- val = 200
221
- code = PatternMatching.build {plus(mul(100, 100), val)}
222
- p Calc.new.calcm(code)
223
-
224
- # another partial func example
225
- class CalcX
226
- extend PatternMatching
227
-
228
- func(:calcx) do
229
- seems as {plus(:a, :b)} do
230
- calcx(a) + calcx(b)
204
+
205
+ #A pattern matches anything
206
+ #=== Usage
207
+ # seems something do ... end
208
+ def something
209
+ proc {_}
231
210
  end
232
- seems as {mul(:a, :b)} do
233
- calcx(a) * calcx(b)
211
+
212
+ #Define method as partial style
213
+ #=== Usage
214
+ # func(NAME).seems as {PATTERN_1} do ACTION_1 end
215
+ # func(NAME).seems as {PATTERN_2} do ACTION_2 end
216
+ # func(NAME).seems something do ACTION_DEFAULT end
217
+ #
218
+ #or
219
+ #
220
+ # func NAME do
221
+ # seems as {PATTERN_1} do ACTION_1 end
222
+ # seems as {PATTERN_2} do ACTION_2 end
223
+ # seems something do ACTION_DEFAULT end
224
+ # end
225
+ #
226
+ def func(name, &block)
227
+ pattern_name = ("@_pattern_" + name.to_s ).to_sym
228
+ unless method_defined?(name)
229
+ patterns = []
230
+ instance_variable_set(pattern_name, patterns)
231
+ define_method(name) do |target|
232
+ MatchExec.exec_as(target, patterns, self)
233
+ end
234
+ end
235
+ patterns = instance_variable_get(pattern_name)
236
+ fragments = PatternFragments.new(patterns)
237
+ if block
238
+ fragments.instance_eval(&block)
239
+ end
240
+ fragments
234
241
  end
235
242
  end
236
- func(:calcx).seems as {:value} do
237
- value
238
- end
239
- end
240
-
241
- p CalcX.new.calcx(code)
242
-
243
- # pattern example
244
- include PatternMatching
245
-
246
- def calc(code)
247
- make(code) {
248
- seems as {plus(:a, :b)} do calc(a) + calc(b) end
249
- seems as {mul(:a, :b)} do calc(a) * calc(b) end
250
- seems something do code end
251
- }
252
- end
253
-
254
- p calc(code)
255
-
256
-
257
- # enumerable match example
258
- is = build { exact([1,2,3,4,5]) }
259
- make is do
260
- seems as {exact([:a,:b, _!(:c)])} do
261
- puts a.to_s + ", " + b.to_s + " and " + c.to_s
262
- end
263
- seems something do
264
- puts "not matched"
265
- end
266
- end
267
-
268
- # hash to hash match example
269
- dict = build { {:name => "Taro", :age => 5} }
270
- make dict do
271
- seems as {{:name => :name}} do
272
- puts "He is " + name
273
- end
274
- seems something do
275
- puts "no name"
276
- end
277
- end
278
-
279
- # hash to obj match example
280
- class Person
281
- def initialize(name, age)
282
- @name = name
283
- @age = age
284
- end
285
- attr :name
286
- attr :age
287
- end
288
-
289
- make Person.new("Jiro", 3) do
290
- seems as {{:name => :name}} do
291
- puts "He is " + name
292
- end
293
- seems something do
294
- puts "no name"
295
- end
243
+ include DSL
296
244
  end
297
- =end
@@ -2,7 +2,7 @@ module PatternMatching #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,5 +1,111 @@
1
- module PatternMatching
2
- end
3
1
 
4
2
  require 'patternmatching/version'
5
3
  require 'patternmatching/pattern'
4
+
5
+ module PatternMatching
6
+ # The module is only for showing example docs.
7
+ #== Using module
8
+ # # If installed from rubygems
9
+ # require "rubygems"
10
+ # gem "patternmatching"
11
+ #
12
+ # # for use
13
+ # require "patternmatching"
14
+ #
15
+ #== Structured data example
16
+ # val = 200
17
+ # code = PatternMatching.build {plus(mul(100, 100), val)}
18
+ #
19
+ #== Partial func example
20
+ # class Calc
21
+ # extend PatternMatching
22
+ #
23
+ # func(:calcm).seems as {plus(:a, :b)} do
24
+ # calcm(a) + calcm(b)
25
+ # end
26
+ # func(:calcm).seems as {mul(:a, :b)} do
27
+ # calcm(a) * calcm(b)
28
+ # end
29
+ # func(:calcm).seems as {:value} do
30
+ # value
31
+ # end
32
+ # end
33
+ #
34
+ # p Calc.new.calcm(code)
35
+ #
36
+ #== Another partial style method example
37
+ # class CalcX
38
+ # extend PatternMatching
39
+ #
40
+ # func(:calcx) do
41
+ # seems as {plus(:a, :b)} do
42
+ # calcx(a) + calcx(b)
43
+ # end
44
+ # seems as {mul(:a, :b)} do
45
+ # calcx(a) * calcx(b)
46
+ # end
47
+ # end
48
+ # func(:calcx).seems as {:value} do
49
+ # value
50
+ # end
51
+ # end
52
+ #
53
+ # p CalcX.new.calcx(code)
54
+ #
55
+ #== Pattern matching example
56
+ # include PatternMatching
57
+ #
58
+ # def calc(code)
59
+ # make(code) {
60
+ # seems as {plus(:a, :b)} do calc(a) + calc(b) end
61
+ # seems as {mul(:a, :b)} do calc(a) * calc(b) end
62
+ # seems something do code end
63
+ # }
64
+ # end
65
+ #
66
+ # p calc(code)
67
+ #
68
+ #== Enumerable matching example
69
+ # is = build { exact([1,2,3,4,5]) }
70
+ # make is do
71
+ # seems as {exact([:a,:b, _!(:c)])} do
72
+ # puts a.to_s + ", " + b.to_s + " and " + c.to_s
73
+ # end
74
+ # seems something do
75
+ # puts "not matched"
76
+ # end
77
+ # end
78
+ #
79
+ #== Hash to Hash matching example
80
+ # dict = build { {:name => "Taro", :age => 5} }
81
+ # make dict do
82
+ # seems as {{:name => :name}} do
83
+ # puts "He is " + name
84
+ # end
85
+ # seems something do
86
+ # puts "no name"
87
+ # end
88
+ # end
89
+ #
90
+ #== Hash to non-Hash object matching example
91
+ # class Person
92
+ # def initialize(name, age)
93
+ # @name = name
94
+ # @age = age
95
+ # end
96
+ # attr :name
97
+ # attr :age
98
+ # end
99
+ #
100
+ # make Person.new("Jiro", 3) do
101
+ # seems as {{:name => :name}} do
102
+ # puts "He is " + name
103
+ # end
104
+ # seems something do
105
+ # puts "no name"
106
+ # end
107
+ # end
108
+ #
109
+ module EXAMPLES
110
+ end
111
+ end
@@ -43,6 +43,26 @@ class Person
43
43
  end
44
44
 
45
45
  include PatternMatching
46
+ class PartialStyleDefs
47
+ def initialize
48
+ @name = "Foo"
49
+ end
50
+ attr :name
51
+
52
+ def bar
53
+ make "bar" do
54
+ seems as {:val} do
55
+ @name = val
56
+ end
57
+ end
58
+ end
59
+
60
+ func(:buzz).seems as {:val} do
61
+ @name = val
62
+ end
63
+ end
64
+
65
+
46
66
  def calc(code)
47
67
  make(code) {
48
68
  seems as {plus(:a, :b)} do calc(a) + calc(b) end
@@ -159,4 +179,13 @@ describe "PatternMatching from Example" do
159
179
  end
160
180
  result.should == [120, 200]
161
181
  end
182
+
183
+ it "should update fields from block" do
184
+ o = PartialStyleDefs.new
185
+ o.name.should == "Foo"
186
+ o.bar
187
+ o.name.should == "bar"
188
+ o.buzz("buzz")
189
+ o.name.should == "buzz"
190
+ end
162
191
  end
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>PatternMatching module</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/patternmatching"; return false'>
35
35
  Get Version
36
- <a href="http://rubyforge.org/projects/patternmatching" class="numbers">0.1.2</a>
36
+ <a href="http://rubyforge.org/projects/patternmatching" class="numbers">0.1.3</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;patternmatching&#8217;</h1>
39
39
 
@@ -61,7 +61,7 @@ Provides a pure ruby module that:
61
61
 
62
62
 
63
63
  <ul>
64
- <li>For detail, see Wikipedia: <a href="http://en.wikipedia.org/wiki/Pattern_matching">Pattern matching</a></li>
64
+ <li>For detail, see <a href="http://en.wikipedia.org/wiki/Pattern_matching">Wikipedia: Pattern matching</a></li>
65
65
  <li>Syntax based on meta-programming, like &#8220;rspec&#8221;, and so on.</li>
66
66
  </ul>
67
67
 
@@ -86,6 +86,9 @@ to the following block when the pattern matched.</p>
86
86
 
87
87
  <h3>Pattern matching expression</h3>
88
88
  <pre>
89
+ # If installed from gem
90
+ # require "rubygems"
91
+ # gem "patternmatching"
89
92
  require "patternmatching"
90
93
 
91
94
  # For DSL style code, include PatternMatching
@@ -205,7 +208,7 @@ end # =&gt; "He is Jiro"
205
208
  <h2>How to submit patches</h2>
206
209
 
207
210
 
208
- <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
211
+ <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the forum above.</p>
209
212
 
210
213
 
211
214
  <p>The trunk repository is <code>svn://rubyforge.org/var/svn/patternmatching/trunk</code> for anonymous access.</p>
@@ -229,9 +232,21 @@ end # =&gt; "He is Jiro"
229
232
  <h2>Contact</h2>
230
233
 
231
234
 
232
- <p>Comments are welcome. Send an email to <a href="mailto:bellbind@gmail.com"><span class="caps">ICHIYAMA</span> Ryoichi</a>. <a href="http://d.hatena.ne.jp/bellbind">My blog</a> (written in Japanese) could be help you.</p>
235
+ <p>Comments are welcome. Send a message to the forum.</p>
236
+
237
+
238
+ <h2>Authors</h2>
239
+
240
+
241
+ <ul>
242
+ <li><span class="caps">ICHIYAMA</span> Ryoichi: bellbind at gmail dot com</li>
243
+ </ul>
244
+
245
+
246
+ <p><a href="http://d.hatena.ne.jp/bellbind">My blog</a> (written in Japanese)
247
+ could be help you.</p>
233
248
  <p class="coda">
234
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 4th June 2007<br>
249
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 5th June 2007<br>
235
250
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
236
251
  </p>
237
252
  </div>
data/website/index.txt CHANGED
@@ -17,7 +17,7 @@ h2. The basics
17
17
 
18
18
  This module provides methods for tree pattern matching features.
19
19
 
20
- * For detail, see Wikipedia: "Pattern matching":http://en.wikipedia.org/wiki/Pattern_matching
20
+ * For detail, see "Wikipedia: Pattern matching":http://en.wikipedia.org/wiki/Pattern_matching
21
21
  * Syntax based on meta-programming, like "rspec", and so on.
22
22
 
23
23
  Note: Default equivalence used in structured pattern matching is
@@ -36,6 +36,9 @@ to the following block when the pattern matched.
36
36
 
37
37
  <h3>Pattern matching expression</h3>
38
38
  <pre>
39
+ # If installed from gem
40
+ # require "rubygems"
41
+ # gem "patternmatching"
39
42
  require "patternmatching"
40
43
 
41
44
  # For DSL style code, include PatternMatching
@@ -152,7 +155,7 @@ Visit RubyForge project forum.
152
155
 
153
156
  h2. How to submit patches
154
157
 
155
- Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
158
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the forum above.
156
159
 
157
160
  The trunk repository is <code>svn://rubyforge.org/var/svn/patternmatching/trunk</code> for anonymous access.
158
161
 
@@ -167,5 +170,11 @@ h2. Link
167
170
 
168
171
  h2. Contact
169
172
 
170
- Comments are welcome. Send an email to "ICHIYAMA Ryoichi":mailto:bellbind@gmail.com. "My blog":http://d.hatena.ne.jp/bellbind (written in Japanese) could be help you.
173
+ Comments are welcome. Send a message to the forum.
171
174
 
175
+ h2. Authors
176
+
177
+ * ICHIYAMA Ryoichi: bellbind at gmail dot com
178
+
179
+ "My blog":http://d.hatena.ne.jp/bellbind (written in Japanese)
180
+ could be help you.
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: patternmatching
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2007-06-04 00:00:00 +09:00
6
+ version: 0.1.3
7
+ date: 2007-06-05 00:00:00 +09:00
8
8
  summary: Provide a pure ruby module that can build structured objects easily, can enable pattern match of objects, and can define method as a partial function style.
9
9
  require_paths:
10
10
  - lib
@@ -36,6 +36,7 @@ files:
36
36
  - Rakefile
37
37
  - examples/enumerable_matching.rb
38
38
  - examples/hash_matching.rb
39
+ - examples/match_inside_class.rb
39
40
  - examples/matching.rb
40
41
  - examples/object_matching.rb
41
42
  - examples/partial_style_method.rb