Class: FPM::Fry::Source::Dir::Cache

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fpm/fry/source/dir.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dirObject

Returns the value of attribute dir

Returns:

  • (Object)

    the current value of dir



21
22
23
# File 'lib/fpm/fry/source/dir.rb', line 21

def dir
  @dir
end

#packageObject

Returns the value of attribute package

Returns:

  • (Object)

    the current value of package



21
22
23
# File 'lib/fpm/fry/source/dir.rb', line 21

def package
  @package
end

Instance Method Details

#cachekeyObject



35
36
37
38
39
40
41
# File 'lib/fpm/fry/source/dir.rb', line 35

def cachekey
  dig = Digest::SHA2.new
  tar_io.each(1024) do |block|
    dig << block
  end
  return dig.hexdigest
end

#copy_to(dst) ⇒ Object



30
31
32
33
# File 'lib/fpm/fry/source/dir.rb', line 30

def copy_to(dst)
  children = ::Dir.new(dir).select{|x| x[0...1] != "." }.map{|x| File.join(dir,x) }
  FileUtils.cp_r(children, dst)
end

#prefixObject



43
44
45
# File 'lib/fpm/fry/source/dir.rb', line 43

def prefix
  Source::prefix(dir)
end

#tar_ioObject



26
27
28
# File 'lib/fpm/fry/source/dir.rb', line 26

def tar_io
  Exec::popen('tar','-c','.', chdir: dir, logger: logger)
end