Class: Backup::Syncer::Base

Inherits:
Object
  • Object
show all
Includes:
Config::Helpers, Utilities::Helpers
Defined in:
lib/backup/syncer/base.rb

Direct Known Subclasses

Cloud::Base, Cloud::S3, RSync::Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Config::Helpers

included

Constructor Details

#initialize(syncer_id = nil) ⇒ Base

Returns a new instance of Base.



23
24
25
26
27
28
29
30
31
# File 'lib/backup/syncer/base.rb', line 23

def initialize(syncer_id = nil)
  @syncer_id = syncer_id

  load_defaults!

  @mirror ||= false
  @directories ||= []
  @excludes ||= []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers

Instance Attribute Details

#excludesObject (readonly)

Returns the value of attribute excludes.



21
22
23
# File 'lib/backup/syncer/base.rb', line 21

def excludes
  @excludes
end

#mirrorObject

Flag for mirroring the files/directories



13
14
15
# File 'lib/backup/syncer/base.rb', line 13

def mirror
  @mirror
end

#pathObject

Path to store the synced files/directories to



9
10
11
# File 'lib/backup/syncer/base.rb', line 9

def path
  @path
end

#syncer_idObject (readonly)

Optional user-defined identifier to differentiate multiple syncers defined within a single backup model. Currently this is only used in the log messages.



19
20
21
# File 'lib/backup/syncer/base.rb', line 19

def syncer_id
  @syncer_id
end

Instance Method Details

#add(path) ⇒ Object



40
41
42
# File 'lib/backup/syncer/base.rb', line 40

def add(path)
  directories << path
end

#directories(&block) ⇒ Object

Syntactical suger for the DSL for adding directories



35
36
37
38
# File 'lib/backup/syncer/base.rb', line 35

def directories(&block)
  return @directories unless block_given?
  instance_eval(&block)
end

#exclude(pattern) ⇒ Object

For Cloud Syncers, pattern can be a string (with shell-style wildcards) or a regex. For RSync, each pattern will be passed to rsync’s –exclude option.



47
48
49
# File 'lib/backup/syncer/base.rb', line 47

def exclude(pattern)
  excludes << pattern
end