nuggets 1.6.0 → 1.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dad45b4d4a9ccf28b262ca7b38cb728d04fcbc03cd9ba1d761ac40bded7ce1db
4
- data.tar.gz: a35c07426a38a092e2a6159f961574d9fd25a55d9b36e639807397b0c2baa877
3
+ metadata.gz: 1918bdc23725b5833549da651c379edda6a6e070753571e0037e7a7147be67ca
4
+ data.tar.gz: e48e2395d1366f14bfba167be73e36a4f2050ea64419918eca3b1f095d0fb37c
5
5
  SHA512:
6
- metadata.gz: a603785020efbd4ac9e8fb45c95207527f8e02857b76bf0cd201559169c1ea49a41a8e5ae7e5bfe1d48419eff6e72b95a8699c1ffcf49bb28b797881ebbc32f8
7
- data.tar.gz: 3c16dbd738a21dc8ace62e6916e603fec2853b947c54753033e18d47f8379dcbafaa9f838e69dd48153136907815232a46a7281610bd5f239da47e826b730869
6
+ metadata.gz: 6719bf7667073a9bb9eb8c6f667a1715ebce7dff48b4cc4d514dbfbb6a245fafbfe3101a4f6426cb96e9820b072c8431d5b88c8f51a8201c143166eb65be4daf
7
+ data.tar.gz: de3a4dad5dcd6e5d238c92ea95ee4d4964c79c10df4b634c0b533e2e7f93e7107516c3d147c856dccb40f556911791b11b515c4ce427c6dd8f256036b5bd7c91
data/ChangeLog CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  = Revision history for nuggets
4
4
 
5
+ == 1.6.1 [2022-05-18]
6
+
7
+ * Ruby 3.1 compatibility.
8
+
5
9
  == 1.6.0 [2018-07-12]
6
10
 
7
11
  * Added <tt>JSON.*_{multi,canonical}</tt>.
data/README CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to nuggets version 1.6.0.
5
+ This documentation refers to nuggets version 1.6.1.
6
6
 
7
7
 
8
8
  == DESCRIPTION
9
9
 
10
10
  Nuggets provides a collection of extensions to Ruby classes.
11
- It's similar to projects like Facets[http://rubyworks.github.com/facets]
11
+ It's similar to projects like Facets[https://rubyworks.github.io/facets]
12
12
  and Extensions[http://extensions.rubyforge.org] (or even
13
13
  Labrador[http://labrador.rubyforge.org]).
14
14
 
@@ -45,7 +45,7 @@ expected or cause other libraries to misbehave. Use at your own risk!
45
45
 
46
46
  == LINKS
47
47
 
48
- Documentation:: https://blackwinter.github.com/nuggets
48
+ Documentation:: https://blackwinter.github.io/nuggets
49
49
  Source code:: https://github.com/blackwinter/nuggets
50
50
  RubyGem:: https://rubygems.org/gems/nuggets
51
51
  Travis CI:: https://travis-ci.org/blackwinter/nuggets
@@ -58,7 +58,7 @@ Travis CI:: https://travis-ci.org/blackwinter/nuggets
58
58
 
59
59
  == LICENSE AND COPYRIGHT
60
60
 
61
- Copyright (C) 2007-2018 Jens Wille
61
+ Copyright (C) 2007-2022 Jens Wille
62
62
 
63
63
  nuggets is free software: you can redistribute it and/or modify it
64
64
  under the terms of the GNU Affero General Public License as published by
@@ -39,9 +39,9 @@ module Nuggets
39
39
  #
40
40
  # Calls String#sub! on file +name+'s contents with +args+ and (optional)
41
41
  # +block+ and returns the new content.
42
- def sub(name, *args)
42
+ def sub(name, *args, &block)
43
43
  content = read(name)
44
- content.sub!(*args, &block_given? ? ::Proc.new : nil)
44
+ content.sub!(*args, &block)
45
45
  content
46
46
  end
47
47
 
@@ -51,11 +51,11 @@ module Nuggets
51
51
  # Calls String#sub! on file +name+'s contents with +args+ and (optional)
52
52
  # +block+ and replaces the file with the new content. Returns the result
53
53
  # of the String#sub! call.
54
- def sub!(name, *args)
54
+ def sub!(name, *args, &block)
55
55
  res = nil
56
56
 
57
57
  replace(name) { |content|
58
- res = content.sub!(*args, &block_given? ? ::Proc.new : nil)
58
+ res = content.sub!(*args, &block)
59
59
  content
60
60
  }
61
61
 
@@ -67,9 +67,9 @@ module Nuggets
67
67
  #
68
68
  # Calls String#gsub! on file +name+'s contents with +args+ and (optional)
69
69
  # +block+ and returns the new content.
70
- def gsub(name, *args)
70
+ def gsub(name, *args, &block)
71
71
  content = read(name)
72
- content.gsub!(*args, &block_given? ? ::Proc.new : nil)
72
+ content.gsub!(*args, &block)
73
73
  content
74
74
  end
75
75
 
@@ -79,11 +79,11 @@ module Nuggets
79
79
  # Calls String#gsub! on file +name+'s contents with +args+ and (optional)
80
80
  # +block+ and replaces the file with the new content. Returns the result
81
81
  # of the String#gsub! call.
82
- def gsub!(name, *args)
82
+ def gsub!(name, *args, &block)
83
83
  res = nil
84
84
 
85
85
  replace(name) { |content|
86
- res = content.gsub!(*args, &block_given? ? ::Proc.new : nil)
86
+ res = content.gsub!(*args, &block)
87
87
  content
88
88
  }
89
89
 
@@ -49,11 +49,11 @@ module Nuggets
49
49
  # hash[:foo][:bar][:b] = { x: 0, y: 3 }
50
50
  # hash
51
51
  # #=> {:foo=>{:bar=>{:b=>{:y=>3, :x=>0}, :a=>{:y=>2, :x=>1}}}}
52
- def nest(depth = 0, value = default = true)
52
+ def nest(depth = 0, value = default = true, &block)
53
53
  if depth.zero?
54
54
  if default
55
55
  if block_given?
56
- new { |hash, key| hash[key] = yield(key) }
56
+ new { |hash, key| hash[key] = block[key] }
57
57
  else
58
58
  new { |hash, key| hash[key] = hash.default }
59
59
  end
@@ -62,11 +62,7 @@ module Nuggets
62
62
  end
63
63
  else
64
64
  if default
65
- if block_given?
66
- new { |hash, key| hash[key] = nest(depth - 1, &::Proc.new) }
67
- else
68
- new { |hash, key| hash[key] = nest(depth - 1) }
69
- end
65
+ new { |hash, key| hash[key] = nest(depth - 1, &block) }
70
66
  else
71
67
  new { |hash, key| hash[key] = nest(depth - 1, value) }
72
68
  end
@@ -38,8 +38,8 @@ class IO
38
38
  #
39
39
  # Opens +name+ with mode +r+. NOTE: With no associated block,
40
40
  # acts like the original IO::read, not like IO::new.
41
- def read(name, *args)
42
- return _nuggets_original_read(name, *args) unless block_given?
41
+ def read(name, *args, **opts, &block)
42
+ return _nuggets_original_read(name, *args, **opts) unless block_given?
43
43
 
44
44
  case args.size
45
45
  when 0
@@ -55,7 +55,7 @@ class IO
55
55
  raise ::ArgumentError, "wrong number of arguments (#{args.size + 1} for 1-2)"
56
56
  end
57
57
 
58
- open_with_mode(name, 'r', binary, &::Proc.new)
58
+ open_with_mode(name, 'r', binary, &block)
59
59
  end
60
60
 
61
61
  # call-seq:
@@ -63,8 +63,8 @@ class IO
63
63
  # IO.write(name[, binary]) { |io| ... } => anObject
64
64
  #
65
65
  # Opens +name+ with mode +w+.
66
- def write(name, binary = false)
67
- open_with_mode(name, 'w', binary, &block_given? ? ::Proc.new : nil)
66
+ def write(name, binary = false, &block)
67
+ open_with_mode(name, 'w', binary, &block)
68
68
  end
69
69
 
70
70
  # call-seq:
@@ -72,8 +72,8 @@ class IO
72
72
  # IO.append(name[, binary]) { |io| ... } => anObject
73
73
  #
74
74
  # Opens +name+ with mode +a+.
75
- def append(name, binary = false)
76
- open_with_mode(name, 'a', binary, &block_given? ? ::Proc.new : nil)
75
+ def append(name, binary = false, &block)
76
+ open_with_mode(name, 'a', binary, &block)
77
77
  end
78
78
 
79
79
  # call-seq:
@@ -81,8 +81,8 @@ class IO
81
81
  # IO.read_write(name[, binary]) { |io| ... } => anObject
82
82
  #
83
83
  # Opens +name+ with mode <tt>r+</tt>.
84
- def read_write(name, binary = false)
85
- open_with_mode(name, 'r+', binary, &block_given? ? ::Proc.new : nil)
84
+ def read_write(name, binary = false, &block)
85
+ open_with_mode(name, 'r+', binary, &block)
86
86
  end
87
87
 
88
88
  # call-seq:
@@ -90,8 +90,8 @@ class IO
90
90
  # IO.write_read(name[, binary]) { |io| ... } => anObject
91
91
  #
92
92
  # Opens +name+ with mode <tt>w+</tt>.
93
- def write_read(name, binary = false)
94
- open_with_mode(name, 'w+', binary, &block_given? ? ::Proc.new : nil)
93
+ def write_read(name, binary = false, &block)
94
+ open_with_mode(name, 'w+', binary, &block)
95
95
  end
96
96
 
97
97
  # call-seq:
@@ -99,15 +99,15 @@ class IO
99
99
  # IO.append_read(name[, binary]) { |io| ... } => anObject
100
100
  #
101
101
  # Opens +name+ with mode <tt>a+</tt>.
102
- def append_read(name, binary = false)
103
- open_with_mode(name, 'a+', binary, &block_given? ? ::Proc.new : nil)
102
+ def append_read(name, binary = false, &block)
103
+ open_with_mode(name, 'a+', binary, &block)
104
104
  end
105
105
 
106
106
  private
107
107
 
108
108
  # Just a helper to DRY things up.
109
- def open_with_mode(name, mode, binary = false)
110
- open(name, "#{mode}#{'b' if binary}", &block_given? ? ::Proc.new : nil)
109
+ def open_with_mode(name, mode, binary = false, &block)
110
+ open(name, "#{mode}#{'b' if binary}", &block)
111
111
  end
112
112
 
113
113
  end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 6
7
- TINY = 0
7
+ TINY = 1
8
8
 
9
9
  class << self
10
10
 
@@ -7,7 +7,7 @@ describe Enumerable, 'minmax' do
7
7
 
8
8
  e.max.should == 'quux'
9
9
  e.max_by(:length).should == 'quuux'
10
- e.max(:length).should == 5 if RUBY_VERSION < '2.4'
10
+ e.max(:length).should == 5 if RUBY_VERSION < '2.4' && RUBY_ENGINE != 'jruby'
11
11
  }
12
12
 
13
13
  example {
@@ -15,7 +15,7 @@ describe Enumerable, 'minmax' do
15
15
 
16
16
  e.max.should == 222
17
17
  e.max_by(b).should == 45
18
- e.max(b).should == 5 if RUBY_VERSION < '2.4'
18
+ e.max(b).should == 5 if RUBY_VERSION < '2.4' && RUBY_ENGINE != 'jruby'
19
19
  }
20
20
 
21
21
  end
@@ -52,7 +52,7 @@ describe_extended JSON, Nuggets::JSON::MultiMixin, true do
52
52
  example { expect(subject.size).to eq(3) }
53
53
  example { expect(subject.keys).to eq(%w[a b a]) }
54
54
 
55
- example { expect(subject['a']).to eq(1) }
55
+ example { expect(subject['a']).to eq(1) } unless RUBY_ENGINE == 'jruby'
56
56
  example { expect(subject['b']).to eq([42, 23]) }
57
57
 
58
58
  example { expect(multi[0]).to eq(1) }
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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-12 00:00:00.000000000 Z
11
+ date: 2022-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '0.9'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 0.9.0
50
+ version: 0.9.1
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '0.9'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.9.0
60
+ version: 0.9.1
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -364,13 +364,13 @@ licenses:
364
364
  metadata: {}
365
365
  post_install_message: |2+
366
366
 
367
- nuggets-1.6.0 [2018-07-12]:
367
+ nuggets-1.6.1 [2022-05-18]:
368
368
 
369
- * Added <tt>JSON.*_{multi,canonical}</tt>.
369
+ * Ruby 3.1 compatibility.
370
370
 
371
371
  rdoc_options:
372
372
  - "--title"
373
- - nuggets Application documentation (v1.6.0)
373
+ - nuggets Application documentation (v1.6.1)
374
374
  - "--charset"
375
375
  - UTF-8
376
376
  - "--line-numbers"
@@ -390,9 +390,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
390
  - !ruby/object:Gem::Version
391
391
  version: '0'
392
392
  requirements: []
393
- rubyforge_project:
394
- rubygems_version: 2.7.7
395
- signing_key:
393
+ rubygems_version: 3.2.5
394
+ signing_key:
396
395
  specification_version: 4
397
396
  summary: Extending Ruby.
398
397
  test_files: []
398
+ ...