Module: Gem

Extended by:
QuickLoader
Defined in:
lib/core/r4a/gems.rb

Defined Under Namespace

Modules: QuickLoader Classes: LoadError

Constant Summary

ConfigMap =
{
  :sitedir => RbConfig::CONFIG["sitedir"],
  :ruby_version => RbConfig::CONFIG["ruby_version"],
  :libdir => RbConfig::CONFIG["libdir"],
  :sitelibdir => RbConfig::CONFIG["sitelibdir"],
  :arch => RbConfig::CONFIG["arch"],
  :bindir => RbConfig::CONFIG["bindir"],
  :EXEEXT => RbConfig::CONFIG["EXEEXT"],
  :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
  :ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
}
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::GemPaths, QuickLoader::GemVersions

Class Method Summary collapse

Methods included from QuickLoader

calculate_integers_for_gem_version, const_missing, load_full_rubygems_library, method_missing, push_all_highest_version_gems_on_load_path, push_gem_version_on_load_path

Class Method Details

.default_bindirObject

The default directory for binaries



151
152
153
154
155
156
157
# File 'lib/core/r4a/gems.rb', line 151

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



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/core/r4a/gems.rb', line 112

def self.default_dir
  if defined? RUBY_FRAMEWORK_VERSION then
    File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
              ConfigMap[:ruby_version]
  elsif RUBY_VERSION > '1.9' then
    File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], '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



143
144
145
146
# File 'lib/core/r4a/gems.rb', line 143

def self.default_exec_format
  baseruby = ConfigMap[:BASERUBY] || 'ruby'
  ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
end

.default_pathObject

Default gem load path



136
137
138
# File 'lib/core/r4a/gems.rb', line 136

def self.default_path
  [user_dir, default_dir]
end

.default_sourcesObject

An Array of the default sources that come with RubyGems



104
105
106
# File 'lib/core/r4a/gems.rb', line 104

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

.default_system_source_cache_dirObject

The default system-wide source info cache directory



162
163
164
# File 'lib/core/r4a/gems.rb', line 162

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



169
170
171
# File 'lib/core/r4a/gems.rb', line 169

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

.dirObject



44
45
46
47
48
# File 'lib/core/r4a/gems.rb', line 44

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

.ensure_gem_subdirectories(path) ⇒ Object



92
93
# File 'lib/core/r4a/gems.rb', line 92

def self.ensure_gem_subdirectories(path)
end

.pathObject



50
51
52
53
54
55
56
57
58
# File 'lib/core/r4a/gems.rb', line 50

def self.path
  @gem_path ||= nil
  unless @gem_path
    paths = [ENV['GEM_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



60
61
62
# File 'lib/core/r4a/gems.rb', line 60

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

.post_uninstall(&hook) ⇒ Object



64
65
66
# File 'lib/core/r4a/gems.rb', line 64

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

.pre_install(&hook) ⇒ Object



68
69
70
# File 'lib/core/r4a/gems.rb', line 68

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

.pre_uninstall(&hook) ⇒ Object



72
73
74
# File 'lib/core/r4a/gems.rb', line 72

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

.ruby_engineObject

A wrapper around RUBY_ENGINE const that may not be defined



176
177
178
179
180
181
182
# File 'lib/core/r4a/gems.rb', line 176

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

.set_home(home) ⇒ Object



76
77
78
79
# File 'lib/core/r4a/gems.rb', line 76

def self.set_home(home)
  @gem_home = home
  ensure_gem_subdirectories(@gem_home)
end

.set_paths(gpaths) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/core/r4a/gems.rb', line 81

def self.set_paths(gpaths)
  if gpaths
    @gem_path = gpaths.split(File::PATH_SEPARATOR)
    @gem_path << Gem.dir
  else
    @gem_path = [Gem.dir]
  end
  @gem_path.uniq!
  @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
end

.user_dirObject

Path for gems in the user's home directory



128
129
130
131
# File 'lib/core/r4a/gems.rb', line 128

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