Skip to content

Commit 53aa864

Browse files
authored
Merge pull request #195 from DannyBen/add/ruby-3.1-support
Ruby 3.1 adjustments
2 parents 9879b75 + a7e3db3 commit 53aa864

File tree

9 files changed

+17
-8
lines changed

9 files changed

+17
-8
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
LC_ALL: en_US.UTF-8 # consistent sort order
1414

1515
strategy:
16-
matrix: { ruby: ['2.7', '3.0'] }
16+
matrix: { ruby: ['2.7', '3.0', '3.1'] }
1717

1818
steps:
1919
- name: Checkout code

helpers/example.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def initialize(dir)
2121
end
2222

2323
def config
24-
@config ||= YAML.load_file(yaml_path)
24+
@config ||= YAML.properly_load_file(yaml_path)
2525
end
2626

2727
def yaml

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

lib/bashly/library.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def exist?(name)
66
end
77

88
def config
9-
@config ||= YAML.load_file(config_path)
9+
@config ||= YAML.properly_load_file(config_path)
1010
end
1111

1212
def config_path

lib/bashly/message_strings.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def values
1313
private
1414

1515
def values!
16-
defaults = YAML.load_file asset("templates/strings.yml")
16+
defaults = YAML.properly_load_file asset("templates/strings.yml")
1717
defaults.merge project_strings
1818
end
1919

@@ -23,7 +23,7 @@ def project_strings
2323

2424
def project_strings!
2525
if File.exist? project_strings_path
26-
YAML.load_file project_strings_path
26+
YAML.properly_load_file project_strings_path
2727
else
2828
{}
2929
end

lib/bashly/refinements/compose_refinements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def compose(keyword = 'import')
2222
end
2323

2424
def safe_load_yaml(path)
25-
loaded = YAML.load_file path
25+
loaded = YAML.properly_load_file path
2626
return loaded if loaded.is_a? Array or loaded.is_a? Hash
2727
raise Bashly::ConfigurationError, "Cannot find a valid YAML in !txtgrn!#{path}"
2828

spec/spec_mixin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ def reset_tmp_dir(create_src: false, copy_from: nil)
88

99
def load_fixture(filename)
1010
@loaded_fixtures ||= {}
11-
@loaded_fixtures[filename] ||= YAML.load_file("spec/fixtures/#{filename}.yml")
11+
@loaded_fixtures[filename] ||= YAML.properly_load_file("spec/fixtures/#{filename}.yml")
1212
end
1313
end

0 commit comments

Comments
 (0)