Class: Nanoc3::Extra::Deployers::Rsync
- Inherits:
-
Object
- Object
- Nanoc3::Extra::Deployers::Rsync
- Defined in:
- lib/nanoc3/extra/deployers/rsync.rb
Overview
A deployer that deploys a site using rsync.
Constant Summary
- DEFAULT_OPTIONS =
Default rsync options
[ '-glpPrtvz', '--exclude=".hg"', '--exclude=".svn"', '--exclude=".git"' ]
Instance Method Summary (collapse)
-
- (Rsync) initialize
constructor
Creates a new deployer that uses rsync.
-
- (void) run(params = {})
Runs the task.
Constructor Details
- (Rsync) initialize
Creates a new deployer that uses rsync. The deployment configurations will be read from the configuration file of the site (which is assumed to be the current working directory).
The deployment configurations are stored like this in the site's configuration file:
deploy: NAME: options: [ OPTIONS ] dst: "DST"
NAME is a unique name for the deployment configuration. By default,
the deployer will use the deployment configuration named "default".
OPTIONS is an array containing options to pass to the rsync
executable. This is not required; by default, DEFAULT_OPTIONS options
will be used.
DST is a string containing the destination to where rsync should
upload its data. It will likely be in host:path format. For example,
"example.com:/var/www/sites/mysite/html". It should not end with a
trailing slash.
Example: This deployment configuration defines a "default" and a "staging" deployment configuration. The default options are used.
deploy: default: dst: "ectype:sites/stoneship/public" staging: dst: "ectype:sites/stoneship-staging/public" options: [ "-glpPrtvz" ]
When running the deployer with the default resp. staging
configurations, the following rsync commands will be executed:
rsync -glpPrtvz --exclude=".hg" --exclude=".svn" --exclude=".git" output ectype:sites/stoneship/public
rsync -glpPrtvz output ectype:sites/stoneship-staging/public
57 58 59 60 61 |
# File 'lib/nanoc3/extra/deployers/rsync.rb', line 57 def initialize # Get site error 'No site configuration found' unless File.file?('config.yaml') @site = Nanoc3::Site.new('.') end |
Instance Method Details
- (void) run(params = {})
This method returns an undefined value.
Runs the task. Possible params:
should not be executed, but still printed; false otherwise.
deployment configuration to use.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/nanoc3/extra/deployers/rsync.rb', line 72 def run(params={}) # Extract params config_name = params.has_key?(:config_name) ? params[:config_name].to_sym : :default dry_run = params.has_key?(:dry_run) ? params[:dry_run] : false # Validate config error 'No deploy configuration found' if @site.config[:deploy].nil? error "No deploy configuration found for #{config_name}" if @site.config[:deploy][config_name].nil? # Set arguments src = File.(@site.config[:output_dir]) + '/' dst = @site.config[:deploy][config_name][:dst] = @site.config[:deploy][config_name][:options] || DEFAULT_OPTIONS # Validate arguments error 'No dst found in deployment configuration' if dst.nil? error 'dst requires no trailing slash' if dst[-1,1] == '/' # Run if dry_run warn 'Performing a dry-run; no actions will actually be performed' run_shell_cmd([ 'echo', 'rsync', , src, dst ].flatten) else run_shell_cmd([ 'rsync', , src, dst ].flatten) end end |