ruby-nuggets 0.2.0.238 → 0.2.1.246

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.2.0
5
+ This documentation refers to ruby-nuggets version 0.2.1
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -25,3 +25,71 @@
25
25
  ###############################################################################
26
26
  #++
27
27
 
28
+ module Enumerable
29
+
30
+ alias_method :original_all?, :all?
31
+ alias_method :original_any?, :any?
32
+
33
+ # call-seq:
34
+ # enum.all?(obj[, operator]) => true or false
35
+ # enum.all? { ... } => true or false
36
+ #
37
+ # Adds the ability to pass an +object+ instead of a block, which will then
38
+ # be tested against each item in _enum_ according to +operator+, defaulting
39
+ # to :===.
40
+ def all?(object = default = Object.new, operator = :===, &block)
41
+ original_all?(&_block_for_all_any_extended(object, default, operator, block))
42
+ end
43
+
44
+ # call-seq:
45
+ # enum.any?(obj[, operator]) => true or false
46
+ # enum.any? { ... } => true or false
47
+ #
48
+ # Adds the ability to pass an +object+ instead of a block, which will then
49
+ # be tested against each item in _enum_ according to +operator+, defaulting
50
+ # to :===.
51
+ def any?(object = default = Object.new, operator = :===, &block)
52
+ original_any?(&_block_for_all_any_extended(object, default, operator, block))
53
+ end
54
+
55
+ private
56
+
57
+ # Common argument processing for extended versions of #all? and #any?.
58
+ def _block_for_all_any_extended(object, default, operator, block)
59
+ if default.nil?
60
+ raise ArgumentError, "both block and object argument given", caller(1) if block
61
+
62
+ lambda { |item| object.send(operator, item) }
63
+ else
64
+ block
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ if $0 == __FILE__
71
+ e = %w[quux quuux quix]
72
+ p e
73
+
74
+ p e.all?(String)
75
+ p e.any?(Numeric)
76
+
77
+ e = [:one, 'c', nil, 88]
78
+ p e
79
+
80
+ p e.all?(Object)
81
+ p e.any?(NilClass)
82
+
83
+ begin
84
+ e.any?(NilClass) { |i| i.nil? }
85
+ rescue ArgumentError => err
86
+ puts "#{err.backtrace.first}: #{err} (#{err.class})"
87
+ end
88
+
89
+ e = [0, 10, 20]
90
+ p e
91
+
92
+ p e.any?(9..99)
93
+ p e.any?(9, :<)
94
+ p e.any? { |i| i < 9 }
95
+ end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 0
7
+ TINY = 1
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nuggets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.238
4
+ version: 0.2.1.246
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-05 00:00:00 +02:00
12
+ date: 2008-06-24 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,61 +24,61 @@ extra_rdoc_files:
24
24
  - ChangeLog
25
25
  - README
26
26
  files:
27
- - lib/nuggets/integer/to_binary_s.rb
28
- - lib/nuggets/integer/factorial.rb
29
- - lib/nuggets/version.rb
30
- - lib/nuggets/object/singleton_class.rb
31
- - lib/nuggets/object/blank.rb
32
- - lib/nuggets/enumerable/agrep.rb
33
- - lib/nuggets/enumerable/minmax.rb
34
27
  - lib/nuggets/all.rb
35
- - lib/nuggets/string/sub_with_md.rb
28
+ - lib/nuggets/version.rb
29
+ - lib/nuggets/io/agrep.rb
30
+ - lib/nuggets/file/which.rb
31
+ - lib/nuggets/integer/factorial.rb
32
+ - lib/nuggets/integer/to_binary_s.rb
33
+ - lib/nuggets/array/to_hash.rb
34
+ - lib/nuggets/array/shuffle.rb
35
+ - lib/nuggets/array/format.rb
36
+ - lib/nuggets/array/in_order.rb
37
+ - lib/nuggets/array/combination.rb
38
+ - lib/nuggets/array/flatten_once.rb
39
+ - lib/nuggets/array/rand.rb
40
+ - lib/nuggets/array/monotone.rb
41
+ - lib/nuggets/uri/exist.rb
42
+ - lib/nuggets/uri/content_type.rb
43
+ - lib/nuggets/proc/bind.rb
44
+ - lib/nuggets/string/word_wrap.rb
36
45
  - lib/nuggets/string/msub.rb
37
46
  - lib/nuggets/string/case.rb
47
+ - lib/nuggets/string/sub_with_md.rb
38
48
  - lib/nuggets/string/evaluate.rb
39
- - lib/nuggets/string/word_wrap.rb
40
49
  - lib/nuggets/string/nsub.rb
41
50
  - lib/nuggets/string/capitalize_first.rb
42
- - lib/nuggets/hash/in_order.rb
43
- - lib/nuggets/hash/insert.rb
44
- - lib/nuggets/proc/bind.rb
45
- - lib/nuggets/array/rand.rb
46
- - lib/nuggets/array/to_hash.rb
47
- - lib/nuggets/array/flatten_once.rb
48
- - lib/nuggets/array/in_order.rb
49
- - lib/nuggets/array/shuffle.rb
50
- - lib/nuggets/array/monotone.rb
51
- - lib/nuggets/array/format.rb
52
- - lib/nuggets/array/combination.rb
51
+ - lib/nuggets/object/blank.rb
52
+ - lib/nuggets/object/singleton_class.rb
53
53
  - lib/nuggets/numeric/between.rb
54
54
  - lib/nuggets/numeric/signum.rb
55
55
  - lib/nuggets/numeric/to_multiple.rb
56
- - lib/nuggets/util/ansicolor2css.rb
57
- - lib/nuggets/util/content_type.rb
58
56
  - lib/nuggets/util/dotted_decimal.rb
59
57
  - lib/nuggets/util/i18n.rb
60
- - lib/nuggets/file/which.rb
61
- - lib/nuggets/uri/content_type.rb
62
- - lib/nuggets/uri/exist.rb
63
- - lib/nuggets/io/agrep.rb
58
+ - lib/nuggets/util/ansicolor2css.rb
59
+ - lib/nuggets/util/content_type.rb
60
+ - lib/nuggets/enumerable/minmax.rb
61
+ - lib/nuggets/enumerable/all_any_extended.rb
62
+ - lib/nuggets/enumerable/agrep.rb
63
+ - lib/nuggets/hash/in_order.rb
64
+ - lib/nuggets/hash/insert.rb
64
65
  - COPYING
65
- - HEADER
66
+ - Rakefile
66
67
  - README
67
68
  - ChangeLog
68
- - Rakefile
69
69
  has_rdoc: true
70
70
  homepage: http://prometheus.rubyforge.org/ruby-nuggets
71
71
  post_install_message:
72
72
  rdoc_options:
73
73
  - --line-numbers
74
- - --all
74
+ - --main
75
+ - README
75
76
  - --inline-source
76
77
  - --title
77
78
  - ruby-nuggets Application documentation
78
- - --main
79
- - README
80
79
  - --charset
81
80
  - UTF-8
81
+ - --all
82
82
  require_paths:
83
83
  - lib
84
84
  required_ruby_version: !ruby/object:Gem::Requirement