ick 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -0
- data/lib/ick/sugar.rb +1 -1
- data/lib/ick/tee.rb +9 -6
- data/lib/ick/version.rb +1 -1
- data/lib/ick/wrap.rb +0 -5
- data/test/test_ick.rb +40 -23
- data/website/index.html +1 -1
- metadata +1 -1
data/History.txt
CHANGED
data/lib/ick/sugar.rb
CHANGED
data/lib/ick/tee.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
module Ick
|
2
2
|
|
3
|
-
|
4
|
-
WARNING: UNTESTED
|
5
|
-
=end
|
6
|
-
class Tee < Wrap
|
3
|
+
class Split < Wrap
|
7
4
|
|
8
5
|
def invoke(*values, &proc)
|
9
6
|
invoke_wrapped(values, ArrayWrapper, nil, &proc)
|
@@ -13,8 +10,6 @@ module Ick
|
|
13
10
|
wrapped.respond_to?(:__value__) ? wrapped.__value__.first : wrapped
|
14
11
|
end
|
15
12
|
|
16
|
-
evaluates_in_calling_environment and returns_result
|
17
|
-
|
18
13
|
def self.belongs_to clazz
|
19
14
|
method_name = self.underscore(self.name.split('::')[-1])
|
20
15
|
unless clazz.method_defined?(method_name)
|
@@ -31,5 +26,13 @@ module Ick
|
|
31
26
|
end
|
32
27
|
|
33
28
|
end
|
29
|
+
|
30
|
+
class Tee < Split
|
31
|
+
evaluates_in_calling_environment and returns_value
|
32
|
+
end
|
33
|
+
|
34
|
+
class Fork < Split
|
35
|
+
evaluates_in_calling_environment and returns_result
|
36
|
+
end
|
34
37
|
|
35
38
|
end
|
data/lib/ick/version.rb
CHANGED
data/lib/ick/wrap.rb
CHANGED
@@ -54,12 +54,7 @@ module Ick
|
|
54
54
|
|
55
55
|
class ArrayWrapper < Wrapper
|
56
56
|
|
57
|
-
def initialize(values, *additional_attributes)
|
58
|
-
super(values)
|
59
|
-
end
|
60
|
-
|
61
57
|
def __invoke__(sym, *args, &block)
|
62
|
-
p "#{sym} -> #{@value.inspect}"
|
63
58
|
@value.map { |_| _.__send__(sym, *args, &block) }
|
64
59
|
end
|
65
60
|
|
data/test/test_ick.rb
CHANGED
@@ -125,28 +125,45 @@ class TestIck < Test::Unit::TestCase
|
|
125
125
|
)
|
126
126
|
end
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
128
|
+
def test_tee_basic
|
129
|
+
box1 = Box.new(1)
|
130
|
+
box2 = Box.new(2)
|
131
|
+
assert_equal(box1.object_id, tee(box1,box2) { |box| box.value = 7 }.object_id)
|
132
|
+
assert_equal(7, box1.value)
|
133
|
+
assert_equal(7, box2.value)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_tee_semantics
|
137
|
+
array_logger_one = []
|
138
|
+
array_logger_two = []
|
139
|
+
line_number = 0
|
140
|
+
[array_logger_one, array_logger_two].map do |log|
|
141
|
+
line_number += 1
|
142
|
+
log << "A#{line_number}"
|
143
|
+
line_number += 1
|
144
|
+
log << "B#{line_number}"
|
145
|
+
end
|
146
|
+
assert_equal(%w(A1 B2), array_logger_one)
|
147
|
+
assert_equal(%w(A3 B4), array_logger_two)
|
148
|
+
array_logger_one = []
|
149
|
+
array_logger_two = []
|
150
|
+
line_number = 0
|
151
|
+
tee(array_logger_one, array_logger_two) do |log|
|
152
|
+
line_number += 1
|
153
|
+
log << "A#{line_number}"
|
154
|
+
line_number += 1
|
155
|
+
log << "B#{line_number}"
|
156
|
+
end
|
157
|
+
assert_equal(%w(A1 B2), array_logger_one)
|
158
|
+
assert_equal(%w(A1 B2), array_logger_two)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_fork_basic
|
162
|
+
box1 = Box.new(1)
|
163
|
+
box2 = Box.new(2)
|
164
|
+
assert_equal(7, fork(box1,box2) { |box| box.value = 7 })
|
165
|
+
assert_equal(7, box1.value)
|
166
|
+
assert_equal(7, box2.value)
|
167
|
+
end
|
151
168
|
|
152
169
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Invocation Construction Kit</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/ick"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/ick" class="numbers">0.2.
|
36
|
+
<a href="http://rubyforge.org/projects/ick" class="numbers">0.2.2</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘ick’</h1>
|
39
39
|
|