map_by_method 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/map_by_method.rb +2 -1
- data/lib/map_by_method/version.rb +1 -1
- data/test/test_map_by_method.rb +12 -0
- data/website/index.html +2 -2
- metadata +2 -2
data/History.txt
CHANGED
data/lib/map_by_method.rb
CHANGED
@@ -30,7 +30,8 @@ module MapByMethod
|
|
30
30
|
iterator, callmethod = matches[1..2]
|
31
31
|
# map by multiple stuff
|
32
32
|
result = callmethod.split('_and_').collect do |method|
|
33
|
-
self.send(iterator) { |item| item.send method }
|
33
|
+
# self.send(iterator) { |item| item.send method }
|
34
|
+
self.send(iterator) { |item| item.send(method, *args, &block) }
|
34
35
|
end
|
35
36
|
|
36
37
|
return result.length > 1 ? result.transpose : result.first
|
data/test/test_map_by_method.rb
CHANGED
@@ -56,4 +56,16 @@ class TestMapByMethod < Test::Unit::TestCase
|
|
56
56
|
assert_equal expected, original.index_by_name
|
57
57
|
end
|
58
58
|
|
59
|
+
def test_pass_args
|
60
|
+
original = ["hello world", "hallo wereld", "ciao mondo"]
|
61
|
+
expected = %w[hell hall ciao]
|
62
|
+
assert_equal(expected, original.map_by_slice(0,4))
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_pass_block
|
66
|
+
original = ["hello world", "hallo wereld", "ciao mondo"]
|
67
|
+
expected = ["[hello ]world", "[hallo ]wereld", "[ciao ]mondo"]
|
68
|
+
assert_equal(expected, original.map_by_gsub(/^(.*)\s/) {|first_word| "[#{first_word}]" })
|
69
|
+
end
|
70
|
+
|
59
71
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Map By Method</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/map_by_method"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/map_by_method" class="numbers">0.8.
|
36
|
+
<a href="http://rubyforge.org/projects/map_by_method" class="numbers">0.8.3</a>
|
37
37
|
</div>
|
38
38
|
<h1><code>["1","2","3"]. map_by_to_i => [1,2,3]</code></h1>
|
39
39
|
|
@@ -104,7 +104,7 @@ other stories and things.</p>
|
|
104
104
|
|
105
105
|
<p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a> via the <a href="http://groups.google.com/group/drnicutilities">forum</a></p>
|
106
106
|
<p class="coda">
|
107
|
-
<a href="drnicwilliams@gmail.com">Dr Nic Williams</a>,
|
107
|
+
<a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 12th August 2007<br>
|
108
108
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
109
109
|
</p>
|
110
110
|
</div>
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.3
|
|
3
3
|
specification_version: 1
|
4
4
|
name: map_by_method
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.8.3
|
7
|
+
date: 2007-11-16 00:00:00 +10:00
|
8
8
|
summary: Replacement for map {|obj| obj.action} and Symbol.to_proc which is much cleaner and prettier NOW WORKS with ActiveRecord Associations!!
|
9
9
|
require_paths:
|
10
10
|
- lib
|