From 21bac99122188d3b7852dc67563ac15bbd67ba05 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 16 Oct 2024 16:49:51 +0900 Subject: [PATCH] [ruby/yaml] Make YAML::DBM optional https://github.com/ruby/yaml/commit/f7c44d3fd7 --- lib/yaml/dbm.rb | 8 ++++++-- test/yaml/test_dbm.rb | 2 +- 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)