Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created July 29, 2009 06:29
Show Gist options
  • Save defunkt/157899 to your computer and use it in GitHub Desktop.
Save defunkt/157899 to your computer and use it in GitHub Desktop.
A Rip plugin for stubbing out RubyGems.
# file:lib/rip/commands/fake_rubygems.rb
module Rip
module Commands
FAKE_RUBYGEMS = "def gem(*args)end;module Gem;end"
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