[ruby/yaml] Make PStore support as optional

https://github.com/ruby/yaml/commit/da421ce46f
This commit is contained in:
Hiroshi SHIBATA 2024-01-31 11:01:31 +09:00 committed by git
parent 7c8f9603b1
commit 3de2ab7fdb
2 changed files with 7 additions and 3 deletions

View File

@ -3,7 +3,11 @@
# YAML::Store # YAML::Store
# #
require 'yaml' require 'yaml'
require 'pstore'
begin
require 'pstore'
rescue LoadError
end
# YAML::Store provides the same functionality as PStore, except it uses YAML # YAML::Store provides the same functionality as PStore, except it uses YAML
# to dump objects instead of Marshal. # to dump objects instead of Marshal.
@ -83,4 +87,4 @@ class YAML::Store < PStore
def empty_marshal_checksum def empty_marshal_checksum
CHECKSUM_ALGO.digest(empty_marshal_data) CHECKSUM_ALGO.digest(empty_marshal_data)
end end
end end if defined?(::PStore)

View File

@ -177,4 +177,4 @@ class YAMLStoreTest < Test::Unit::TestCase
end end
assert_equal(indentation_3_yaml, File.read(@yaml_store_file), bug12800) assert_equal(indentation_3_yaml, File.read(@yaml_store_file), bug12800)
end end
end end if defined?(::YAML::Store)