Skip to content

Commit a67b52f

Browse files
committed
- Adjust YAML loading to allow aliases in Ruby 3.1
1 parent 4d7c05b commit a67b52f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/bashly.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
requires 'bashly/concerns'
99

10+
requires 'bashly/extensions'
1011
requires 'bashly/settings'
1112
requires 'bashly/exceptions'
1213
requires 'bashly/refinements'

lib/bashly/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Config
1010

1111
def self.new(config)
1212
if config.is_a? String
13-
YAML.load_file(config).compose
13+
YAML.properly_load_file(config).compose
1414
else
1515
config
1616
end

lib/bashly/extensions/yaml.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module YAML
2+
# This awkward patch is due to https://bugs.ruby-lang.org/issues/17866
3+
def self.properly_load_file(path)
4+
YAML.load_file path, aliases: true
5+
rescue ArgumentError
6+
YAML.load_file path
7+
end
8+
end

0 commit comments

Comments
 (0)