Class: Rip::DirPackage

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

Instance Attribute Summary

Attributes inherited from Package

#files, #source

Instance Method Summary collapse

Methods inherited from Package

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

Methods included from PackageAPI

#cached?, #dependencies!, #files!, #meta_package?, #unpack!

Methods included from Memoize

included, #memoize, #method_added

Constructor Details

#initialize(source, *args) ⇒ DirPackage

Returns a new instance of DirPackage.



7
8
9
10
# File 'lib/rip/packages/dir_package.rb', line 7

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

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rip/packages/dir_package.rb', line 12

def exists?
  File.directory? source
end

#fetch!Object



29
30
31
32
# File 'lib/rip/packages/dir_package.rb', line 29

def fetch!
  FileUtils.rm_rf cache_path
  FileUtils.cp_r "#{source}/.", cache_path
end

#nameObject



17
18
19
# File 'lib/rip/packages/dir_package.rb', line 17

def name
  File.basename(source)
end

#versionObject



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

def version
  if name.match(/-((?:\d+\.?)+\d+)$/)
    $1
  else
    "unversioned"
  end
end