rmtools 2.1.0 → 2.1.1

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.
@@ -63,14 +63,11 @@ private
63
63
  # 2. Most latency is given by #method_missing, but which are factor of #__send__?
64
64
  def method_missing(method, *args, &block)
65
65
  if match = (meth = method.to_s).match(@@iterators_pattern)
66
- iterator, meth = match[1].to_sym, match[2].to_sym
66
+ iterator, meth = match[1], match[2]
67
+ iterator.sub!(/^((?:ever|an)y|no(?:ne)?)$/, '\1?')
68
+ iterator = iterator.to_sym
67
69
 
68
70
  begin
69
- case iterator
70
- when :every then iterator = :every?
71
- when :no then iterator = :no?
72
- end
73
-
74
71
  return case iterator
75
72
  when :sum, :sort_along_by; __send__(iterator, args.shift) {|i| i.__send__ meth, *args, &block}
76
73
  when :find_by, :select_by, :reject_by, :partition_by; __send__(iterator, meth, *args)
@@ -108,7 +105,7 @@ private
108
105
 
109
106
  end # << self
110
107
 
111
- add_iterator_name(instance_methods.grep(/_by$/)+%w{every no which select reject partition find_all find sum foldr foldl fold count rand_by})
108
+ add_iterator_name(instance_methods.grep(/_by$/)+%w{every any no none which select reject partition find_all find sum foldr foldl fold count rand_by})
112
109
 
113
110
  # Benchmark 2:
114
111
  #
@@ -227,11 +224,9 @@ private
227
224
  # # += 6% of time
228
225
  def method_missing(method, *args, &block)
229
226
  if match = (meth = method.to_s).match(@@iterators_pattern)
230
- iterator, meth = match[1].to_sym, match[2].to_sym
231
- case iterator
232
- when :every then iterator = :every?
233
- when :no then iterator = :no?
234
- end
227
+ iterator, meth = match[1], match[2]
228
+ iterator.sub!(/^((?:ever|an)y|no(?:ne)?)$/, '\1?')
229
+ iterator = iterator.to_sym
235
230
 
236
231
  case iterator
237
232
  when :sum, :sort_along_by
@@ -44,9 +44,11 @@ else
44
44
  end
45
45
  end
46
46
 
47
- def any?
48
- !empty?
49
- end
47
+ if RUBY_VERSION < '1.9'
48
+ def any?(&block)
49
+ !!find(&block)
50
+ end
51
+ end
50
52
 
51
53
  def max_by_key; [(m = keys.max), self[m]] end
52
54
 
@@ -1,3 +1,3 @@
1
1
  module RMTools
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport