lib/knj/cmd_gen.rb in knjrbfw-0.0.30 vs lib/knj/cmd_gen.rb in knjrbfw-0.0.31

- old
+ new

@@ -1,6 +1,21 @@ +#This class holds various methods to generate commands for command-line-purpose. class Knj::Cmd_gen + #Generates rsync commands as strings. + #===Examples + # Knj::Cmd_gen.rsync( + # :bin => "/usr/bin/rsync", + # :verbose => 2, + # :ssh => true, + # :port => 10022, + # :delete => true, + # :exclude => "cache", + # :user => "username", + # :host => "mydomain.com", + # :dir_host => "/home/username/sync_path", + # :dir_local => "/home/otheruser/sync_path" + # ) #=> <String> def self.rsync(args) cmd = "" if args[:bin] cmd << args[:bin] @@ -37,9 +52,21 @@ cmd << " \"#{args[:user]}@#{args[:host]}:#{args[:dir_host]}\" \"#{args[:dir_local]}\"" return cmd end + #Generates tar commands. + #===Examples + # Knj::Cmd_gen.tar( + # :bin => "/usr/bin/tar", + # :gzip => true, + # :extract => false, + # :file => true, + # :create => true, + # :verbose => 1, + # :archive_path => "~/myarchive.tar.gz", + # :paths => ["~/mylib1", "~/mylib2", "~/mylib3"] + # ) #=> <String> def self.tar(args) cmd = "" if args[:bin] cmd << args[:bin] \ No newline at end of file