Module: Gem

Extended by:
QuickLoader
Defined in:
lib/faster_rubygems.rb,
lib/faster_rubygems/my_defaults.rb,
lib/faster_rubygems/my_gem_prelude.rb,
lib/faster_rubygems/prelude_bin_path.rb,
lib/faster_rubygems/prelude_cached_load.rb,
lib/faster_rubygems/prelude_create_cache.rb

Overview

define it so gem_prelude will execute…

Defined Under Namespace

Modules: QuickLoader

Constant Summary collapse

ConfigMap =
{
  :EXEEXT            => RbConfig::CONFIG["EXEEXT"],
  :RUBY_SO_NAME      => RbConfig::CONFIG["RUBY_SO_NAME"],
  :arch              => RbConfig::CONFIG["arch"],
  :bindir            => RbConfig::CONFIG["bindir"],
  :libdir            => RbConfig::CONFIG["libdir"],
  :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
  :ruby_version      => RbConfig::CONFIG["ruby_version"],
  :rubylibprefix     => (RbConfig::CONFIG["rubylibprefix"] ||  RbConfig::CONFIG['rubylibdir'].split('/')[0..-2].join('/')),
  :sitedir           => RbConfig::CONFIG["sitedir"],
  :sitelibdir        => RbConfig::CONFIG["sitelibdir"],
}
GEM_PRELUDE_METHODS =

Methods before this line will be removed when QuickLoader is replaced with the real RubyGems

Gem.methods(false)

Constants included from QuickLoader

QuickLoader::AllCaches, QuickLoader::GemPaths, QuickLoader::GemVersions, QuickLoader::GemsActivated

Class Method Summary collapse

Methods included from QuickLoader

bin_path, calculate_all_highest_version_gems, const_missing, create_cache, create_cache_for_all!, fake_rubygems_as_loaded, integers_for, load_full_rubygems_library, method_missing, path_to_full_rubygems_library, push_all_gems_that_might_match_and_reload_files, push_gem_version_on_load_path, remove

Class Method Details

.default_bindirObject

The default directory for binaries



67
68
69
70
71
72
73
# File 'lib/faster_rubygems/my_defaults.rb', line 67

def self.default_bindir
  if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
    '/usr/bin'
  else # generic install
    ConfigMap[:bindir]
  end
end

.default_dirObject

Default home directory path to be used if an alternate value is not specified in the environment



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/faster_rubygems/my_defaults.rb', line 19

def self.default_dir
  if defined? RUBY_FRAMEWORK_VERSION then
    File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
              ConfigMap[:ruby_version]
  elsif ConfigMap[:rubylibprefix] then
    File.join(ConfigMap[:rubylibprefix], 'gems',
              ConfigMap[:ruby_version])
  else
    File.join(ConfigMap[:libdir], ruby_engine, 'gems',
              ConfigMap[:ruby_version])
  end
end

.default_exec_formatObject

Deduce Ruby’s –program-prefix and –program-suffix from its install name



53
54
55
56
57
58
59
60
61
62
# File 'lib/faster_rubygems/my_defaults.rb', line 53

def self.default_exec_format
  exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'

  unless exec_format =~ /%s/ then
    raise Gem::Exception,
      "[BUG] invalid exec_format #{exec_format.inspect}, no %s"
  end

  exec_format
end

.default_pathObject

Default gem load path



42
43
44
45
46
47
48
# File 'lib/faster_rubygems/my_defaults.rb', line 42

def self.default_path
  if File.exist? Gem.user_home then
    [user_dir, default_dir]
  else
    [default_dir]
  end
end

.default_sourcesObject

An Array of the default sources that come with RubyGems



11
12
13
# File 'lib/faster_rubygems/my_defaults.rb', line 11

def self.default_sources
  %w[http://rubygems.org/]
end

.default_system_source_cache_dirObject

The default system-wide source info cache directory



78
79
80
# File 'lib/faster_rubygems/my_defaults.rb', line 78

def self.default_system_source_cache_dir
  File.join Gem.dir, 'source_cache'
end

.default_user_source_cache_dirObject

The default user-specific source info cache directory



85
86
87
# File 'lib/faster_rubygems/my_defaults.rb', line 85

def self.default_user_source_cache_dir
  File.join Gem.user_home, '.gem', 'source_cache'
end

.dirObject



40
41
42
43
44
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 40

def self.dir
  @gem_home ||= nil
  set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
  @gem_home
end

.pathObject



46
47
48
49
50
51
52
53
54
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 46

def self.path
  @gem_path ||= nil
  unless @gem_path
    paths = [ENV['GEM_PATH'] || default_path]
    paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
    set_paths(paths.compact.join(File::PATH_SEPARATOR))
  end
  @gem_path
end

.post_install(&hook) ⇒ Object



56
57
58
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 56

def self.post_install(&hook)
  @post_install_hooks << hook
end

.post_uninstall(&hook) ⇒ Object



60
61
62
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 60

def self.post_uninstall(&hook)
  @post_uninstall_hooks << hook
end

.pre_install(&hook) ⇒ Object



64
65
66
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 64

def self.pre_install(&hook)
  @pre_install_hooks << hook
end

.pre_uninstall(&hook) ⇒ Object



68
69
70
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 68

def self.pre_uninstall(&hook)
  @pre_uninstall_hooks << hook
end

.ruby_engineObject

A wrapper around RUBY_ENGINE const that may not be defined



92
93
94
95
96
97
98
# File 'lib/faster_rubygems/my_defaults.rb', line 92

def self.ruby_engine
  if defined? RUBY_ENGINE then
    RUBY_ENGINE
  else
    'ruby'
  end
end

.set_home(home) ⇒ Object



72
73
74
75
76
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 72

def self.set_home(home)
  home = home.dup
  home.gsub!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
  @gem_home = home
end

.set_paths(gpaths) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 78

def self.set_paths(gpaths)
  if gpaths
    @gem_path = gpaths.split(File::PATH_SEPARATOR)

    if File::ALT_SEPARATOR then
      @gem_path.map! do |path|
        path.gsub File::ALT_SEPARATOR, File::SEPARATOR
      end
    end

    @gem_path << Gem.dir
  else
    # TODO: should this be Gem.default_path instead?
    @gem_path = [Gem.dir]
  end

  @gem_path.uniq!
end

.user_dirObject

Path for gems in the user’s home directory



35
36
37
# File 'lib/faster_rubygems/my_defaults.rb', line 35

def self.user_dir
  File.join Gem.user_home, '.gem', ruby_engine, ConfigMap[:ruby_version]
end

.user_homeObject



97
98
99
100
101
102
103
104
105
# File 'lib/faster_rubygems/my_gem_prelude.rb', line 97

def self.user_home
  @user_home ||= File.expand_path("~")
rescue
  if File::ALT_SEPARATOR then
    "C:/"
  else
    "/"
  end
end