1module Gem 2 DEFAULT_HOST = "https://rubygems.org" 3 4 @post_install_hooks ||= [] 5 @done_installing_hooks ||= [] 6 @post_uninstall_hooks ||= [] 7 @pre_uninstall_hooks ||= [] 8 @pre_install_hooks ||= [] 9 10 ## 11 # An Array of the default sources that come with RubyGems 12 13 def self.default_sources 14 %w[https://rubygems.org/] 15 end 16 17 ## 18 # Default home directory path to be used if an alternate value is not 19 # specified in the environment 20 21 def self.default_dir 22 path = if defined? RUBY_FRAMEWORK_VERSION then 23 [ 24 File.dirname(ConfigMap[:sitedir]), 25 'Gems', 26 ConfigMap[:ruby_version] 27 ] 28 elsif ConfigMap[:rubylibprefix] then 29 [ 30 ConfigMap[:rubylibprefix], 31 'gems', 32 ConfigMap[:ruby_version] 33 ] 34 else 35 [ 36 ConfigMap[:libdir], 37 ruby_engine, 38 'gems', 39 ConfigMap[:ruby_version] 40 ] 41 end 42 43 @default_dir ||= File.join(*path) 44 end 45 46 ## 47 # Paths where RubyGems' .rb files and bin files are installed 48 49 def self.default_rubygems_dirs 50 nil # default to standard layout 51 end 52 53 ## 54 # Path for gems in the user's home directory 55 56 def self.user_dir 57 parts = [Gem.user_home, '.gem', ruby_engine] 58 parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? 59 File.join parts 60 end 61 62 ## 63 # How String Gem paths should be split. Overridable for esoteric platforms. 64 65 def self.path_separator 66 File::PATH_SEPARATOR 67 end 68 69 ## 70 # Default gem load path 71 72 def self.default_path 73 if Gem.user_home && File.exist?(Gem.user_home) then 74 [user_dir, default_dir] 75 else 76 [default_dir] 77 end 78 end 79 80 ## 81 # Deduce Ruby's --program-prefix and --program-suffix from its install name 82 83 def self.default_exec_format 84 exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' 85 86 unless exec_format =~ /%s/ then 87 raise Gem::Exception, 88 "[BUG] invalid exec_format #{exec_format.inspect}, no %s" 89 end 90 91 exec_format 92 end 93 94 ## 95 # The default directory for binaries 96 97 def self.default_bindir 98 if defined? RUBY_FRAMEWORK_VERSION then # mac framework support 99 '/usr/bin' 100 else # generic install 101 ConfigMap[:bindir] 102 end 103 end 104 105 ## 106 # A wrapper around RUBY_ENGINE const that may not be defined 107 108 def self.ruby_engine 109 if defined? RUBY_ENGINE then 110 RUBY_ENGINE 111 else 112 'ruby' 113 end 114 end 115 116 ## 117 # The default signing key path 118 119 def self.default_key_path 120 File.join Gem.user_home, ".gem", "gem-private_key.pem" 121 end 122 123 ## 124 # The default signing certificate chain path 125 126 def self.default_cert_path 127 File.join Gem.user_home, ".gem", "gem-public_cert.pem" 128 end 129end 130