Module: Capsaicin::Files::Local

Includes:
FileUtils::Verbose
Defined in:
lib/capsaicin/files/local.rb

Instance Method Summary collapse

Instance Method Details

#cd(dir, options = {}) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/capsaicin/files/local.rb', line 36

def cd(dir, options={})
  if block_given?
    dir, dir2 = pwd, dir
    cd dir2
    yield
  end  
  cd dir
end

#download(from, to) ⇒ Object



32
33
34
# File 'lib/capsaicin/files/local.rb', line 32

def download(from, to)
  cp from, to
end

#tail_f(file, n = 10) ⇒ Object



21
22
23
24
25
26
# File 'lib/capsaicin/files/local.rb', line 21

def tail_f(file, n=10)
  unless defined? File::Tail::Logfile then gem 'file-tail'; require 'file/tail' end
  File::Tail::Logfile.tail(file, :backward=>n) do |line| puts line end
rescue Interrupt
  logger.trace "interrupted (Ctrl-C)" if logger
end

#tar_c(dest, src, options = {}, &filter) ⇒ Object



45
46
47
48
49
# File 'lib/capsaicin/files/local.rb', line 45

def tar_c(dest, src, options={}, &filter)
  logger and
    logger.trace "tar -cf #{dest} " + Array(src).map { |s| s.gsub ' ', '\\ ' }.join(' ')
  _tar File.open(dest, 'wb'), src, v, &filter
end

#tar_cz(dest, src, options = {}, &filter) ⇒ Object



51
52
53
54
55
56
# File 'lib/capsaicin/files/local.rb', line 51

def tar_cz(dest, src, options={}, &filter)
  require 'zlib' unless defined? Zlib::GzipWriter
  logger and
    logger.trace "tar -czf #{dest} " + Array(src).map { |s| s.gsub ' ', '\\ ' }.join(' ')
  _tar Zlib::GzipWriter.new(File.open(dest, 'wb')), src, options, &filter
end

#upload(from, to) ⇒ Object



28
29
30
# File 'lib/capsaicin/files/local.rb', line 28

def upload(from, to)
  cp from, to
end