attr_extras 6.2.3 → 6.2.4

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: 8de2d9f5a942529a96ff782dae5d6cc8ed15136ca0a8b9a5bdab353a96b58ed1
4
- data.tar.gz: 1b12b6151ac7c28bc78ab6637a7fe25c12842079dcea32075fba8a2176c6bd13
3
+ metadata.gz: e4f8e12f94bbc166632e1a65a52f83ddc14e4982ad57f87043fa285e7e7a8cf2
4
+ data.tar.gz: 1d621e46616f5df763909d9481f983d60fe4e014a8a9a3b0dbfc2635d8867d71
5
5
  SHA512:
6
- metadata.gz: c953ecbac9eadca7fc324a37af2360de9d9d6740b3ed28f3fa2c76cb45a44479e7d0d05f77c2087451167759e42a87b7d414cab19ad5ac3c72f077d797fdffcf
7
- data.tar.gz: 36723de91da1c0e754a5c20ee76238d23944f1cc15789fd5482ccccfa8798cf3cbd679d381c81932ae8427fe6e4e7ff05ebe00496cd36c32f2c0c8e1fa86dd30
6
+ metadata.gz: 44cade5ed299c18a1e8c01706e04767f1b49f3a934a53759542702fd6435c8ba225b360250dd276a78174fdea32e112ca1155cf20e172db765940ea05ecb3b03
7
+ data.tar.gz: 7fe165a6de71503666cb3344478c769385d50a31ca11de78cce7f934d87393867a5e2c3bc05703c7a3fdc86dd81da729703452c35d0999600f70b42a35851629
@@ -1,10 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.7.0
4
- - 2.6.5
5
- - 2.5.7
6
- - 2.4.9
3
+ - 2.7.1
4
+ - 2.6.6
5
+ - 2.5.8
7
6
  - jruby-head
8
- before_install: # For jruby-head to work.
9
- - gem install bundler
10
- - gem update bundler
@@ -1,30 +1,34 @@
1
1
  # Changelog
2
2
 
3
- # 6.2.3
3
+ ## [6.2.4](https://github.com/barsoom/attr_extras/releases/tag/v6.2.4)
4
+
5
+ - Fix keyword argument warnings with Ruby 2.7. Thanks to [Elliot Winkler](https://github.com/barsoom/attr_extras/pull/34)!
6
+
7
+ ## [6.2.3](https://github.com/barsoom/attr_extras/releases/tag/v6.2.3)
4
8
 
5
9
  - `attr_implement` error says "an 'ear()' method" instead of "a 'ear()' method", when the method starts with a likely vowel.
6
10
 
7
- # 6.2.2
11
+ ## [6.2.2](https://github.com/barsoom/attr_extras/releases/tag/v6.2.2)
8
12
 
9
13
  - Fix warnings with Ruby 2.7. Thanks to [Juanito Fatas](https://github.com/barsoom/attr_extras/pull/31)!
10
14
  - Fix deprecation warnings for Minitest 6. Thanks again to [Juanito Fatas](https://github.com/barsoom/attr_extras/pull/30)!
11
15
 
12
- # 6.2.1
16
+ ## [6.2.1](https://github.com/barsoom/attr_extras/releases/tag/v6.2.1)
13
17
 
14
18
  * Bugfix with keyword argument defaults. Thanks to [Roman Dubrovsky](https://github.com/barsoom/attr_extras/pull/29)!
15
19
 
16
- # 6.2.0
20
+ ## [6.2.0](https://github.com/barsoom/attr_extras/releases/tag/v6.2.0)
17
21
 
18
22
  * Another bugfix when passing hash values to positional arguments.
19
23
 
20
- # 6.1.0
24
+ ## [6.1.0](https://github.com/barsoom/attr_extras/releases/tag/v6.1.0)
21
25
 
22
26
  * Bugfix when passing hash values to positional arguments.
23
27
 
24
- # 6.0.0 (yanked)
28
+ ## 6.0.0 (yanked)
25
29
 
26
30
  * Default arguments! Thanks to [Ola K](https://github.com/lesin). For example: `pattr_initialize [:foo, bar: "default value"]`
27
31
 
28
- # 5.2.0 and earlier
32
+ ## [5.2.0](https://github.com/barsoom/attr_extras/releases/tag/v5.2.0) and earlier
29
33
 
30
34
  Please [see Git history](https://github.com/barsoom/attr_extras/releases).
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/attr_extras.svg)](https://badge.fury.io/rb/attr_extras)
1
2
  [![Build status](https://secure.travis-ci.org/barsoom/attr_extras.svg)](https://travis-ci.org/#!/barsoom/attr_extras/builds)
2
3
  [![Code Climate](https://codeclimate.com/github/barsoom/attr_extras/badges/gpa.svg)](https://codeclimate.com/github/barsoom/attr_extras)
3
4
 
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = AttrExtras::VERSION
17
17
 
18
18
  gem.add_development_dependency "minitest", ">= 5"
19
- gem.add_development_dependency "m", "~> 1.5.0" # Running individual tests.
19
+ gem.add_development_dependency "m", "~> 1.5.1" # Running individual tests.
20
20
 
21
21
  # For Travis CI.
22
22
  gem.add_development_dependency "rake"
@@ -61,9 +61,17 @@ module AttrExtras
61
61
  alias_method :attr_accessor_initialize, :aattr_initialize
62
62
 
63
63
  def static_facade(method_name_or_names, *names)
64
- Array(method_name_or_names).each do |method_name|
65
- define_singleton_method(method_name) do |*values, &block|
66
- new(*values).public_send(method_name, &block)
64
+ if names.any? { |name| name.is_a?(Array) }
65
+ Array(method_name_or_names).each do |method_name|
66
+ define_singleton_method(method_name) do |*args, **opts, &block|
67
+ new(*args, **opts).public_send(method_name, &block)
68
+ end
69
+ end
70
+ else
71
+ Array(method_name_or_names).each do |method_name|
72
+ define_singleton_method(method_name) do |*args, &block|
73
+ new(*args).public_send(method_name, &block)
74
+ end
67
75
  end
68
76
  end
69
77
 
@@ -1,3 +1,3 @@
1
1
  module AttrExtras
2
- VERSION = "6.2.3"
2
+ VERSION = "6.2.4"
3
3
  end
@@ -56,4 +56,34 @@ describe Object, ".static_facade" do
56
56
 
57
57
  assert klass.foo { :bar } == :bar
58
58
  end
59
+
60
+ it "does not blow up when the class method is called with an empty hash" do
61
+ klass = Class.new do
62
+ static_facade :foo,
63
+ :value
64
+
65
+ def foo
66
+ end
67
+ end
68
+
69
+ refute_raises_anything { klass.foo({}) }
70
+ end
71
+
72
+ it "does not emit warnings when the initializer is overridden with more keyword arguments" do
73
+ superklass = Class.new do
74
+ static_facade :something, [ :foo!, :bar! ]
75
+
76
+ def something
77
+ end
78
+ end
79
+
80
+ klass = Class.new(superklass) do
81
+ def initialize(extra:, **rest)
82
+ super(**rest)
83
+ @extra = extra
84
+ end
85
+ end
86
+
87
+ refute_warnings_emitted { klass.something(foo: 1, bar: 2, extra: "yay") }
88
+ end
59
89
  end
@@ -2,3 +2,20 @@ require "minitest/autorun"
2
2
  require "minitest/pride"
3
3
 
4
4
  $: << File.dirname(__FILE__) + "/../lib"
5
+
6
+ Minitest::Test.class_eval do
7
+ def refute_warnings_emitted(&block)
8
+ _, stderr = capture_io(&block)
9
+
10
+ assert stderr.empty?, -> do
11
+ warnings = stderr.strip.split("\n").map { |line| " #{line}" }.join("\n")
12
+ "Expected no warnings to be emitted, but these ones were:\n\n#{warnings}"
13
+ end
14
+ end
15
+
16
+ def refute_raises_anything
17
+ yield
18
+ rescue => error
19
+ flunk "Expected no error to be raised, but got #{error.class} (#{error.message})."
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.3
4
+ version: 6.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-01-25 00:00:00.000000000 Z
15
+ date: 2020-06-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: minitest
@@ -34,14 +34,14 @@ dependencies:
34
34
  requirements:
35
35
  - - "~>"
36
36
  - !ruby/object:Gem::Version
37
- version: 1.5.0
37
+ version: 1.5.1
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - "~>"
43
43
  - !ruby/object:Gem::Version
44
- version: 1.5.0
44
+ version: 1.5.1
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: rake
47
47
  requirement: !ruby/object:Gem::Requirement
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.0.3
121
+ rubygems_version: 3.1.2
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Takes some boilerplate out of Ruby with methods like attr_initialize.