forked from backup/backup
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add RSync::Base - adjust paths according to direction - ensure removal of temporary password file - update all specs
- Loading branch information
Brian D. Burns
committed
Jan 12, 2012
1 parent
9be16f7
commit d813160
Showing
24 changed files
with
1,009 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# encoding: utf-8 | ||
|
||
module Backup | ||
module Configuration | ||
module Syncer | ||
class Base < Configuration::Base; end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# encoding: utf-8 | ||
|
||
module Backup | ||
module Configuration | ||
module Syncer | ||
module RSync | ||
class Base < Syncer::Base | ||
class << self | ||
|
||
## | ||
# Path to store the synced files/directories to | ||
attr_accessor :path | ||
|
||
## | ||
# Flag for mirroring the files/directories | ||
attr_accessor :mirror | ||
|
||
## | ||
# Additional options for the rsync cli | ||
attr_accessor :additional_options | ||
|
||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# encoding: utf-8 | ||
|
||
module Backup | ||
module Syncer | ||
module RSync | ||
class Base < Syncer::Base | ||
|
||
## | ||
# Path to store the synced files/directories to | ||
attr_accessor :path | ||
|
||
## | ||
# Directories to sync | ||
attr_writer :directories | ||
|
||
## | ||
# Flag for mirroring the files/directories | ||
attr_accessor :mirror | ||
|
||
## | ||
# Additional options for the rsync cli | ||
attr_accessor :additional_options | ||
|
||
## | ||
# Instantiates a new RSync Syncer object | ||
# and sets the default configuration | ||
def initialize | ||
load_defaults! | ||
|
||
@path ||= 'backups' | ||
@directories = Array.new | ||
@mirror ||= false | ||
@additional_options ||= Array.new | ||
end | ||
|
||
## | ||
# Syntactical suger for the DSL for adding directories | ||
def directories(&block) | ||
return @directories unless block_given? | ||
instance_eval(&block) | ||
end | ||
|
||
## | ||
# Adds a path to the @directories array | ||
def add(path) | ||
@directories << path | ||
end | ||
|
||
private | ||
|
||
## | ||
# Returns the @directories as a space-delimited string of | ||
# single-quoted values for use in the `rsync` command line. | ||
# Each path is expanded, since these refer to local paths | ||
# for both RSync::Local and RSync::Push. | ||
# RSync::Pull does not use this method. | ||
def directories_option | ||
@directories.map do |directory| | ||
"'#{ File.expand_path(directory) }'" | ||
end.join(' ') | ||
end | ||
|
||
## | ||
# Returns Rsync syntax for enabling mirroring | ||
def mirror_option | ||
'--delete' if @mirror | ||
end | ||
|
||
## | ||
# Returns Rsync syntax for invoking "archive" mode | ||
def archive_option | ||
'--archive' | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.