| Module | Gem |
| In: |
lib/rubygems/defaults.rb
lib/rubygems/deprecate.rb lib/rubygems/gem_openssl.rb lib/rubygems/test_case.rb lib/rubygems.rb |
RubyGems is the Ruby standard for publishing and managing third party libraries.
For user documentation, see:
For gem developer documentation see:
Further RubyGems documentation can be found at:
As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or $LOAD_PATH. Plugins must be named ‘rubygems_plugin’ (.rb, .so, etc) and placed at the root of your gem‘s require_path. Plugins are discovered via Gem::find_files then loaded. Take care when implementing a plugin as your plugin file may be loaded multiple times if multiple versions of your gem are installed.
For an example plugin, see the graph gem which adds a `gem graph` command.
RubyGems defaults are stored in rubygems/defaults.rb. If you‘re packaging RubyGems or implementing Ruby you can change RubyGems’ defaults.
For RubyGems packagers, provide lib/rubygems/operating_system.rb and override any defaults from lib/rubygems/defaults.rb.
For Ruby implementers, provide lib/rubygems/#{RUBY_ENGINE}.rb and override any defaults from lib/rubygems/defaults.rb.
If you need RubyGems to perform extra work on install or uninstall, your defaults override file can set pre and post install and uninstall hooks. See Gem::pre_install, Gem::pre_uninstall, Gem::post_install, Gem::post_uninstall.
You can submit bugs to the RubyGems bug tracker on RubyForge
RubyGems is currently maintained by Eric Hodel.
RubyGems was originally developed at RubyConf 2003 by:
Contributors:
(If your name is missing, PLEASE let us know!)
Thanks!
-The RubyGems Team
| QUICKLOADER_SUCKAGE | = | RUBY_VERSION =~ /^1\.9\.1/ | ||
| GEM_PRELUDE_SUCKAGE | = | RUBY_VERSION =~ /^1\.9\.2/ | ||
| VERSION | = | '1.8.15' | ||
| 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 231
231: def self.activate(dep, *requirements)
232: raise ArgumentError, "Deprecated use of Gem.activate(dep)" if
233: Gem::Dependency === dep
234:
235: Gem::Specification.find_by_name(dep, *requirements).activate
236: end
An Array of all possible load paths for all versions of all gems in the Gem installation.
# File lib/rubygems.rb, line 254
254: def self.all_load_paths
255: result = []
256:
257: Gem.path.each do |gemdir|
258: each_load_path all_partials(gemdir) do |load_path|
259: result << gemdir.add(load_path).expand_path
260: end
261: end
262:
263: result
264: end
See if a given gem is available.
# File lib/rubygems.rb, line 278
278: def self.available?(dep, *requirements)
279: requirements = Gem::Requirement.default if requirements.empty?
280:
281: unless dep.respond_to?(:name) and dep.respond_to?(:requirement) then
282: dep = Gem::Dependency.new dep, requirements
283: end
284:
285: not dep.matching_specs(true).empty?
286: 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 294
294: def self.bin_path(name, exec_name = nil, *requirements)
295: # TODO: fails test_self_bin_path_bin_file_gone_in_latest
296: # Gem::Specification.find_by_name(name, *requirements).bin_file exec_name
297:
298: raise ArgumentError, "you must supply exec_name" unless exec_name
299:
300: requirements = Gem::Requirement.default if
301: requirements.empty?
302:
303: specs = Gem::Dependency.new(name, requirements).matching_specs(true)
304:
305: raise Gem::GemNotFoundException,
306: "can't find gem #{name} (#{requirements})" if specs.empty?
307:
308: specs = specs.find_all { |spec|
309: spec.executables.include? exec_name
310: } if exec_name
311:
312: unless spec = specs.last
313: msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
314: raise Gem::GemNotFoundException, msg
315: end
316:
317: spec.bin_file exec_name
318: end
The mode needed to read a file as straight binary.
# File lib/rubygems.rb, line 323
323: def self.binary_mode
324: 'rb'
325: 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 342
342: def self.clear_paths
343: @@source_index = nil
344: @paths = nil
345: @user_home = nil
346: @searcher = nil
347: Gem::Specification.reset
348: end
The standard configuration object for gems.
# File lib/rubygems.rb, line 360
360: def self.configuration
361: @configuration ||= Gem::ConfigFile.new []
362: end
Use the given configuration object (which implements the ConfigFile protocol) as the standard configuration object.
# File lib/rubygems.rb, line 368
368: def self.configuration=(config)
369: @configuration = config
370: 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 376
376: def self.datadir(gem_name)
377: # TODO: deprecate
378: spec = @loaded_specs[gem_name]
379: return nil if spec.nil?
380: File.join spec.full_gem_path, "data", gem_name
381: end
The default directory for binaries Debian patch:
install binaries to /usr/local/bin instead of /usr/bin
# File lib/rubygems/defaults.rb, line 68
68: def self.default_bindir
69: File.join('/', 'usr', 'local', 'bin')
70: 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 52
52: def self.default_exec_format
53: exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
54:
55: unless exec_format =~ /%s/ then
56: raise Gem::Exception,
57: "[BUG] invalid exec_format #{exec_format.inspect}, no %s"
58: end
59:
60: exec_format
61: end
The default system-wide source info cache directory
# File lib/rubygems/defaults.rb, line 75
75: def self.default_system_source_cache_dir
76: File.join(Gem.dir, 'source_cache')
77: end
The default user-specific source info cache directory
# File lib/rubygems/defaults.rb, line 82
82: def self.default_user_source_cache_dir
83: #
84: # NOTE Probably an argument for moving this to per-ruby supported dirs like
85: # user_dir
86: #
87: File.join(Gem.user_home, '.gem', 'source_cache')
88: end
A Zlib::Deflate.deflate wrapper
# File lib/rubygems.rb, line 386
386: def self.deflate(data)
387: require 'zlib'
388: Zlib::Deflate.deflate data
389: 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 444
444: def self.ensure_gem_subdirectories dir = Gem.dir
445: require 'fileutils'
446:
447: old_umask = File.umask
448: File.umask old_umask | 022
449:
450: %w[cache doc gems specifications].each do |name|
451: subdir = File.join dir, name
452: next if File.exist? subdir
453: FileUtils.mkdir_p subdir rescue nil # in case of perms issues -- lame
454: end
455: ensure
456: File.umask old_umask
457: 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 471
471: def self.find_files(glob, check_load_path=true)
472: files = []
473:
474: if check_load_path
475: files = $LOAD_PATH.map { |load_path|
476: Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
477: }.flatten.select { |file| File.file? file.untaint }
478: end
479:
480: files.concat Gem::Specification.map { |spec|
481: spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
482: }.flatten
483:
484: # $LOAD_PATH might contain duplicate entries or reference
485: # the spec dirs directly, so we prune.
486: files.uniq! if check_load_path
487:
488: return files
489: end
Zlib::GzipReader wrapper that unzips data.
# File lib/rubygems.rb, line 534
534: def self.gunzip(data)
535: # TODO: move to utils
536: require 'stringio'
537: require 'zlib'
538: data = StringIO.new data
539:
540: Zlib::GzipReader.new(data).read
541: end
Zlib::GzipWriter wrapper that zips data.
# File lib/rubygems.rb, line 546
546: def self.gzip(data)
547: # TODO: move to utils
548: require 'stringio'
549: require 'zlib'
550: zipped = StringIO.new
551:
552: Zlib::GzipWriter.wrap zipped do |io| io.write data end
553:
554: zipped.string
555: end
Get the default RubyGems API host. This is normally rubygems.org.
# File lib/rubygems.rb, line 570
570: def self.host
571: # TODO: move to utils
572: @host ||= "https://rubygems.org"
573: end
A Zlib::Inflate#inflate wrapper
# File lib/rubygems.rb, line 560
560: def self.inflate(data)
561: # TODO: move to utils
562: require 'zlib'
563: Zlib::Inflate.inflate data
564: 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 586
586: def self.latest_load_paths
587: result = []
588:
589: Gem.path.each do |gemdir|
590: each_load_path(latest_partials(gemdir)) do |load_path|
591: result << load_path
592: end
593: end
594:
595: result
596: end
# File lib/rubygems.rb, line 927
927: def self.latest_rubygems_version
928: latest_version_for "rubygems-update"
929: end
# File lib/rubygems.rb, line 908
908: def self.latest_spec_for name
909: dependency = Gem::Dependency.new name
910: fetcher = Gem::SpecFetcher.fetcher
911: spec_tuples = fetcher.find_matching dependency
912:
913: match = spec_tuples.select { |(n, _, p), _|
914: n == name and Gem::Platform.match p
915: }.sort_by { |(_, version, _), _|
916: version
917: }.last
918:
919: match and fetcher.fetch_spec(*match)
920: end
# File lib/rubygems.rb, line 922
922: def self.latest_version_for name
923: spec = latest_spec_for name
924: spec and spec.version
925: end
Find all ‘rubygems_plugin’ files in $LOAD_PATH and load them
# File lib/rubygems.rb, line 1091
1091: def self.load_env_plugins
1092: path = "rubygems_plugin"
1093:
1094: files = []
1095: $LOAD_PATH.each do |load_path|
1096: globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
1097:
1098: globbed.each do |load_path_file|
1099: files << load_path_file if File.file?(load_path_file.untaint)
1100: end
1101: end
1102:
1103: load_plugin_files files
1104: 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 626
626: def self.load_path_insert_index
627: index = $LOAD_PATH.index ConfigMap[:sitelibdir]
628:
629: if QUICKLOADER_SUCKAGE then
630: $LOAD_PATH.each_with_index do |path, i|
631: if path.instance_variables.include?(:@gem_prelude_index) or
632: path.instance_variables.include?('@gem_prelude_index') then
633: index = i
634: break
635: end
636: end
637: end
638:
639: index
640: end
Load plugins as ruby files
# File lib/rubygems.rb, line 1064
1064: def self.load_plugin_files(plugins)
1065: plugins.each do |plugin|
1066:
1067: # Skip older versions of the GemCutter plugin: Its commands are in
1068: # RubyGems proper now.
1069:
1070: next if plugin =~ /gemcutter-0\.[0-3]/
1071:
1072: begin
1073: load plugin
1074: rescue ::Exception => e
1075: details = "#{plugin.inspect}: #{e.message} (#{e.class})"
1076: warn "Error loading RubyGems plugin #{details}"
1077: end
1078: end
1079: end
Find all ‘rubygems_plugin’ files in installed gems and load them
# File lib/rubygems.rb, line 1084
1084: def self.load_plugins
1085: load_plugin_files find_files('rubygems_plugin', false)
1086: end
Loads YAML, preferring Psych
# File lib/rubygems.rb, line 647
647: def self.load_yaml
648: return if @yaml_loaded
649:
650: begin
651: gem 'psych', '~> 1.2', '>= 1.2.1' unless ENV['TEST_SYCK']
652: rescue Gem::LoadError
653: # It's OK if the user does not have the psych gem installed. We will
654: # attempt to require the stdlib version
655: end
656:
657: begin
658: # Try requiring the gem version *or* stdlib version of psych.
659: require 'psych' unless ENV['TEST_SYCK']
660: rescue ::LoadError
661: ensure
662: require 'yaml'
663: end
664:
665: # Now that we're sure some kind of yaml library is loaded, pull
666: # in our hack to deal with Syck's DefaultKey ugliness.
667: require 'rubygems/syck_hack'
668:
669: @yaml_loaded = true
670: end
# File lib/rubygems.rb, line 987
987: def self.loaded_path? path
988: # TODO: ruby needs a feature to let us query what's loaded in 1.8 and 1.9
989: re = /(^|\/)#{Regexp.escape path}#{Regexp.union(*Gem.suffixes)}$/
990: $LOADED_FEATURES.any? { |s| s =~ re }
991: end
The file name and line number of the caller of the caller of this method.
# File lib/rubygems.rb, line 675
675: def self.location_of_caller
676: caller[1] =~ /(.*?):(\d+).*?$/i
677: file = $1
678: lineno = $2.to_i
679:
680: # TODO: it is ALWAYS joined! STUPID!
681: [file, lineno]
682: end
The version of the Marshal format for your Ruby.
# File lib/rubygems.rb, line 687
687: def self.marshal_version
688: "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
689: end
# File lib/rubygems.rb, line 411
411: def self.path
412: # TODO: raise "no"
413: paths.path
414: end
# File lib/rubygems.rb, line 395
395: def self.paths=(env)
396: clear_paths
397: @paths = Gem::PathSupport.new env
398: Gem::Specification.dirs = @paths.path # FIX: home is at end
399: 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 737
737: def self.post_build(&hook)
738: @post_build_hooks << hook
739: 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 745
745: def self.post_install(&hook)
746: @post_install_hooks << hook
747: end
Adds a hook that will get run after Gem::Specification.reset is run.
# File lib/rubygems.rb, line 753
753: def self.post_reset(&hook)
754: @post_reset_hooks << hook
755: 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 762
762: def self.post_uninstall(&hook)
763: @post_uninstall_hooks << hook
764: 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 771
771: def self.pre_install(&hook)
772: @pre_install_hooks << hook
773: end
Adds a hook that will get run before Gem::Specification.reset is run.
# File lib/rubygems.rb, line 779
779: def self.pre_reset(&hook)
780: @pre_reset_hooks << hook
781: 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 788
788: def self.pre_uninstall(&hook)
789: @pre_uninstall_hooks << hook
790: 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 797
797: def self.prefix
798: prefix = File.dirname RUBYGEMS_DIR
799:
800: if prefix != File.expand_path(ConfigMap[:sitelibdir]) and
801: prefix != File.expand_path(ConfigMap[:libdir]) and
802: 'lib' == File.basename(RUBYGEMS_DIR) then
803: prefix
804: end
805: 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 812
812: def self.promote_load_path(gem_name, over_name)
813: gem = Gem.loaded_specs[gem_name]
814: over = Gem.loaded_specs[over_name]
815:
816: raise ArgumentError, "gem #{gem_name} is not activated" if gem.nil?
817: raise ArgumentError, "gem #{over_name} is not activated" if over.nil?
818:
819: last_gem_path = Gem::Path.path(gem.full_gem_path).add(gem.require_paths.last)
820:
821: over_paths = over.require_paths.map do |path|
822: Gem::Path.path(over.full_gem_path).add(path).to_s
823: end
824:
825: over_paths.each do |path|
826: $LOAD_PATH.delete path
827: end
828:
829: gem = $LOAD_PATH.index(last_gem_path) + 1
830:
831: $LOAD_PATH.insert(gem, *over_paths)
832: end
Refresh source_index from disk and clear searcher.
# File lib/rubygems.rb, line 837
837: def self.refresh
838: Gem::Specification.reset
839: @source_index = nil
840: @searcher = nil
841: end
Full path to libfile in gemname. Searches for the latest gem unless requirements is given.
# File lib/rubygems.rb, line 878
878: def self.required_location(gemname, libfile, *requirements)
879: requirements = Gem::Requirement.default if requirements.empty?
880:
881: matches = Gem::Specification.find_all_by_name gemname, *requirements
882:
883: return nil if matches.empty?
884:
885: spec = matches.last
886: spec.require_paths.each do |path|
887: result = Gem::Path.path(spec.full_gem_path).add(path, libfile)
888: return result if result.exist?
889: end
890:
891: nil
892: end
The path to the running Ruby interpreter.
# File lib/rubygems.rb, line 897
897: def self.ruby
898: if @ruby.nil? then
899: @ruby = File.join(ConfigMap[:bindir],
900: "#{ConfigMap[:ruby_install_name]}#{ConfigMap[:EXEEXT]}")
901:
902: @ruby = "\"#{@ruby}\"" if @ruby =~ /\s/
903: end
904:
905: @ruby
906: end
A wrapper around RUBY_ENGINE const that may not be defined
# File lib/rubygems/defaults.rb, line 93
93: def self.ruby_engine
94: if defined? RUBY_ENGINE then
95: RUBY_ENGINE
96: else
97: 'ruby'
98: end
99: end
A Gem::Version for the currently running ruby.
# File lib/rubygems.rb, line 934
934: def self.ruby_version
935: return @ruby_version if defined? @ruby_version
936: version = RUBY_VERSION.dup
937:
938: if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1 then
939: version << ".#{RUBY_PATCHLEVEL}"
940: elsif defined?(RUBY_REVISION) then
941: version << ".dev.#{RUBY_REVISION}"
942: end
943:
944: @ruby_version = Gem::Version.new version
945: end
The GemPathSearcher object used to search for matching installed gems.
# File lib/rubygems.rb, line 950
950: def self.searcher
951: @searcher ||= Gem::GemPathSearcher.new
952: end
Returns the Gem::SourceIndex of specifications that are in the Gem.path
# File lib/rubygems.rb, line 957
957: def self.source_index
958: @@source_index ||= Gem::Deprecate.skip_during do
959: SourceIndex.new Gem::Specification.dirs
960: end
961: 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 968
968: def self.sources
969: @sources ||= default_sources
970: 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 976
976: def self.sources= new_sources
977: @sources = new_sources
978: 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
Prints the amount of time the supplied block takes to run using the debug UI output.
# File lib/rubygems.rb, line 1011
1011: def self.time(msg, width = 0, display = Gem.configuration.verbose)
1012: now = Time.now
1013:
1014: value = yield
1015:
1016: elapsed = Time.now - now
1017:
1018: ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display
1019:
1020: value
1021: 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 197
197: def self.try_activate path
198: # TODO: deprecate when 1.9.3 comes out.
199: # finds the _latest_ version... regardless of loaded specs and their deps
200:
201: # TODO: use find_all and bork if ambiguous
202:
203: spec = Gem::Specification.find_by_path path
204: return false unless spec
205:
206: begin
207: spec.activate
208: rescue Gem::LoadError # this could fail due to gem dep collisions, go lax
209: Gem::Specification.find_by_name(spec.name).activate
210: end
211:
212: return true
213: end
Lazily loads DefaultUserInteraction and returns the default UI.
# File lib/rubygems.rb, line 1026
1026: def self.ui
1027: require 'rubygems/user_interaction'
1028:
1029: Gem::DefaultUserInteraction.ui
1030: end
# File lib/rubygems.rb, line 246
246: def self.unresolved_deps
247: @unresolved_deps ||= Hash.new { |h, n| h[n] = Gem::Dependency.new n }
248: 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 1036
1036: def self.use_paths(home, *paths)
1037: paths = nil if paths == [nil]
1038: paths = paths.first if Array === Array(paths).first
1039: self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths }
1040: # TODO: self.paths = home, paths
1041: end
Path for gems in the user‘s home directory
# File lib/rubygems/defaults.rb, line 34
34: def self.user_dir
35: File.join Gem.user_home, '.gem', ruby_engine, ConfigMap[:ruby_version]
36: end
The home directory for the user.
# File lib/rubygems.rb, line 1046
1046: def self.user_home
1047: @user_home ||= find_home
1048: 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