From 802432861d238b4d7d3f2ea4ae030047218956ff Mon Sep 17 00:00:00 2001 From: Clayton Parker Date: Wed, 6 Mar 2024 09:50:59 -0500 Subject: [PATCH] fix for yaml regex in ruby 3 --- lib/augury/cli.rb | 4 +++- spec/fixtures/transforms.yml | 4 ++++ spec/lib/augury/cli_spec.rb | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/transforms.yml diff --git a/lib/augury/cli.rb b/lib/augury/cli.rb index ae1a3bc..458704d 100644 --- a/lib/augury/cli.rb +++ b/lib/augury/cli.rb @@ -86,7 +86,9 @@ def options config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml')) if File.file?(config_path) - config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {}) + config_options = Thor::CoreExt::HashWithIndifferentAccess.new( + YAML.load_file(config_path, permitted_classes: [Regexp]) || {}, + ) defaults = defaults.merge(config_options) end diff --git a/spec/fixtures/transforms.yml b/spec/fixtures/transforms.yml new file mode 100644 index 0000000..2834f8f --- /dev/null +++ b/spec/fixtures/transforms.yml @@ -0,0 +1,4 @@ +global-transforms: + - + - !ruby/regexp /(hello)/i + - "\\1 world" diff --git a/spec/lib/augury/cli_spec.rb b/spec/lib/augury/cli_spec.rb index 53683a7..509d759 100644 --- a/spec/lib/augury/cli_spec.rb +++ b/spec/lib/augury/cli_spec.rb @@ -83,5 +83,14 @@ }, ) end + + it 'allows regex in transforms' do + ENV['AUGURY_CFG_PATH'] = 'spec/fixtures/transforms.yml' + expect(subject.send(:options)).to include( + { + 'global-transforms' => [[/(hello)/i, '\\1 world']], + }, + ) + end end end