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 04e59c0 Copy-paste error
04e59c0 is described below
commit 04e59c031d96f990d0d31a68ccfd7252c7042442
Author: Sebb <[email protected]>
AuthorDate: Fri Jan 14 01:06:39 2022 +0000
Copy-paste error
More haste less speed
---
lib/whimsy/asf/yaml.rb | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/lib/whimsy/asf/yaml.rb b/lib/whimsy/asf/yaml.rb
index 03eecf5..8f41c4b 100644
--- a/lib/whimsy/asf/yaml.rb
+++ b/lib/whimsy/asf/yaml.rb
@@ -16,14 +16,13 @@ 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)
- 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) || {}
+ if args.empty?
+ yaml = YAML.safe_load(file.read, permitted_classes: [Symbol]) || {}
+ else
+ yaml = YAML.safe_load(file.read, *args) || {}
+ end
file.rewind
file.write YAML.dump(yield yaml)
file.truncate(file.pos)
@@ -101,14 +100,13 @@ 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)
- 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)
+ if args.empty?
+ yaml = YAML.safe_load(file.read, permitted_classes: [Symbol])
+ else
+ yaml = YAML.safe_load(file.read, *args)
+ end
if block_given?
yield yaml
else