whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] 02/03: Allow options to be provided (e.g. [Symbol])
Date Sat, 19 Sep 2020 12:48:35 GMT
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

commit 65ccbfb0f62a427dff894e6bab4a52792a828410
Author: Sebb <sebb@apache.org>
AuthorDate: Sat Sep 19 13:13:15 2020 +0100

    Allow options to be provided (e.g. [Symbol])
---
 lib/whimsy/asf/yaml.rb | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/whimsy/asf/yaml.rb b/lib/whimsy/asf/yaml.rb
index a117626..d5f9de9 100644
--- a/lib/whimsy/asf/yaml.rb
+++ b/lib/whimsy/asf/yaml.rb
@@ -13,10 +13,10 @@ module YamlFile
   # opens the file for exclusive access with an exclusive lock
   # Yields the parsed YAML to the block, and writes the updated
   # data to the file
-  def self.update(yaml_file)
+  def self.update(yaml_file, *args)
     File.open(yaml_file, File::RDWR|File::CREAT, 0644) do |file| 
       file.flock(File::LOCK_EX)
-      yaml = YAML.safe_load(file.read) || {} rescue {}
+      yaml = YAML.safe_load(file.read, *args) || {} rescue {}
       yield yaml
       file.rewind
       file.write YAML.dump(yaml)
@@ -29,10 +29,10 @@ module YamlFile
   # Opens the file read-only, with a shared lock, and parses the YAML
   # This is yielded to the block (if provided), whilst holding the lock
   # Otherwise the YAML is returned to the caller, and the lock is released
-  def self.read(yaml_file)
+  def self.read(yaml_file, *args)
     File.open(yaml_file, File::RDONLY) do |file|
       file.flock(File::LOCK_SH)
-      yaml = YAML.safe_load(file.read) || {} rescue {}
+      yaml = YAML.safe_load(file.read,*args) || {} rescue {}
       if block_given?
         yield yaml
       else


Mime
View raw message