Skip to content

Commit 4b89c86

Browse files
authored
Merge pull request #37 from taichi-ishitani/ruby_27_support
Fix warnings caused by Ruby 2.7 update
2 parents 172a262 + 92829b6 commit 4b89c86

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rvm:
44
- 2.5.5
55
- 2.6.2 # Uses unicode 12.0.0
66
- 2.6.3 # Uses unicode 12.1.0
7+
- 2.7.0
78
- ruby-head
89
matrix:
910
allow_failures:

lib/core_extensions/regexp/examples.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module Regexp
55
# No core classes are extended in any way, other than the above two methods.
66
module Examples
77
def examples(**config_options)
8-
RegexpExamples::Config.with_configuration(config_options) do
8+
RegexpExamples::Config.with_configuration(**config_options) do
99
examples_by_method(:result)
1010
end
1111
end
1212

1313
def random_example(**config_options)
14-
RegexpExamples::Config.with_configuration(config_options) do
14+
RegexpExamples::Config.with_configuration(**config_options) do
1515
examples_by_method(:random_result).sample
1616
end
1717
end

lib/regexp-examples/config.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def with_configuration(**new_config)
2727
original_config = config.dup
2828

2929
begin
30-
self.config = new_config
30+
update_config(**new_config)
3131
result = yield
3232
ensure
33-
self.config = original_config
33+
update_config(**original_config)
3434
end
3535

3636
result
@@ -48,7 +48,7 @@ def with_configuration(**new_config)
4848

4949
private
5050

51-
def config=(**args)
51+
def update_config(**args)
5252
Thread.current[:regexp_examples_config].merge!(args)
5353
end
5454

regexp-examples.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
1717
s.add_development_dependency 'bundler', '> 1.7'
1818
s.add_development_dependency 'rake', '~> 12.0'
1919
s.add_development_dependency 'pry', '~> 0.12.0'
20+
s.add_development_dependency 'warning', '~> 0.10.0'
2021
s.license = 'MIT'
2122
s.required_ruby_version = '>= 2.4.0'
2223
end

spec/gem_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
require './lib/regexp-examples.rb'
77
require 'helpers'
88
require 'pry'
9+
require 'warning'
910

1011
# Several of these tests (intentionally) use "weird" regex patterns,
1112
# that spam annoying warnings when running.
1213
# E.g. warning: invalid back reference: /\k/
1314
# and warning: character class has ']' without escape: /[]]/
1415
# This config disables those warnings.
15-
$VERBOSE = nil
16+
Warning.ignore(//, __dir__)
1617

1718
RSpec.configure do |config|
1819
config.include Helpers

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
# This setting enables warnings. It's recommended, but in some cases may
6767
# be too noisy due to issues in dependencies.
68-
config.warnings = true
68+
config.warnings = false
6969

7070
# Many RSpec users commonly either run the entire suite or an individual
7171
# file, and it's useful to allow more verbose output when running an

0 commit comments

Comments
 (0)