map_by_method 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -0,0 +1,4 @@
1
+ 0.6
2
+ Removed explicit singularize method.
3
+ Instead, singularize option only supported if another gem (e.g. activesupport)
4
+ provides a singularize method for strings.
@@ -1,7 +1,7 @@
1
1
  module MapByMethod #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 5
4
+ MINOR = 6
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
data/lib/map_by_method.rb CHANGED
@@ -19,7 +19,9 @@ module MapByMethod
19
19
  result.first :
20
20
  result.transpose
21
21
  end
22
- return self.map {|item| item.send method.to_s.singularize.to_sym}
22
+ method_name = method.to_s
23
+ @@support_singularize ||= method_name.methods.include? "singularize"
24
+ return self.map {|item| item.send method_name.singularize.to_sym} if @@support_singularize
23
25
  rescue NoMethodError
24
26
  nil
25
27
  end
@@ -29,12 +31,4 @@ module MapByMethod
29
31
  end
30
32
  end
31
33
 
32
- unless String.instance_methods.include? "singularize"
33
- class String
34
- def singularize
35
- self.gsub(/e?s\Z/,'')
36
- end
37
- end
38
- end
39
-
40
34
  Array.send :include, MapByMethod
@@ -8,7 +8,6 @@ class MapByMethodTest < Test::Unit::TestCase
8
8
  def test_map
9
9
  assert_equal ['1','2','3'], [1,2,3].map_to_s
10
10
  assert_equal ['1','2','3'], [1,2,3].map_by_to_s
11
- assert_equal ['1','2','3'], [1,2,3].to_ss
12
11
  end
13
12
 
14
13
  def test_collect
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: map_by_method
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2006-10-26 00:00:00 +02:00
6
+ version: 0.6.0
7
+ date: 2006-12-21 00:00:00 +11:00
8
8
  summary: Replacement for Symbol.to_proc which is much cleaner and prettier
9
9
  require_paths:
10
10
  - lib
@@ -32,11 +32,11 @@ files:
32
32
  - CHANGELOG
33
33
  - Rakefile
34
34
  - test/all_tests.rb
35
+ - test/test_helper.rb
35
36
  - test/map_by_method_test.rb
36
37
  - test/multiple_methods_test.rb
37
- - test/test_helper.rb
38
- - lib/map_by_method
39
38
  - lib/map_by_method.rb
39
+ - lib/map_by_method
40
40
  - lib/map_by_method/version.rb
41
41
  test_files: []
42
42