pvalena / rpms / ruby

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