A simple gem for copying, synching, and deleting entire folders over FTP. Adds
two new public methods to Net::FTP —
put_dir takes a hash of arguments:
- local - (string) The relative or absolute path to the local directory to be copied.
- remote - (string) The relative or absolute remote path that the local directory will be copied to.
- verbose - (bool: defaults to false) Will output progress if set to true.
- erase - (bool: defaults to false) If set to true,
put_dirwill overwrite any existing directories (default behavior is to update changed files only).
- exclude - (array) A list of any files in local directory to be excluded.
All file paths in
excludeshould be relative to
rmrf_dir takes two arguments: the path to the remote directory
to be deleted, and a verbose boolean flag (defaulted to false).
To use FTPExt, require it and use Net::FTP as normal. Because FTPExt requires Net::FTP for you, you don't need to include it separately.
require 'rubygems' require 'ftp-ext' ftp = Net::FTP.new('ftp/server/address') ftp.login('username', 'password') ftp.put_dir(:local => 'path/to/local', :remote => 'path/to/remote')
For example, imagine I have a local directory,
/Users/zpendleton/code, that I want to upload on my server to the
/home/zpendleton directory. I'd run the following command:
code directory already exists in
/home/zpendleton, it will be updated (the script checks the
last modified timestamps of all files). If the
doesn't exist, it will be created. To overwrite the
directory on the server, set the
:erase option in
To later delete the
/home/zpendleton/code directory (in verbose
mode), you would use:
To leave verbose mode turned off, you would just omit the second parameter.
- Fork the project.
- Create a branch (
git checkout -b my_edit).
- Commit your changes (
git commit -am "Added feature").
- Push to the branch (
git push origin my_edit).
- Create an issue with a link to your branch.
- Kick it old school to this while you wait.
Copyright (c) 2010 Zach Pendleton. See LICENSE for details.