Class: LSync::Directory

Inherits:
Object
  • Object
show all
Includes:
EventHandler
Defined in:
lib/lsync/directory.rb

Overview

A specific directory which is relative to the root of a given server. Specific configuration details such as excludes and other options may be specified.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EventHandler

#abort!, #fire, #on, #try

Constructor Details

#initialize(path) ⇒ Directory

Returns a new instance of Directory.



44
45
46
47
# File 'lib/lsync/directory.rb', line 44

def initialize(path)
  @path = Pathname.new(path).cleanpath.normalize_trailing_slash
  @options = {:arguments => []}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



50
51
52
# File 'lib/lsync/directory.rb', line 50

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



49
50
51
# File 'lib/lsync/directory.rb', line 49

def path
  @path
end

Instance Method Details

#exclude(pattern) ⇒ Object

Exclude a specific shell glob pattern.



53
54
55
56
# File 'lib/lsync/directory.rb', line 53

def exclude(pattern)
  # RSync specific... need to figure out if there is a good way to do this generally.
  @options[:arguments] += ["--exclude", pattern]
end

#to_sObject

A string representation of the path for logging.



59
60
61
# File 'lib/lsync/directory.rb', line 59

def to_s
  @path.to_s
end