Class: Nanoc3::Extra::Deployers::Rsync
Nanoc3::Extra::Deployers::Rsync is a deployer that deploys a site using rsync.
Constructor Summary
public
initialize
Creates a new deployment task that uses rsync. The deployment configuration will be taken from the site’s configuration file.
[View source]
10 11 12 13 14 |
# File 'lib/nanoc3/extra/deployers/rsync.rb', line 10 def initialize # Get site error 'No site configuration found' unless File.file?('config.yaml') @site = Nanoc3::Site.new('.') end |
Public Visibility
Public Instance Method Summary
| #run(params = {}) |
Runs the task. |
|---|
Public Instance Method Details
run
public
run(params = {})
Runs the task. Possible params:
| :dry_run: | Set to true when the action itself should not be executed, but still printed. Useful for debugging. |
| :config_name: | The name of the deployment configuration to use. Defaults to :default (surprise!). |
[View source]
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nanoc3/extra/deployers/rsync.rb', line 23 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] || [] # 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 |