Skip to content

Instantly share code, notes, and snippets.

@rcrowley
Forked from defunkt/fake_rubygems.rb
Created October 31, 2009 20:08
Show Gist options
  • Save rcrowley/223216 to your computer and use it in GitHub Desktop.
Save rcrowley/223216 to your computer and use it in GitHub Desktop.
# Fake RubyGems
# http://gist.github.com/223216 is an expansion of Chris'
# http://gist.github.com/157899 that allows Rails to work properly
module Rip
module Commands
FAKE_RUBYGEMS = <<EOM
require 'thread'
def gem(name, *args)
raise LoadError if name =~ /adapter$/
raise Gem::LoadError unless name =~ /^rails|rack$/
end
module Gem
RubyGemsVersion = VERSION = '1.3.5'
class LoadError < Exception
end
class Dependency
end
class SourceIndex
def initialize(*args)
end
def refresh!
end
end
def self.source_index
SourceIndex.new
end
class LoadedSpecs < Array
def values
self
end
end
def self.loaded_specs
LoadedSpecs.new
end
def self.clear_paths
end
class Requirement
def initialize(*args)
end
def self.default
end
def self.create(*args)
end
end
end
EOM
o 'rip fake_rubygems [-d]'
x "Installs a rubygems.rb stub into the current ripenv."
x "Useful when dealing with libraries that require 'rubygems'"
x
x "The -d option deletes the stub."
def fake_rubygems(options = {}, *args)
file = File.join(Rip::Env.active_dir, 'lib', 'rubygems.rb')
# un-fake rubygems
if options[:d]
if File.exists? file
FileUtils.rm file
ui.abort "un-faked rubygems"
else
ui.abort "you haven't faked rubygems yet"
end
end
if File.exists?(file)
ui.abort "already faked rubygems in #{Rip::Env.active} ripenv"
else
File.open(file, 'w') do |f|
f.puts FAKE_RUBYGEMS
f.flush
end
ui.puts "rip: rubygems successfully faked"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment