Sha256: 169dda27dab953e2a28592a2a20f56ef711509d58cb217b645502b5b1fa40167

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

module Rip
  class GemPackage < Package
    handles '.gem'

    def initialize(source, *args)
      super
      @source = File.expand_path(source.strip.chomp)
    end

    def name
      metadata[:name]
    end

    def version
      metadata[:version]
    end

    def cache_file
      "#{cache_path}.gem"
    end

    def exists?
      if `which gem`.strip.empty?
        ui.abort "you don't have rubygems installed"
      end

      File.exists?(source)
    end

    def fetch!
      FileUtils.cp File.expand_path(source), cache_file
    end

    def unpack!
      system "gem unpack #{cache_file} --target=#{packages_path} > /dev/null"
    end

    memoize :metadata
    def metadata
      parts = source.split('/').last.chomp('.gem').split('-')
      { :name => parts[0...-1].join('-'), :version => parts[-1] }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rip-0.0.1 lib/rip/packages/gem_package.rb