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