Sha256: 972db1ea9de8bde4c97869140eb342eeaadcd3a1fbe3ee6984489909f5e8ef56

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 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 #{gembin}`.strip.empty?
        ui.abort "you don't have #{gembin} installed"
      end

      File.exists?(source)
    end

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

    def unpack!
      system "'#{gembin}' 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

    def gembin
      ENV['GEMBIN'] || 'gem'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rip-0.0.3 lib/rip/packages/gem_package.rb
rip-0.0.2 lib/rip/packages/gem_package.rb