Class: Rip::GemPackage

Inherits:
Package show all
Defined in:
lib/rip/packages/gem_package.rb

Instance Attribute Summary

Attributes inherited from Package

#files, #source

Instance Method Summary collapse

Methods inherited from Package

#cache_name, #cache_path, #dependencies, #fetch, #files!, for, handles, #installed?, #packages_path, #run_hook, #to_s, #ui, #unpack

Methods included from PackageAPI

#cached?, #files!, #meta_package?

Methods included from Memoize

included, #memoize, #method_added

Constructor Details

#initialize(source, *args) ⇒ GemPackage

Returns a new instance of GemPackage.



5
6
7
8
# File 'lib/rip/packages/gem_package.rb', line 5

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

Instance Method Details

#cache_fileObject



18
19
20
# File 'lib/rip/packages/gem_package.rb', line 18

def cache_file
  "#{cache_path}.gem"
end

#dependencies!Object



36
37
38
# File 'lib/rip/packages/gem_package.rb', line 36

def dependencies!
  Sh::Gem.dependencies(name)
end

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/rip/packages/gem_package.rb', line 22

def exists?
  ui.abort "can't find your gem command" unless Sh::Gem.check?

  File.exists?(source)
end

#fetch!Object



28
29
30
# File 'lib/rip/packages/gem_package.rb', line 28

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

#metadataObject



41
42
43
44
# File 'lib/rip/packages/gem_package.rb', line 41

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

#nameObject



10
11
12
# File 'lib/rip/packages/gem_package.rb', line 10

def name
  [:name]
end

#unpack!Object



32
33
34
# File 'lib/rip/packages/gem_package.rb', line 32

def unpack!
  Sh::Gem.rgem("unpack '#{cache_file}' --target='#{packages_path}' > /dev/null")
end

#versionObject



14
15
16
# File 'lib/rip/packages/gem_package.rb', line 14

def version
  [:version]
end