mug 1.2.1 → 1.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c21f58658e25bbdc5ffa1d9fc3b5a80ba7da9c4a49348681523a034e21d6972e
4
- data.tar.gz: 2db7532d87137ca0bf31ac1d460b7bf487ee15abdbc8e09f5d32310e8a5bd8d5
3
+ metadata.gz: ae4264ea134edd98eb0f3b98b9af1d3d6b201158843f41f1adc24463e17680c0
4
+ data.tar.gz: 233a5598d2598106cbce6de061c1d3d91e7bee1647f314708c1a2ea812c200d6
5
5
  SHA512:
6
- metadata.gz: 96db9c590c28244950a74746f680549234780c34a259819991b3efccc78cc2fb5294f3b9655fe3f428b50805d472b67c43c86ad7c60608e80b039cbd8f34ddc8
7
- data.tar.gz: e57ca3a0fa44884f06fb5bfc3a7b1a26d5055b1e1b6ccdcf7832df86d7c39f18d5dfad512c4666d1f466f5c0fe5ffbd76a69fee3d7482d00b853b6ed74070a0b
6
+ metadata.gz: 03571d89948df0dd21c24f1b598a9324f9caac1c53537a45f0853583756ba6a4acdacbb7de4d7b15eec9c549232212b0af9d6620d93205cd4fe726de680498a7
7
+ data.tar.gz: a945570b56260c0e14c82b46fcc363cbf69925aee08679de9327f9246d9f721a877b14c79c5266905a25145839f688980c83d68adadd9e606274efa19cfb3672
data/lib/mug.rb CHANGED
@@ -11,6 +11,7 @@ require_relative 'mug/array/to_proc'
11
11
  require_relative 'mug/bool'
12
12
  require_relative 'mug/bittest'
13
13
  require_relative 'mug/clamp'
14
+ require_relative 'mug/compat'
14
15
  require_relative 'mug/enumerable/any-and-all'
15
16
  require_relative 'mug/enumerable/chain'
16
17
  require_relative 'mug/enumerable/counts'
@@ -14,7 +14,11 @@ module Enumerable
14
14
  end
15
15
  end
16
16
 
17
- undef chain if RUBY_VERSION >= '2.6'
17
+ if RUBY_VERSION >= '2.6'
18
+ warn "warning: Enumerable\#chain defined since Ruby 2.6 is incompatible with this gem when used with args and a block"
19
+ undef chain
20
+ end
21
+
18
22
  #
19
23
  # Creates a chain of Enumerables following this one, and
20
24
  # invokes a block once for each element of each Enumerable.
@@ -8,6 +8,7 @@ class Hash
8
8
  # {'a'=>1, 'b'=>2}.map_values { "cat" } #=> {'a'=>"cat", 'b'=>"cat"}
9
9
  #
10
10
  def map_values &_block # :yields: value
11
+ return enum_for(:map_values) unless block_given?
11
12
  hsh = {}
12
13
  each do |k, v|
13
14
  hsh[k] = yield v
@@ -21,6 +22,7 @@ class Hash
21
22
  # See: #map_values
22
23
  #
23
24
  def map_values! &block # :yields: value
25
+ return enum_for(:map_values!) unless block_given?
24
26
  replace map_values(&block)
25
27
  end
26
28
 
@@ -35,6 +37,7 @@ class Hash
35
37
  # {'a'=>1, 'b'=>2}.map_keys { "cat" } #=> {'cat'=>2}
36
38
  #
37
39
  def map_keys &_block # :yields: key
40
+ return enum_for(:map_keys) unless block_given?
38
41
  hsh = {}
39
42
  each do |k, v|
40
43
  hsh[ yield k ] = v
@@ -50,6 +53,7 @@ class Hash
50
53
  # See: #map_keys
51
54
  #
52
55
  def map_keys! &block # :yields: key
56
+ return enum_for(:map_keys!) unless block_given?
53
57
  replace map_keys(&block)
54
58
  end
55
59
 
@@ -64,6 +68,7 @@ class Hash
64
68
  # {'a'=>1, 'b'=>2}.map_pairs { ["cat","dog"] } #=> {'cat'=>'dog'}
65
69
  #
66
70
  def map_pairs &_block # :yields: key, value
71
+ return enum_for(:map_pairs) unless block_given?
67
72
  hsh = {}
68
73
  each do |k, v|
69
74
  a, b = yield k, v
@@ -78,6 +83,7 @@ class Hash
78
83
  # See: #map_values
79
84
  #
80
85
  def map_pairs! &block # :yields: key, value
86
+ return enum_for(:map_pairs!) unless block_given?
81
87
  replace map_pairs(&block)
82
88
  end
83
89
  end
@@ -22,7 +22,7 @@ class Iterator < Enumerator
22
22
  # In the second, deprecated, form, a generated Iterator sends the
23
23
  # given method with any +args+ to the iterand.
24
24
  #
25
- # Use of this form is discourages. Use Object#iter_for or
25
+ # Use of this form is discouraged. Use Object#iter_for or
26
26
  # Object#to_iter instead.
27
27
  #
28
28
  # @call-seq new(initial, *args) { |obj, *args| ... }
@@ -7,6 +7,7 @@ module Kernel
7
7
  return enum_for(:with, *args) unless block_given?
8
8
  yield *args
9
9
  end
10
+ private :with
10
11
  end
11
12
 
12
13
  =begin
@@ -0,0 +1,46 @@
1
+ require 'test/unit'
2
+ $VERBOSE = true
3
+
4
+ class ::DummyClass
5
+ def self.dummy_method
6
+ :ok
7
+ end
8
+ def self.clobber_method
9
+ :original
10
+ end
11
+ end
12
+
13
+ require_relative '../lib/mug/with'
14
+ class Test_with < Test::Unit::TestCase
15
+
16
+ def test_with
17
+ input = [1, 'two', :three]
18
+ output = nil
19
+
20
+ with(*input) do |a, b, c|
21
+ output = [a, b, c]
22
+ end
23
+
24
+ assert_equal( output, input )
25
+ end
26
+
27
+ def test_with__noblock
28
+ input = [1, 'two', :three]
29
+ output = nil
30
+
31
+ enum = with(*input)
32
+ assert_kind_of( Enumerator, enum )
33
+
34
+ enum.each do |a, b, c|
35
+ output = [a, b, c]
36
+ end
37
+
38
+ assert_equal( output, input )
39
+ end
40
+
41
+ def test_with__private
42
+ assert_raise(NoMethodError) { self.with }
43
+ end
44
+
45
+ end
46
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Kerwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  == MUG: Matty's Ultimate Gem
@@ -106,6 +106,7 @@ files:
106
106
  - test/test-tau.rb
107
107
  - test/test-time.rb
108
108
  - test/test-top.rb
109
+ - test/test-with.rb
109
110
  homepage: http://phluid61.github.com/mug
110
111
  licenses:
111
112
  - ISC
@@ -125,8 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  - !ruby/object:Gem::Version
126
127
  version: '0'
127
128
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.7.6
129
+ rubygems_version: 3.0.1
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: 'MUG: Matty''s Ultimate Gem'
@@ -150,6 +150,7 @@ test_files:
150
150
  - test/test-array-to_proc.rb
151
151
  - test/test-affix.rb
152
152
  - test/test-hashmerge.rb
153
+ - test/test-with.rb
153
154
  - test/test-any-and-all.rb
154
155
  - test/test-self.rb
155
156
  - test/test-enumerable-chain.rb