Sha256: f42eb681c9b72907f16c8d6c9f65eb54a5f3bbe8b8e93231bed0f4df397cfde9

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

require 'rake/tasklib'
require 'pathname'

module Rake
  class GemGhostTask < TaskLib
    attr_reader :name
    def initialize(name = nil)
      @name = name || Pathname.getwd.basename.to_s
      define
    end

  private

    def define
      desc "Replace system gem with symlink to this folder"
      task 'ghost' do
        if spec = Gem.source_index.find_name(name).sort_by(&:version).last
          gem_path = Pathname(spec.full_gem_path)
          current_path = Pathname.getwd.expand_path
          abort "#{gem_path.dirname} is not writable!" unless gem_path.dirname.writable?
          sh 'rm', '-r', gem_path
          sh 'ln', '-s', current_path, gem_path
        else
          abort 'Gem is not installed, install first'
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake-gem-ghost-0.0.2 lib/rake/gem_ghost_task.rb
rake-gem-ghost-0.0.1.3 lib/rake/gem_ghost_task.rb
rake-gem-ghost-0.0.1.2 lib/rake/gem_ghost_task.rb