map_by_method 0.8.2 → 0.8.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.
@@ -1,3 +1,7 @@
1
+ == 0.8.3 2007-11-16
2
+
3
+ * *args and &block are passed at #send time [thx Lawrence Pit]
4
+
1
5
  == 0.8.2 2007-09-07
2
6
 
3
7
  * Updated gem structure to use newgem's latest concepts - rubigen integration, and config folder instead of
@@ -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
@@ -2,7 +2,7 @@ module MapByMethod #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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
@@ -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.2</a>
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 =&gt; [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>, 11th August 2007<br>
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.2
7
- date: 2007-09-07 00:00:00 +02:00
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