Module | Rye::Cmd |
In: |
lib/rye/cmd.rb
|
This class contains all of the shell command methods available to an instance of Rye::Box. For security and general safety, Rye only permits this whitelist of commands by default. However, you‘re free to add methods with mixins.
require 'rye' module Rye::Box::Cmd def special(*args); run_command("/your/special/command", args); end end rbox = Rye::Box.new('somehost') rbox.special # => "special on somehost"
A helper for adding a command to Rye::Cmd.
An optional block can be provided which will be called instead of calling a system command.
Same as file_download except directories are processed recursively. If any supplied paths are directories you need to use this method and not file_download.
Same as file_upload except directories are processed recursively. If any supplied paths are directories you need to use this method and not file_upload.
Append newcontent to remote filepath. If the file doesn‘t exist it will be created. If backup is specified, filepath will be copied to +filepath-previous+ before appending.
NOTE: Not recommended for large files. It downloads the contents.
Transfer files from a machine via Net::SCP.
local directory to download to. If downloading a single file the last element can be a file path. The target can also be a StringIO object. The target directory will be created if it does not exist, but only when multiple files are being transferred. This method will fail early if there are obvious problems with the input parameters. An exception is raised and no files are transferred. Return nil or a StringIO object, if specified as the target.
NOTE: Changes to current working directory with cd or +[]+ are ignored.
Transfer files to a machine via Net::SCP.
directory to upload to. If uploading a single file, the last element can be a file path. The list of files can also include StringIO objects. The target directory will be created if it does not exist, but only when multiple files are being transferred. This method will fail early if there are obvious problems with the input parameters. An exception is raised and no files are transferred. Always return nil.
NOTE: Changes to current working directory with cd or +[]+ are ignored.
Does the calculated digest of path match the known expected_digest? This is useful for verifying downloaded files. digest_type must be one of: :md5, :sha1, :sha2
Write newcontent to remote filepath. If the file exists it will be overwritten. If backup is specified, filepath will be copied to +filepath-previous+ before appending.
Shorthand for +file_append(‘remote/path’, StringIO.new(‘file content’))+
Appends the content of the String str to remote_path. Returns nil
Shorthand for +file_download(‘remote/path’).string+
Returns a String containing the content of all remote paths.
Shorthand for +file_upload(StringIO.new(‘file content’), ‘remote/path’)+
Uploads the content of the String str to remote_path. Returns nil