Module: FasterRubyGems

Defined in:
lib/faster_rubygems/install_helper.rb

Class Method Summary collapse

Class Method Details

.install_over_rubygems!(aggressive = false) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/faster_rubygems/install_helper.rb', line 3

def self.install_over_rubygems! aggressive = false
  raise 'only needed on 1.8 -- for 1.9 you have to do
  $ export RUBYOPT=$RUBYOPT -rfaster_rubygems' if RUBY_VERSION >= '1.9.0'
  require 'fileutils'
  old = rubygems_path
  new =  old + ".bak.rb"
  raise 'cannot install twice--please run unoverride first' if File.exist?(new)
  FileUtils.cp old, new
  File.open(old, 'w') do |f|
    f.write "require 'faster_rubygems'\n"
    f.write "require 'faster_require'" if aggressive
  end
  puts 'success--it will load by default in place of normal rubygems'
end

.rubygems_pathObject



18
19
20
21
22
23
# File 'lib/faster_rubygems/install_helper.rb', line 18

def self.rubygems_path
  Gem::Dependency
  raise unless $LOADED_FEATURES.include? "rubygems.rb"
  # now go and look for it
  $:.detect{|path| File.exist?(path + '/rubygems.rb') || File.exist?(path + '/rubygems.rb.bak.rb')} + "/rubygems.rb"
end

.uninstall_over_rubygems!Object



25
26
27
28
29
30
31
32
# File 'lib/faster_rubygems/install_helper.rb', line 25

def self.uninstall_over_rubygems!
  raise 'only needed on 1.8' if RUBY_VERSION >= '1.9.0'
  require 'fileutils'
  old = rubygems_path + ".bak.rb"
  FileUtils.cp old, rubygems_path
  File.delete old
  puts 'successfully reverted back to normal rubygems'
end