sr (owner)

Fork Of

gist: 157899 by defunkt A Rip plugin for stubbing o...

Revisions

gist: 189782 Download_button fork
public
Public Clone URL: git://gist.github.com/189782.git
Embed All Files: show embed
fake_rubygems.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# file:lib/rip/commands/fake_rubygems.rb
module Rip
  module Commands
    FAKE_RUBYGEMS = <<-RUBY
def gem(*args)end
module Gem
def self.ruby; `which ruby`.chomp; end
end
RUBY
 
    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