nuggets 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/README +1 -1
- data/lib/nuggets/enumerable/minmax.rb +13 -7
- data/lib/nuggets/version.rb +1 -1
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f7723ca18083a47b25d3966ee9dfed33adc7380
|
4
|
+
data.tar.gz: 7d73e368f7e5818b7c83ec4ffb35d3e3fea5a0c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46812ac2321ae75968d8937b45b325b71e541939b77af029caa3bd3749874a34c4981a8acfa07140325a1262d3f3cffd3898bd14c18a3dda7e8072818ea1c1b9
|
7
|
+
data.tar.gz: ccd5781ae98ea86765115ba317be282405a96f132d1666a7bb6070276c5de64ea52206e3fcc53320389e71df632b486c7e7b99aa2fb3f1aba7eb5bb96be50cca
|
data/ChangeLog
CHANGED
data/README
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# #
|
4
4
|
# nuggets -- Extending Ruby #
|
5
5
|
# #
|
6
|
-
# Copyright (C) 2007-
|
6
|
+
# Copyright (C) 2007-2015 Jens Wille #
|
7
7
|
# #
|
8
8
|
# Authors: #
|
9
9
|
# Jens Wille <jens.wille@gmail.com> #
|
@@ -40,7 +40,9 @@ module Enumerable
|
|
40
40
|
# Finds the maximum/minimum (or whatever +meth+ is) value in _enum_ according
|
41
41
|
# to +by+ (which may be a symbol/string that is sent to each value, or a proc
|
42
42
|
# that receives each value as parameter).
|
43
|
-
def minmax_by(meth, by)
|
43
|
+
def minmax_by(meth = nil, by = nil, &block)
|
44
|
+
return _nuggets_original_minmax_by(&block) unless meth
|
45
|
+
|
44
46
|
_by = by.is_a?(::Proc) ? by : lambda { |i| i.send(by) }
|
45
47
|
send(meth) { |a, b| _by[a] <=> _by[b] }
|
46
48
|
end
|
@@ -49,16 +51,18 @@ module Enumerable
|
|
49
51
|
# enum.max_by(by) => aValue
|
50
52
|
#
|
51
53
|
# Maximum #minmax_by.
|
52
|
-
def max_by(by)
|
53
|
-
|
54
|
+
def max_by(by = nil, &block)
|
55
|
+
by.nil? || by.is_a?(::Numeric) ?
|
56
|
+
_nuggets_original_max_by(by, &block) : minmax_by(:max, by)
|
54
57
|
end
|
55
58
|
|
56
59
|
# call-seq:
|
57
60
|
# enum.min_by(by) => aValue
|
58
61
|
#
|
59
62
|
# Minimum #minmax_by.
|
60
|
-
def min_by(by)
|
61
|
-
|
63
|
+
def min_by(by = nil, &block)
|
64
|
+
by.nil? || by.is_a?(::Numeric) ?
|
65
|
+
_nuggets_original_min_by(by, &block) : minmax_by(:min, by)
|
62
66
|
end
|
63
67
|
|
64
68
|
# call-seq:
|
@@ -68,7 +72,9 @@ module Enumerable
|
|
68
72
|
#
|
69
73
|
# Example:
|
70
74
|
# %w[a bcd ef].max(:length) #=> 3
|
71
|
-
def minmax(meth, what)
|
75
|
+
def minmax(meth = nil, what = nil, &block)
|
76
|
+
return _nuggets_original_minmax(&block) unless meth
|
77
|
+
|
72
78
|
#m = minmax_by(meth, what)
|
73
79
|
#what.is_a?(Proc) ? what[m] : m.send(what)
|
74
80
|
|
data/lib/nuggets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nuggets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -349,15 +349,13 @@ licenses:
|
|
349
349
|
metadata: {}
|
350
350
|
post_install_message: |2+
|
351
351
|
|
352
|
-
nuggets-1.2.
|
352
|
+
nuggets-1.2.1 [2015-04-14]:
|
353
353
|
|
354
|
-
*
|
355
|
-
* Added Net::SSH::Connection::Session#exec_sudo.
|
356
|
-
* Added Hash.deproc.
|
354
|
+
* Ruby Core compatibility for Enumerable#minmax etc. Issue #4 by @codez.
|
357
355
|
|
358
356
|
rdoc_options:
|
359
357
|
- "--title"
|
360
|
-
- nuggets Application documentation (v1.2.
|
358
|
+
- nuggets Application documentation (v1.2.1)
|
361
359
|
- "--charset"
|
362
360
|
- UTF-8
|
363
361
|
- "--line-numbers"
|