Blame SOURCES/ruby-2.5.0-Add-Gem.operating_system_defaults.patch

e076ba
From 60eb961c25f801ee43ca1be9393ab2f0a0546677 Mon Sep 17 00:00:00 2001
e076ba
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
e076ba
Date: Tue, 19 Dec 2017 14:00:20 +0100
e076ba
Subject: [PATCH] Add Gem.operating_system_defaults to allow packagers to
e076ba
 override defaults.
e076ba
e076ba
This change allows Ruby packagers to override defaults and lazily query
e076ba
them.
e076ba
e076ba
This is very much the same change as #1644 to treat the
e076ba
operating_system defaults the same way as platform defaults.
e076ba
---
e076ba
 lib/rubygems/config_file.rb |  2 +-
e076ba
 lib/rubygems/defaults.rb    | 21 ++++++++++++++++++++-
e076ba
 test/rubygems/test_gem.rb   |  7 +++++++
e076ba
 3 files changed, 28 insertions(+), 2 deletions(-)
e076ba
e076ba
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
e076ba
index a4efed0f5a..deee38e6d9 100644
e076ba
--- a/lib/rubygems/config_file.rb
e076ba
+++ b/lib/rubygems/config_file.rb
e076ba
@@ -48,7 +48,7 @@ class Gem::ConfigFile
e076ba
   # For Ruby packagers to set configuration defaults.  Set in
e076ba
   # rubygems/defaults/operating_system.rb
e076ba
 
e076ba
-  OPERATING_SYSTEM_DEFAULTS = {}
e076ba
+  OPERATING_SYSTEM_DEFAULTS = Gem.operating_system_defaults
e076ba
 
e076ba
   ##
e076ba
   # For Ruby implementers to set configuration defaults.  Set in
e076ba
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
e076ba
index 43d57fc808..b8222877ae 100644
e076ba
--- a/lib/rubygems/defaults.rb
e076ba
+++ b/lib/rubygems/defaults.rb
e076ba
@@ -177,7 +177,26 @@ def self.vendor_dir # :nodoc:
e076ba
   end
e076ba
 
e076ba
   ##
e076ba
-  # Default options for gem commands.
e076ba
+  # Default options for gem commands for Ruby packagers.
e076ba
+  #
e076ba
+  # The options here should be structured as an array of string "gem"
e076ba
+  # command names as keys and a string of the default options as values.
e076ba
+  #
e076ba
+  # Example:
e076ba
+  #
e076ba
+  # def self.operating_system_defaults
e076ba
+  #   {
e076ba
+  #       'install' => '--no-rdoc --no-ri --env-shebang',
e076ba
+  #       'update' => '--no-rdoc --no-ri --env-shebang'
e076ba
+  #   }
e076ba
+  # end
e076ba
+
e076ba
+  def self.operating_system_defaults
e076ba
+    {}
e076ba
+  end
e076ba
+
e076ba
+  ##
e076ba
+  # Default options for gem commands for Ruby implementers.
e076ba
   #
e076ba
   # The options here should be structured as an array of string "gem"
e076ba
   # command names as keys and a string of the default options as values.
e076ba
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
e076ba
index 3225a05c6b..62b80c4945 100644
e076ba
--- a/test/rubygems/test_gem.rb
e076ba
+++ b/test/rubygems/test_gem.rb
e076ba
@@ -1802,6 +1802,13 @@ def test_use_gemdeps_specific
e076ba
     ENV['RUBYGEMS_GEMDEPS'] = rubygems_gemdeps
e076ba
   end
e076ba
 
e076ba
+  def test_operating_system_defaults
e076ba
+    operating_system_defaults = Gem.operating_system_defaults
e076ba
+
e076ba
+    assert operating_system_defaults != nil
e076ba
+    assert operating_system_defaults.is_a? Hash
e076ba
+  end
e076ba
+
e076ba
   def test_platform_defaults
e076ba
     platform_defaults = Gem.platform_defaults
e076ba