Skip to content

Commit

Permalink
Merge pull request #37 from taichi-ishitani/ruby_27_support
Browse files Browse the repository at this point in the history
Fix warnings caused by Ruby 2.7 update
  • Loading branch information
tom-lord authored Jan 9, 2020
2 parents 172a262 + 92829b6 commit 4b89c86
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rvm:
- 2.5.5
- 2.6.2 # Uses unicode 12.0.0
- 2.6.3 # Uses unicode 12.1.0
- 2.7.0
- ruby-head
matrix:
allow_failures:
Expand Down
4 changes: 2 additions & 2 deletions lib/core_extensions/regexp/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ module Regexp
# No core classes are extended in any way, other than the above two methods.
module Examples
def examples(**config_options)
RegexpExamples::Config.with_configuration(config_options) do
RegexpExamples::Config.with_configuration(**config_options) do
examples_by_method(:result)
end
end

def random_example(**config_options)
RegexpExamples::Config.with_configuration(config_options) do
RegexpExamples::Config.with_configuration(**config_options) do
examples_by_method(:random_result).sample
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/regexp-examples/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def with_configuration(**new_config)
original_config = config.dup

begin
self.config = new_config
update_config(**new_config)
result = yield
ensure
self.config = original_config
update_config(**original_config)
end

result
Expand All @@ -48,7 +48,7 @@ def with_configuration(**new_config)

private

def config=(**args)
def update_config(**args)
Thread.current[:regexp_examples_config].merge!(args)
end

Expand Down
1 change: 1 addition & 0 deletions regexp-examples.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'bundler', '> 1.7'
s.add_development_dependency 'rake', '~> 12.0'
s.add_development_dependency 'pry', '~> 0.12.0'
s.add_development_dependency 'warning', '~> 0.10.0'
s.license = 'MIT'
s.required_ruby_version = '>= 2.4.0'
end
3 changes: 2 additions & 1 deletion spec/gem_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
require './lib/regexp-examples.rb'
require 'helpers'
require 'pry'
require 'warning'

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

RSpec.configure do |config|
config.include Helpers
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

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

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

0 comments on commit 4b89c86

Please sign in to comment.