Class: Octopress::Deploy::Rsync
- Inherits:
-
Object
- Object
- Octopress::Deploy::Rsync
- Defined in:
- lib/octopress-deploy/rsync.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cmd ⇒ Object
-
#initialize(options) ⇒ Rsync
constructor
A new instance of Rsync.
- #pull ⇒ Object
- #push ⇒ Object
Constructor Details
#initialize(options) ⇒ Rsync
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/octopress-deploy/rsync.rb', line 5 def initialize() = @flags = [:flags] || ' -avz' @user = [:user] @port = [:port] @local = [:site_dir] || '_site' @remote_path = [:remote_path] @exclude = [:exclude] @exclude_from = [:exclude_from] @exclude_from = File.(@exclude_from) if @exclude_from @include = [:include] @include_from = [:include_from] @include_from = File.(@include_from) if @include_from @delete = [:delete] || false @pull_dir = [:dir] end |
Class Method Details
.default_config(options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/octopress-deploy/rsync.rb', line 60 def self.default_config(={}) "\#{\"user: \#{options[:user]}\".ljust(40)} # The user for your host, e.g. [email protected]\n\#{\"remote_path: \#{options[:remote_path]}\".ljust(40)} # Destination directory\n\#{\"delete: \#{options[:delete]}\".ljust(40)} # Remove files from destination which don't match files in source\n\#{\"port: \#{options[:port]}\".ljust(40)} # If your host requires a non standard port\n\#{\"flags: \#{options[:flags] || ' -avz'}\".ljust(40)} # Modify flags as necessary to suit your hosting setup\n\n\#{\"# exclude: \".ljust(40)} # files to exclude\n\#{\"# exclude-from: \".ljust(40)} # Path to file containing list of files to exclude\n\#{\"# include: \".ljust(40)} # files to include\n\#{\"# include-from: \".ljust(40)} # Path to file containing list of files to include\n" end |
Instance Method Details
#cmd ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/octopress-deploy/rsync.rb', line 32 def cmd local = '' remote = '' cmd = "rsync " cmd << "#{@flags} " cmd << " --exclude-from #{@exclude_from}" if @exclude_from Array(@exclude).each do |e| cmd << " --exclude #{e}" end cmd << " --include-from #{@include_from}" if @include_from Array(@include).each do |i| cmd << " --include #{i}" end cmd << " --rsh='ssh -p#{@port}'" if @user && @port cmd << " --delete " if @delete local << " #{File.join(@local, '')} " remote << " #{@user}:" if @user remote << "#{@remote_path}" if @pull_dir cmd << remote+'/ ' << @pull_dir else cmd << local << remote end end |
#pull ⇒ Object
27 28 29 30 |
# File 'lib/octopress-deploy/rsync.rb', line 27 def pull puts "Syncing #{@remote_path} files to #{@pull_dir} with rsync." system cmd end |
#push ⇒ Object
22 23 24 25 |
# File 'lib/octopress-deploy/rsync.rb', line 22 def push puts "Syncing #{@local} files to #{@remote_path} with rsync." system cmd end |