This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new c828dd8 Oops, wrong fix here
c828dd8 is described below
commit c828dd8321b333f587e60a730efdff5c5fc4b7b3
Author: Sebb <[email protected]>
AuthorDate: Fri Jan 14 00:49:18 2022 +0000
Oops, wrong fix here
---
lib/whimsy/asf/yaml.rb | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/whimsy/asf/yaml.rb b/lib/whimsy/asf/yaml.rb
index 6ba2376..03eecf5 100644
--- a/lib/whimsy/asf/yaml.rb
+++ b/lib/whimsy/asf/yaml.rb
@@ -16,7 +16,11 @@ module YamlFile
# data to the file
# The args are passed to YAML.safe_load, and default to permitted_classes:
[Symbol]
def self.update(yaml_file, *args)
- args << permitted_classes: [Symbol] if args.empty?
+ if args.empty?
+ yaml = YAML.safe_load(content, permitted_classes: [Symbol])
+ else
+ yaml = YAML.safe_load(content, *args)
+ end
File.open(yaml_file, File::RDWR|File::CREAT, 0o644) do |file|
file.flock(File::LOCK_EX)
yaml = YAML.safe_load(file.read, *args) || {}
@@ -36,8 +40,11 @@ module YamlFile
def self.replace_section(content, key, *args)
raise ArgumentError, 'block is required' unless block_given?
- args << permitted_classes: [Symbol] if args.empty?
- yaml = YAML.safe_load(content, *args)
+ if args.empty?
+ yaml = YAML.safe_load(content, permitted_classes: [Symbol])
+ else
+ yaml = YAML.safe_load(content, *args)
+ end
section = yaml[key]
unless section
@@ -94,7 +101,11 @@ module YamlFile
# Otherwise the YAML is returned to the caller, and the lock is released
# The args are passed to YAML.safe_load, and default to permitted_classes:
[Symbol]
def self.read(yaml_file, *args)
- args << permitted_classes: [Symbol] if args.empty?
+ if args.empty?
+ yaml = YAML.safe_load(content, permitted_classes: [Symbol])
+ else
+ yaml = YAML.safe_load(content, *args)
+ end
File.open(yaml_file, File::RDONLY) do |file|
file.flock(File::LOCK_SH)
yaml = YAML.safe_load(file.read, *args)