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
Returns a new instance of 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() @options = @flags = @options[:flags] || ' -avz' @user = @options[:user] @port = @options[:port] @local = @options[:site_dir] || '_site' @remote_path = @options[:remote_path] @exclude = @options[:exclude] @exclude_from = @options[:exclude_from] @exclude_from = File.(@exclude_from) if @exclude_from @include = @options[:include] @include_from = @options[:include_from] @include_from = File.(@include_from) if @include_from @delete = @options[:delete] || false @pull_dir = @options[:dir] end |
Class Method Details
.default_config(options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/octopress-deploy/rsync.rb', line 64 def self.default_config(={}) <<-CONFIG #{"user: #{[:user]}".ljust(40)} # The user for your host, e.g. [email protected] #{"remote_path: #{[:remote_path]}".ljust(40)} # Destination directory #{"delete: #{[:delete]}".ljust(40)} # Remove files from destination which don't match files in source #{"port: #{[:port]}".ljust(40)} # If your host requires a non standard port #{"flags: #{[:flags] || ' -avz'}".ljust(40)} # Modify flags as necessary to suit your hosting setup #{"# exclude: ".ljust(40)} # files to exclude #{"# exclude-from: ".ljust(40)} # Path to file containing list of files to exclude #{"# include: ".ljust(40)} # files to include #{"# include-from: ".ljust(40)} # Path to file containing list of files to include CONFIG end |
Instance Method Details
#cmd ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/octopress-deploy/rsync.rb', line 36 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
31 32 33 34 |
# File 'lib/octopress-deploy/rsync.rb', line 31 def pull puts "Syncing #{@remote_path} files to #{@pull_dir} with rsync." system cmd end |
#push ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/octopress-deploy/rsync.rb', line 22 def push if File.exist?(@local) puts "Syncing #{@local} files to #{@remote_path} with rsync." system cmd else abort "Cannot find site build at #{@local}. Be sure to build your site first." end end |