Sha256: 39e3d51be9b1c95d8a7aeb303a578a5fdf2dedc76772f69979351030b527c6d2

Contents?: true

Size: 1.15 KB

Versions: 42

Compression:

Stored size: 1.15 KB

Contents

require "fileutils"
require "tmpdir"
require "rubygems/installer"

class FakeGem
  DEFAULT_VERSION = "99.0.0"

  include Gem::UserInteraction

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

  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

private
  def specification
    @specification ||= Gem::Specification.new{ |s|
      s.name          = @name
      s.version       = @version
      s.summary       = "Fake #@name gem"
      s.author        = "Nobody"
      s.email         = "nobody@localhost"
      s.description   = "Fake gem"
      s.homepage      = "http://website.com"
      s.has_rdoc      = false
      s.files         = []
      s.executables   = []
      s.require_paths = ["lib"]
    }
  end

  def build_gem
    FileUtils.mkdir_p("lib")
    Gem::Builder.new(specification).build
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
fwtoolkit-2.6.4 features/support/lib_test/fake_gem.rb
fwtoolkit-2.6.3 features/support/lib_test/fake_gem.rb
fwtoolkit-2.6.2 features/support/lib_test/fake_gem.rb
fwtoolkit-2.6.1 features/support/lib_test/fake_gem.rb
fwtoolkit-2.6.0 features/support/lib_test/fake_gem.rb
fwtoolkit-2.5.0 features/support/lib_test/fake_gem.rb
fwtoolkit-2.4.0 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.6 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.5 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.4 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.3 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.2 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.1 features/support/lib_test/fake_gem.rb
fwtoolkit-2.3.0 features/support/lib_test/fake_gem.rb
fwtoolkit-2.2.4 features/support/lib_test/fake_gem.rb
fwtoolkit-2.2.3 features/support/lib_test/fake_gem.rb
fwtoolkit-2.2.2 features/support/lib_test/fake_gem.rb
fwtoolkit-2.2.1 features/support/lib_test/fake_gem.rb
fwtoolkit-2.2.0 features/support/lib_test/fake_gem.rb
fwtoolkit-2.1.10 features/support/lib_test/fake_gem.rb