patternmatching 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,10 +1,16 @@
1
- == 0.2.4 2007-06-06
1
+ == 0.2.5 2007-06-12
2
+
3
+ * 1 minor enhancement:
4
+ * little performance up
5
+ * Check compatibility with new ruby1.9 (20070606)
6
+ * Update project files from newgem-0.11.0
2
7
 
3
- Check compatibility with jruby1.0.0RC2 and old ruby1.9
8
+ == 0.2.4 2007-06-06
4
9
 
10
+ * Check compatibility with jruby1.0.0RC2 and old ruby1.9
5
11
  * 1 minor enhancement:
6
12
  * Fix module relations
7
- * 2 fix bugs
13
+ * 2 fix bugs:
8
14
  * example/partial_style_method.rb
9
15
  * example/partial_style_method2.rb
10
16
 
data/Rakefile CHANGED
@@ -78,7 +78,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
78
78
  p.url = HOMEPATH
79
79
  p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
80
80
  p.test_globs = ["test/**/test_*.rb"]
81
- p.clean_globs = CLEAN #An array of file patterns to delete on clean.
81
+ p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
82
82
 
83
83
  # == Optional
84
84
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
@@ -49,9 +49,10 @@ class Recursive
49
49
  end
50
50
 
51
51
  # size depends on system stack max
52
- #count = 400 # for ruby 1.8 stack max
53
- #count = 300 # for ruby 1.9 stack max
54
- count = 100 # for jruby stack max
52
+ #count = 600 # for ruby 1.8 stack max
53
+ #count = 1000 # for ruby 1.9 (200706) stack max
54
+ #count = 400 # for ruby 1.9 (200606) stack max
55
+ count = 200 # for jruby1.0 stack max
55
56
 
56
57
  plain = Recursive.new
57
58
  start = Time.new
@@ -8,9 +8,9 @@ inputs = build { exact([1,2,3,4,5]) }
8
8
  make inputs do
9
9
  # _! matches rests of list
10
10
  seems as {exact([:a,:b, _!(:c)])} do
11
- puts a.to_s + ", " + b.to_s + " and " + c.to_s
11
+ puts a.to_s + ", " + b.to_s + " and " + c.join(", ")
12
12
  end
13
13
  seems something do
14
14
  puts "not matched"
15
15
  end
16
- end # => "1, 2, and 345"
16
+ end # => "1, 2, and 3, 4, 5"
@@ -1,6 +1,6 @@
1
1
 
2
2
  module PatternMatching
3
- # Domain Specific Language style methods for inside block
3
+ #Domain Specific Language style methods for inside block
4
4
  module DSL_INSIDE
5
5
  #A pattern matches description inside block
6
6
  #=== Usage
@@ -25,6 +25,7 @@ module PatternMatching
25
25
  end
26
26
  include DSL_INSIDE
27
27
 
28
+ #Domain Specific Language style methods for inside module
28
29
  module DSL_MODULE
29
30
  #Define method as partial style
30
31
  #=== Usage
@@ -46,7 +47,12 @@ module PatternMatching
46
47
  patterns = []
47
48
  instance_variable_set(pattern_name, patterns)
48
49
  define_method(name) do |target|
49
- MatchExec.exec_as(target, patterns, self)
50
+ result = MatchExec.exec_as(target, patterns, self)
51
+ if result
52
+ result[0].instance_eval(&result[1])
53
+ else
54
+ nil
55
+ end
50
56
  end
51
57
  end
52
58
  patterns = instance_variable_get(pattern_name)
@@ -59,7 +65,7 @@ module PatternMatching
59
65
  end
60
66
  include DSL_MODULE
61
67
 
62
- # Domain Specific Language style methods for outside
68
+ #Domain Specific Language style methods for outside
63
69
  module DSL_OUTSIDE
64
70
  #Build structured data
65
71
  #=== Usage
@@ -78,7 +84,12 @@ module PatternMatching
78
84
  def make(target, &block)
79
85
  patterns = []
80
86
  PatternFragments.new(patterns).instance_eval(&block)
81
- MatchExec.exec_as(target, patterns, self)
87
+ result = MatchExec.exec_as(target, patterns, self)
88
+ if result
89
+ result[0].instance_eval(&result[1])
90
+ else
91
+ nil
92
+ end
82
93
  end
83
94
 
84
95
  end
@@ -206,12 +217,12 @@ module PatternMatching
206
217
  end
207
218
  executer = ExecuteAs.new(args, receiver)
208
219
  next if condition != nil and not executer.instance_eval(&condition)
209
- return executer.instance_eval(&action)
220
+ return [executer, action]
210
221
  end
211
222
  nil
212
223
  end
213
224
 
214
- # Private class to access instance valiables of the receiver
225
+ #Private class to access instance valiables of the receiver
215
226
  class InstanceVariableAccessor
216
227
  def initialize(receiver)
217
228
  @receiver = receiver
@@ -2,7 +2,7 @@ module PatternMatching
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -104,13 +104,13 @@ describe "PatternMatching from Example" do
104
104
  a.to_s + " and " + b.to_s + " and" + c.to_s
105
105
  end
106
106
  seems as {exact([:a,:b, _!(:c)])} do
107
- a.to_s + ", " + b.to_s + " and " + c.to_s
107
+ a.to_s + ", " + b.to_s + " and " + c.join(", ")
108
108
  end
109
109
  seems something do
110
110
  "not matched"
111
111
  end
112
112
  end
113
- result.should == "1, 2 and 345"
113
+ result.should == "1, 2 and 3, 4, 5"
114
114
  end
115
115
 
116
116
  it "should look Just Enumerable pattern." do
data/website/index.html CHANGED
@@ -32,8 +32,8 @@
32
32
 
33
33
  <h1>PatternMatching module</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/patternmatching"; return false'>
35
- Get Version
36
- <a href="http://rubyforge.org/projects/patternmatching" class="numbers">0.2.4</a>
35
+ <p>Get Version</p>
36
+ <a href="http://rubyforge.org/projects/patternmatching" class="numbers">0.2.5</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;patternmatching&#8217;</h1>
39
39
 
@@ -114,6 +114,15 @@ pre, code {
114
114
  font-size: 4em;
115
115
  line-height: 0.8em;
116
116
  letter-spacing: -0.1ex;
117
+ margin-bottom: 15px;
118
+ }
119
+
120
+ #version p {
121
+ text-decoration: none;
122
+ color: #141331;
123
+ background-color: #B3ABFF;
124
+ margin: 0;
125
+ padding: 0;
117
126
  }
118
127
 
119
128
  #version a {
@@ -32,7 +32,7 @@
32
32
 
33
33
  <h1><%= title %></h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "<%= download %>"; return false'>
35
- Get Version
35
+ <p>Get Version</p>
36
36
  <a href="<%= download %>" class="numbers"><%= version %></a>
37
37
  </div>
38
38
  <%= body %>
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.2.4
7
- date: 2007-06-06 00:00:00 +09:00
6
+ version: 0.2.5
7
+ date: 2007-06-12 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