Class: FakeGem

Inherits:
Object
  • Object
show all
Includes:
Gem::UserInteraction
Defined in:
lib/fake_gem.rb

Constant Summary collapse

DEFAULT_VERSION =
"99.0.0"
SUMMARY =
"Make RubyGems think that a gem is already installed."

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ FakeGem

Returns a new instance of FakeGem.



11
12
13
14
15
# File 'lib/fake_gem.rb', line 11

def initialize(name, options={})
  @name = name
  @options = {:install_dir => Gem.dir}.merge(options)
  @version = options.delete(:version) || DEFAULT_VERSION
end

Instance Method Details

#installObject



17
18
19
20
21
22
23
24
25
# File 'lib/fake_gem.rb', line 17

def install
  temp_path = File.join(Dir.tmpdir, "fakegem.#{Process.pid}")
  FileUtils.mkdir_p(temp_path)
  Dir.chdir(temp_path) do
    build_gem
    Gem::Installer.new(specification.file_name, @options).install
  end
  say "Fake gem #@name #@version is now installed"
end