Skip to content

Commit

Permalink
fix for yaml regex in ruby 3
Browse files Browse the repository at this point in the history
  • Loading branch information
claytron committed Mar 6, 2024
1 parent 2f2f129 commit 8024328
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/augury/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/transforms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
global-transforms:
-
- !ruby/regexp /(hello)/i
- "\\1 world"
9 changes: 9 additions & 0 deletions spec/lib/augury/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8024328

Please sign in to comment.