summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2024-10-16 16:49:51 +0900
committerHiroshi SHIBATA <[email protected]>2024-10-16 17:04:37 +0900
commit21bac99122188d3b7852dc67563ac15bbd67ba05 (patch)
treef8c5c731f106dd4b7014ccca7600428f28e56dbc
parent1d7547f50d1187f49b5cfec627425e657cdaf9af (diff)
[ruby/yaml] Make YAML::DBM optional
https://github.com/ruby/yaml/commit/f7c44d3fd7
-rw-r--r--lib/yaml/dbm.rb8
-rw-r--r--test/yaml/test_dbm.rb2
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/yaml/dbm.rb b/lib/yaml/dbm.rb
index 126d72dd4d..a3cbaeccf6 100644
--- a/lib/yaml/dbm.rb
+++ b/lib/yaml/dbm.rb
@@ -1,6 +1,10 @@
# frozen_string_literal: false
require 'yaml'
-require 'dbm'
+
+begin
+ require 'dbm'
+rescue LoadError
+end
module YAML
@@ -288,4 +292,4 @@ class DBM < ::DBM
alias :each :each_pair
end
-end
+end if defined?(DBM)
diff --git a/test/yaml/test_dbm.rb b/test/yaml/test_dbm.rb
index 15d441d23b..cf50256298 100644
--- a/test/yaml/test_dbm.rb
+++ b/test/yaml/test_dbm.rb
@@ -43,4 +43,4 @@ class TestYAMLDBM < Test::Unit::TestCase
@dbm["key"] = "value"
assert_equal ["key", "value"], @dbm.shift
end
-end \ No newline at end of file
+end if defined?(YAML::DBM)