ick 0.2.1 → 0.2.2

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.
@@ -11,4 +11,6 @@
11
11
  * 4 minor enhancement
12
12
  * fixed manifest.txt
13
13
  * TODO: build the manifest algorithmically!
14
+ * 5 minor enhancement
15
+ * #fork
14
16
 
@@ -1,6 +1,6 @@
1
1
  module Ick
2
2
  def self.sugarize
3
- [Let, Returning, My, Inside, Maybe, Try, Please, Tee].each do |clazz|
3
+ [Let, Returning, My, Inside, Maybe, Try, Please, Tee, Fork].each do |clazz|
4
4
  clazz.belongs_to Object
5
5
  end
6
6
  end
@@ -1,9 +1,6 @@
1
1
  module Ick
2
2
 
3
- =begin
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
@@ -2,7 +2,7 @@ module Ick #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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
 
@@ -125,28 +125,45 @@ class TestIck < Test::Unit::TestCase
125
125
  )
126
126
  end
127
127
 
128
- # def test_tee_basic
129
- # box1 = Box.new(1)
130
- # box2 = Box.new(2)
131
- # tee(box1,box2) { |box| box.value = 7 }
132
- # assert_equal(7, box1.value)
133
- # assert_equal(7, box2.value)
134
- # end
135
-
136
- # def test_tee_semantics
137
- # first_log = []
138
- # second_log = []
139
- # [first_log, second_log].map do |value|
140
- # log << "first line of output"
141
- # log << "second line of output"
142
- # end
143
- # assert_equal(, log)
144
- # out = []
145
- # tee(1, 2, 3) do |value|
146
- # out << "a#{value}"
147
- # out << "b#{value}"
148
- # end
149
- # assert_equal(%w(a1 b1 c1 a2 b2 c2), out)
150
- # end
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
@@ -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.1</a>
36
+ <a href="http://rubyforge.org/projects/ick" class="numbers">0.2.2</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;ick&#8217;</h1>
39
39
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ick
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
6
+ version: 0.2.2
7
7
  date: 2008-03-09 00:00:00 -05:00
8
8
  summary: Invocation Construction Kit
9
9
  require_paths: