Module | Gem |
In: |
lib/rubygems.rb
lib/rubygems/gem_openssl.rb lib/rubygems/defaults.rb lib/rubygems/test_case.rb lib/rubygems/deprecate.rb lib/rubygems/psych_tree.rb |
Provides a single method deprecate to be used to declare when something is going away.
class Legacy def self.klass_method # ... end def instance_method # ... end extend Gem::Deprecate deprecate :instance_method, "X.z", 2011, 4 class << self extend Gem::Deprecate deprecate :klass_method, :none, 2011, 4 end end
QUICKLOADER_SUCKAGE | = | RUBY_VERSION =~ /^1\.9\.1/ | ||
GEM_PRELUDE_SUCKAGE | = | RUBY_VERSION =~ /^1\.9\.2/ && RUBY_ENGINE == "ruby" | Only MRI 1.9.2 has the custom prelude. | |
VERSION | = | '1.8.24' | ||
WIN_PATTERNS | = | [ /bccwin/i, /cygwin/i, /djgpp/i, /mingw/i, /mswin/i, /wince/i, ] | An Array of Regexps that match windows ruby platforms. | |
MARSHAL_SPEC_DIR | = | "quick/Marshal.#{Gem.marshal_version}/" | Location of Marshal quick gemspecs on remote repositories |
loaded_specs | [R] | Hash of loaded Gem::Specification keyed by name |
post_build_hooks | [R] | The list of hooks to be run before Gem::Install#install finishes installation |
post_install_hooks | [R] | The list of hooks to be run before Gem::Install#install does any work |
post_reset_hooks | [R] | The list of hooks to be run after Gem::Specification.reset is run. |
post_uninstall_hooks | [R] | The list of hooks to be run before Gem::Uninstall#uninstall does any work |
pre_install_hooks | [R] | The list of hooks to be run after Gem::Install#install is finished |
pre_reset_hooks | [R] | The list of hooks to be run before Gem::Specification.reset is run. |
pre_uninstall_hooks | [R] | The list of hooks to be run after Gem::Uninstall#uninstall is finished |
ssl_available | [W] | Is SSL available? |
Activates an installed gem matching dep. The gem must satisfy requirements.
Returns true if the gem is activated, false if it is already loaded, or an exception otherwise.
Gem#activate adds the library paths in dep to $LOAD_PATH. Before a Gem is activated its required Gems are activated. If the version information is omitted, the highest version Gem of the supplied name is loaded. If a Gem is not found that meets the version requirements or a required Gem is not found, a Gem::LoadError is raised.
More information on version requirements can be found in the Gem::Requirement and Gem::Version documentation.
# File lib/rubygems.rb, line 234 234: def self.activate(dep, *requirements) 235: raise ArgumentError, "Deprecated use of Gem.activate(dep)" if 236: Gem::Dependency === dep 237: 238: Gem::Specification.find_by_name(dep, *requirements).activate 239: end
An Array of all possible load paths for all versions of all gems in the Gem installation.
# File lib/rubygems.rb, line 257 257: def self.all_load_paths 258: result = [] 259: 260: Gem.path.each do |gemdir| 261: each_load_path all_partials(gemdir) do |load_path| 262: result << load_path 263: end 264: end 265: 266: result 267: end
See if a given gem is available.
# File lib/rubygems.rb, line 281 281: def self.available?(dep, *requirements) 282: requirements = Gem::Requirement.default if requirements.empty? 283: 284: unless dep.respond_to?(:name) and dep.respond_to?(:requirement) then 285: dep = Gem::Dependency.new dep, requirements 286: end 287: 288: not dep.matching_specs(true).empty? 289: end
Find the full path to the executable for gem name. If the exec_name is not given, the gem‘s default_executable is chosen, otherwise the specified executable‘s path is returned. requirements allows you to specify specific gem versions.
# File lib/rubygems.rb, line 297 297: def self.bin_path(name, exec_name = nil, *requirements) 298: # TODO: fails test_self_bin_path_bin_file_gone_in_latest 299: # Gem::Specification.find_by_name(name, *requirements).bin_file exec_name 300: 301: raise ArgumentError, "you must supply exec_name" unless exec_name 302: 303: requirements = Gem::Requirement.default if 304: requirements.empty? 305: 306: specs = Gem::Dependency.new(name, requirements).matching_specs(true) 307: 308: raise Gem::GemNotFoundException, 309: "can't find gem #{name} (#{requirements})" if specs.empty? 310: 311: specs = specs.find_all { |spec| 312: spec.executables.include? exec_name 313: } if exec_name 314: 315: unless spec = specs.last 316: msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}" 317: raise Gem::GemNotFoundException, msg 318: end 319: 320: spec.bin_file exec_name 321: end
The mode needed to read a file as straight binary.
# File lib/rubygems.rb, line 326 326: def self.binary_mode 327: 'rb' 328: end
Reset the dir and path values. The next time dir or path is requested, the values will be calculated from scratch. This is mainly used by the unit tests to provide test isolation.
# File lib/rubygems.rb, line 345 345: def self.clear_paths 346: @@source_index = nil 347: @paths = nil 348: @user_home = nil 349: @searcher = nil 350: Gem::Specification.reset 351: end
The standard configuration object for gems.
# File lib/rubygems.rb, line 363 363: def self.configuration 364: @configuration ||= Gem::ConfigFile.new [] 365: end
Use the given configuration object (which implements the ConfigFile protocol) as the standard configuration object.
# File lib/rubygems.rb, line 371 371: def self.configuration=(config) 372: @configuration = config 373: end
The path the the data directory specified by the gem name. If the package is not available as a gem, return nil.
# File lib/rubygems.rb, line 379 379: def self.datadir(gem_name) 380: # TODO: deprecate 381: spec = @loaded_specs[gem_name] 382: return nil if spec.nil? 383: File.join spec.full_gem_path, "data", gem_name 384: end
The default directory for binaries Debian patch:
install binaries to /usr/local/bin instead of /usr/bin
# File lib/rubygems/defaults.rb, line 75 75: def self.default_bindir 76: File.join('/', 'usr', 'local', 'bin') 77: end
Default home directory path to be used if an alternate value is not specified in the environment
Debian patch: search order of this directory.
1. GEM_HOME enviroment variable (Using this, Gems are to be installed in any path as you like) 2. /var/lib/gems/{ruby version} (This is the default path in Debian system)
# File lib/rubygems/defaults.rb, line 27 27: def self.default_dir 28: @default_dir ||= File.join('/', 'var', 'lib', 'gems', ConfigMap[:ruby_version]) 29: end
Deduce Ruby‘s —program-prefix and —program-suffix from its install name
# File lib/rubygems/defaults.rb, line 59 59: def self.default_exec_format 60: exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s' 61: 62: unless exec_format =~ /%s/ then 63: raise Gem::Exception, 64: "[BUG] invalid exec_format #{exec_format.inspect}, no %s" 65: end 66: 67: exec_format 68: end
Paths where RubyGems’ .rb files and bin files are installed
# File lib/rubygems/defaults.rb, line 34 34: def self.default_rubygems_dirs 35: nil # default to standard layout 36: end
The default system-wide source info cache directory
# File lib/rubygems/defaults.rb, line 82 82: def self.default_system_source_cache_dir 83: File.join(Gem.dir, 'source_cache') 84: end
The default user-specific source info cache directory
# File lib/rubygems/defaults.rb, line 89 89: def self.default_user_source_cache_dir 90: # 91: # NOTE Probably an argument for moving this to per-ruby supported dirs like 92: # user_dir 93: # 94: File.join(Gem.user_home, '.gem', 'source_cache') 95: end
A Zlib::Deflate.deflate wrapper
# File lib/rubygems.rb, line 389 389: def self.deflate(data) 390: require 'zlib' 391: Zlib::Deflate.deflate data 392: end
Quietly ensure the named Gem directory contains all the proper subdirectories. If we can‘t create a directory due to a permission problem, then we will silently continue.
# File lib/rubygems.rb, line 447 447: def self.ensure_gem_subdirectories dir = Gem.dir 448: old_umask = File.umask 449: File.umask old_umask | 002 450: 451: require 'fileutils' 452: 453: %w[cache doc gems specifications].each do |name| 454: subdir = File.join dir, name 455: next if File.exist? subdir 456: FileUtils.mkdir_p subdir rescue nil # in case of perms issues -- lame 457: end 458: ensure 459: File.umask old_umask 460: end
Ensure that SSL is available. Throw an exception if it is not.
# File lib/rubygems/gem_openssl.rb, line 31 31: def ensure_ssl_available 32: unless ssl_available? 33: raise Gem::Exception, "SSL is not installed on this system" 34: end 35: end
Returns a list of paths matching glob that can be used by a gem to pick up features from other gems. For example:
Gem.find_files('rdoc/discover').each do |path| load path end
if check_load_path is true (the default), then find_files also searches $LOAD_PATH for files as well as gems.
Note that find_files will return all files even if they are from different versions of the same gem.
# File lib/rubygems.rb, line 474 474: def self.find_files(glob, check_load_path=true) 475: files = [] 476: 477: if check_load_path 478: files = $LOAD_PATH.map { |load_path| 479: Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"] 480: }.flatten.select { |file| File.file? file.untaint } 481: end 482: 483: files.concat Gem::Specification.map { |spec| 484: spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}") 485: }.flatten 486: 487: # $LOAD_PATH might contain duplicate entries or reference 488: # the spec dirs directly, so we prune. 489: files.uniq! if check_load_path 490: 491: return files 492: end
Zlib::GzipReader wrapper that unzips data.
# File lib/rubygems.rb, line 537 537: def self.gunzip(data) 538: # TODO: move to utils 539: require 'stringio' 540: require 'zlib' 541: data = StringIO.new data 542: 543: Zlib::GzipReader.new(data).read 544: end
Zlib::GzipWriter wrapper that zips data.
# File lib/rubygems.rb, line 549 549: def self.gzip(data) 550: # TODO: move to utils 551: require 'stringio' 552: require 'zlib' 553: zipped = StringIO.new 554: 555: Zlib::GzipWriter.wrap zipped do |io| io.write data end 556: 557: zipped.string 558: end
Get the default RubyGems API host. This is normally rubygems.org.
# File lib/rubygems.rb, line 573 573: def self.host 574: # TODO: move to utils 575: @host ||= "https://rubygems.org" 576: end
A Zlib::Inflate#inflate wrapper
# File lib/rubygems.rb, line 563 563: def self.inflate(data) 564: # TODO: move to utils 565: require 'zlib' 566: Zlib::Inflate.inflate data 567: end
Return a list of all possible load paths for the latest version for all gems in the Gem installation.
# File lib/rubygems.rb, line 589 589: def self.latest_load_paths 590: result = [] 591: 592: Gem.path.each do |gemdir| 593: each_load_path(latest_partials(gemdir)) do |load_path| 594: result << load_path 595: end 596: end 597: 598: result 599: end
# File lib/rubygems.rb, line 950 950: def self.latest_rubygems_version 951: latest_version_for "rubygems-update" 952: end
# File lib/rubygems.rb, line 931 931: def self.latest_spec_for name 932: dependency = Gem::Dependency.new name 933: fetcher = Gem::SpecFetcher.fetcher 934: spec_tuples = fetcher.find_matching dependency 935: 936: match = spec_tuples.select { |(n, _, p), _| 937: n == name and Gem::Platform.match p 938: }.sort_by { |(_, version, _), _| 939: version 940: }.last 941: 942: match and fetcher.fetch_spec(*match) 943: end
# File lib/rubygems.rb, line 945 945: def self.latest_version_for name 946: spec = latest_spec_for name 947: spec and spec.version 948: end
Find all ‘rubygems_plugin’ files in $LOAD_PATH and load them
# File lib/rubygems.rb, line 1114 1114: def self.load_env_plugins 1115: path = "rubygems_plugin" 1116: 1117: files = [] 1118: $LOAD_PATH.each do |load_path| 1119: globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"] 1120: 1121: globbed.each do |load_path_file| 1122: files << load_path_file if File.file?(load_path_file.untaint) 1123: end 1124: end 1125: 1126: load_plugin_files files 1127: end
The index to insert activated gem paths into the $LOAD_PATH.
Defaults to the site lib directory unless gem_prelude.rb has loaded paths, then it inserts the activated gem‘s paths before the gem_prelude.rb paths so you can override the gem_prelude.rb default $LOAD_PATH paths.
# File lib/rubygems.rb, line 629 629: def self.load_path_insert_index 630: index = $LOAD_PATH.index ConfigMap[:sitelibdir] 631: 632: if QUICKLOADER_SUCKAGE then 633: $LOAD_PATH.each_with_index do |path, i| 634: if path.instance_variables.include?(:@gem_prelude_index) or 635: path.instance_variables.include?('@gem_prelude_index') then 636: index = i 637: break 638: end 639: end 640: end 641: 642: index 643: end
Load plugins as ruby files
# File lib/rubygems.rb, line 1087 1087: def self.load_plugin_files(plugins) 1088: plugins.each do |plugin| 1089: 1090: # Skip older versions of the GemCutter plugin: Its commands are in 1091: # RubyGems proper now. 1092: 1093: next if plugin =~ /gemcutter-0\.[0-3]/ 1094: 1095: begin 1096: load plugin 1097: rescue ::Exception => e 1098: details = "#{plugin.inspect}: #{e.message} (#{e.class})" 1099: warn "Error loading RubyGems plugin #{details}" 1100: end 1101: end 1102: end
Find all ‘rubygems_plugin’ files in installed gems and load them
# File lib/rubygems.rb, line 1107 1107: def self.load_plugins 1108: load_plugin_files find_files('rubygems_plugin', false) 1109: end
Loads YAML, preferring Psych
# File lib/rubygems.rb, line 650 650: def self.load_yaml 651: return if @yaml_loaded 652: 653: test_syck = ENV['TEST_SYCK'] 654: 655: unless test_syck 656: begin 657: gem 'psych', '~> 1.2', '>= 1.2.1' 658: rescue Gem::LoadError 659: # It's OK if the user does not have the psych gem installed. We will 660: # attempt to require the stdlib version 661: end 662: 663: begin 664: # Try requiring the gem version *or* stdlib version of psych. 665: require 'psych' 666: rescue ::LoadError 667: # If we can't load psych, thats fine, go on. 668: else 669: # If 'yaml' has already been required, then we have to 670: # be sure to switch it over to the newly loaded psych. 671: if defined?(YAML::ENGINE) && YAML::ENGINE.yamler != "psych" 672: YAML::ENGINE.yamler = "psych" 673: end 674: 675: require 'rubygems/psych_additions' 676: require 'rubygems/psych_tree' 677: end 678: end 679: 680: require 'yaml' 681: 682: # If we're supposed to be using syck, then we may have to force 683: # activate it via the YAML::ENGINE API. 684: if test_syck and defined?(YAML::ENGINE) 685: YAML::ENGINE.yamler = "syck" unless YAML::ENGINE.syck? 686: end 687: 688: # Now that we're sure some kind of yaml library is loaded, pull 689: # in our hack to deal with Syck's DefaultKey ugliness. 690: require 'rubygems/syck_hack' 691: 692: @yaml_loaded = true 693: end
# File lib/rubygems.rb, line 1010 1010: def self.loaded_path? path 1011: # TODO: ruby needs a feature to let us query what's loaded in 1.8 and 1.9 1012: re = /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/ 1013: $LOADED_FEATURES.any? { |s| s =~ re } 1014: end
The file name and line number of the caller of the caller of this method.
# File lib/rubygems.rb, line 698 698: def self.location_of_caller 699: caller[1] =~ /(.*?):(\d+).*?$/i 700: file = $1 701: lineno = $2.to_i 702: 703: # TODO: it is ALWAYS joined! STUPID! 704: [file, lineno] 705: end
The version of the Marshal format for your Ruby.
# File lib/rubygems.rb, line 710 710: def self.marshal_version 711: "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}" 712: end
# File lib/rubygems.rb, line 414 414: def self.path 415: # TODO: raise "no" 416: paths.path 417: end
# File lib/rubygems.rb, line 398 398: def self.paths=(env) 399: clear_paths 400: @paths = Gem::PathSupport.new env 401: Gem::Specification.dirs = @paths.path # FIX: home is at end 402: end
Adds a post-build hook that will be passed an Gem::Installer instance when Gem::Installer#install is called. The hook is called after the gem has been extracted and extensions have been built but before the executables or gemspec has been written. If the hook returns false then the gem‘s files will be removed and the install will be aborted.
# File lib/rubygems.rb, line 760 760: def self.post_build(&hook) 761: @post_build_hooks << hook 762: end
Adds a post-install hook that will be passed an Gem::Installer instance when Gem::Installer#install is called
# File lib/rubygems.rb, line 768 768: def self.post_install(&hook) 769: @post_install_hooks << hook 770: end
Adds a hook that will get run after Gem::Specification.reset is run.
# File lib/rubygems.rb, line 776 776: def self.post_reset(&hook) 777: @post_reset_hooks << hook 778: end
Adds a post-uninstall hook that will be passed a Gem::Uninstaller instance and the spec that was uninstalled when Gem::Uninstaller#uninstall is called
# File lib/rubygems.rb, line 785 785: def self.post_uninstall(&hook) 786: @post_uninstall_hooks << hook 787: end
Adds a pre-install hook that will be passed an Gem::Installer instance when Gem::Installer#install is called. If the hook returns false then the install will be aborted.
# File lib/rubygems.rb, line 794 794: def self.pre_install(&hook) 795: @pre_install_hooks << hook 796: end
Adds a hook that will get run before Gem::Specification.reset is run.
# File lib/rubygems.rb, line 802 802: def self.pre_reset(&hook) 803: @pre_reset_hooks << hook 804: end
Adds a pre-uninstall hook that will be passed an Gem::Uninstaller instance and the spec that will be uninstalled when Gem::Uninstaller#uninstall is called
# File lib/rubygems.rb, line 811 811: def self.pre_uninstall(&hook) 812: @pre_uninstall_hooks << hook 813: end
The directory prefix this RubyGems was installed at. If your prefix is in a standard location (ie, rubygems is installed where you‘d expect it to be), then prefix returns nil.
# File lib/rubygems.rb, line 820 820: def self.prefix 821: prefix = File.dirname RUBYGEMS_DIR 822: 823: if prefix != File.expand_path(ConfigMap[:sitelibdir]) and 824: prefix != File.expand_path(ConfigMap[:libdir]) and 825: 'lib' == File.basename(RUBYGEMS_DIR) then 826: prefix 827: end 828: end
Promotes the load paths of the gem_name over the load paths of over_name. Useful for allowing one gem to override features in another using find_files.
# File lib/rubygems.rb, line 835 835: def self.promote_load_path(gem_name, over_name) 836: gem = Gem.loaded_specs[gem_name] 837: over = Gem.loaded_specs[over_name] 838: 839: raise ArgumentError, "gem #{gem_name} is not activated" if gem.nil? 840: raise ArgumentError, "gem #{over_name} is not activated" if over.nil? 841: 842: last_gem_path = Gem::Path.path(gem.full_gem_path).add(gem.require_paths.last) 843: 844: over_paths = over.require_paths.map do |path| 845: Gem::Path.path(over.full_gem_path).add(path).to_s 846: end 847: 848: over_paths.each do |path| 849: $LOAD_PATH.delete path 850: end 851: 852: gem = $LOAD_PATH.index(last_gem_path) + 1 853: 854: $LOAD_PATH.insert(gem, *over_paths) 855: end
Refresh source_index from disk and clear searcher.
# File lib/rubygems.rb, line 860 860: def self.refresh 861: Gem::Specification.reset 862: @source_index = nil 863: @searcher = nil 864: end
Full path to libfile in gemname. Searches for the latest gem unless requirements is given.
# File lib/rubygems.rb, line 901 901: def self.required_location(gemname, libfile, *requirements) 902: requirements = Gem::Requirement.default if requirements.empty? 903: 904: matches = Gem::Specification.find_all_by_name gemname, *requirements 905: 906: return nil if matches.empty? 907: 908: spec = matches.last 909: spec.require_paths.each do |path| 910: result = Gem::Path.path(spec.full_gem_path).add(path, libfile) 911: return result if result.exist? 912: end 913: 914: nil 915: end
The path to the running Ruby interpreter.
# File lib/rubygems.rb, line 920 920: def self.ruby 921: if @ruby.nil? then 922: @ruby = File.join(ConfigMap[:bindir], 923: "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}") 924: 925: @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/ 926: end 927: 928: @ruby 929: end
A wrapper around RUBY_ENGINE const that may not be defined
# File lib/rubygems/defaults.rb, line 100 100: def self.ruby_engine 101: if defined? RUBY_ENGINE then 102: RUBY_ENGINE 103: else 104: 'ruby' 105: end 106: end
A Gem::Version for the currently running ruby.
# File lib/rubygems.rb, line 957 957: def self.ruby_version 958: return @ruby_version if defined? @ruby_version 959: version = RUBY_VERSION.dup 960: 961: if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1 then 962: version << ".#{RUBY_PATCHLEVEL}" 963: elsif defined?(RUBY_REVISION) then 964: version << ".dev.#{RUBY_REVISION}" 965: end 966: 967: @ruby_version = Gem::Version.new version 968: end
The GemPathSearcher object used to search for matching installed gems.
# File lib/rubygems.rb, line 973 973: def self.searcher 974: @searcher ||= Gem::GemPathSearcher.new 975: end
Returns the Gem::SourceIndex of specifications that are in the Gem.path
# File lib/rubygems.rb, line 980 980: def self.source_index 981: @@source_index ||= Gem::Deprecate.skip_during do 982: SourceIndex.new Gem::Specification.dirs 983: end 984: end
Allows setting the default SourceIndex. This method is available when requiring ‘rubygems/test_case‘
# File lib/rubygems/test_case.rb, line 42 42: def self.source_index=(si) 43: raise "This method is not supported" 44: Gem::Specification.reset if si # HACK 45: @@source_index = si 46: end
Returns an Array of sources to fetch remote gems from. If the sources list is empty, attempts to load the "sources" gem, then uses default_sources if it is not installed.
# File lib/rubygems.rb, line 991 991: def self.sources 992: @sources ||= default_sources 993: end
Need to be able to set the sources without calling Gem.sources.replace since that would cause an infinite loop.
# File lib/rubygems.rb, line 999 999: def self.sources= new_sources 1000: @sources = new_sources 1001: end
Is SSL (used by the signing commands) available on this platform?
# File lib/rubygems/gem_openssl.rb, line 19 19: def ssl_available? 20: @ssl_available 21: end
Suffixes for require-able paths.
# File lib/rubygems.rb, line 1019 1019: def self.suffixes 1020: @suffixes ||= ['', 1021: '.rb', 1022: *%w(DLEXT DLEXT2).map { |key| 1023: val = RbConfig::CONFIG[key] 1024: next unless val and not val.empty? 1025: ".#{val}" 1026: } 1027: ].compact.uniq 1028: end
Prints the amount of time the supplied block takes to run using the debug UI output.
# File lib/rubygems.rb, line 1034 1034: def self.time(msg, width = 0, display = Gem.configuration.verbose) 1035: now = Time.now 1036: 1037: value = yield 1038: 1039: elapsed = Time.now - now 1040: 1041: ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display 1042: 1043: value 1044: end
Try to activate a gem containing path. Returns true if activation succeeded or wasn‘t needed because it was already activated. Returns false if it can‘t find the path in a gem.
# File lib/rubygems.rb, line 200 200: def self.try_activate path 201: # TODO: deprecate when 1.9.3 comes out. 202: # finds the _latest_ version... regardless of loaded specs and their deps 203: 204: # TODO: use find_all and bork if ambiguous 205: 206: spec = Gem::Specification.find_by_path path 207: return false unless spec 208: 209: begin 210: spec.activate 211: rescue Gem::LoadError # this could fail due to gem dep collisions, go lax 212: Gem::Specification.find_by_name(spec.name).activate 213: end 214: 215: return true 216: end
Lazily loads DefaultUserInteraction and returns the default UI.
# File lib/rubygems.rb, line 1049 1049: def self.ui 1050: require 'rubygems/user_interaction' 1051: 1052: Gem::DefaultUserInteraction.ui 1053: end
# File lib/rubygems.rb, line 249 249: def self.unresolved_deps 250: @unresolved_deps ||= Hash.new { |h, n| h[n] = Gem::Dependency.new n } 251: end
Use the home and paths values for Gem.dir and Gem.path. Used mainly by the unit tests to provide environment isolation.
# File lib/rubygems.rb, line 1059 1059: def self.use_paths(home, *paths) 1060: paths = nil if paths == [nil] 1061: paths = paths.first if Array === Array(paths).first 1062: self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths } 1063: # TODO: self.paths = home, paths 1064: end
Path for gems in the user‘s home directory
# File lib/rubygems/defaults.rb, line 41 41: def self.user_dir 42: File.join Gem.user_home, '.gem', ruby_engine, ConfigMap[:ruby_version] 43: end
The home directory for the user.
# File lib/rubygems.rb, line 1069 1069: def self.user_home 1070: @user_home ||= find_home 1071: end
Allows toggling Windows behavior. This method is available when requiring ‘rubygems/test_case‘
# File lib/rubygems/test_case.rb, line 52 52: def self.win_platform=(val) 53: @@win_platform = val 54: end