Class: Megam::CmdVerb

Inherits:
Object
  • Object
show all
Defined in:
lib/megam/cmd_verb.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCmdVerb

Returns a new instance of CmdVerb.



20
21
# File 'lib/megam/cmd_verb.rb', line 20

def initialize
end

Class Method Details

.cp(opts = {}) ⇒ Object

cp -r -s <from directory> <to directory>



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/megam/cmd_verb.rb', line 24

def self.cp(opts={}) 
  cp =""
  cp << "sudo " if opts[:sudo]
  cp << "cp"
  cp << " -r " if opts[:recursive]
 #   cp << " -u " if opts[:copy_on_new] #copy  only  when  the  SOURCE file is newer than
  cp << opts[:from_dir] if opts[:from_dir] or raise Megam::Exceptions::FileNotFound
  cp << " "
  cp << opts[:to_dir] if opts[:to_dir] or raise Megam::Exceptions::FileNotFound
  cp
end

.untar(opts = {}) ⇒ Object

gunzip -c foo.tar.gz | tar xvf -



37
38
39
40
41
42
43
# File 'lib/megam/cmd_verb.rb', line 37

def self.untar(opts={})
  untar = "gunzip -c "
  untar << opts[:tar_file] if opts[:tar_file] 
  untar << " | tar xvf - -C "
  untar << opts[:to_dir] if opts[:to_dir]
  untar    
end

Instance Method Details

#to_sObject



45
46
47
# File 'lib/megam/cmd_verb.rb', line 45

def to_s
  "cmdverb -> [supports cp, untar *only]"
end