summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-05 23:02:00 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-05 23:02:00 +0000
commit6e48ce9c116a799ac94b63ae486427606e40fbaf (patch)
tree02ec37a173d6b9230a0a7542c848e347c4ddfc3e /lib
parent7a88ad0a42dffdbbcaf0192635ab64c636294cf6 (diff)
* lib/rubygems.rb: Allow specification of directory permissions.
[ruby-trunk - Bug #7713] * test/rubygems/test_gem.rb: Test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index ac992d09d6..80e6a1ff74 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -375,20 +375,28 @@ module Gem
end
##
- # Quietly ensure the named Gem directory contains all the proper
+ # Quietly ensure the Gem directory +dir+ contains all the proper
# subdirectories. If we can't create a directory due to a permission
# problem, then we will silently continue.
+ #
+ # If +mode+ is given, missing directories are created with this mode.
+ #
+ # World-writable directories will never be created.
- def self.ensure_gem_subdirectories dir = Gem.dir
+ def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil
old_umask = File.umask
File.umask old_umask | 002
require 'fileutils'
+ options = {}
+
+ options[:mode] = mode if mode
+
REPOSITORY_SUBDIRECTORIES.each do |name|
subdir = File.join dir, name
next if File.exist? subdir
- FileUtils.mkdir_p subdir rescue nil # in case of perms issues -- lame
+ FileUtils.mkdir_p subdir, options rescue nil
end
ensure
File.umask old_umask