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.



67
68
69
70
71
72
73
74
# File 'lib/lsync/directory.rb', line 67

def initialize(path)
	@path = Pathname.new(path).cleanpath.normalize_trailing_slash
	@options = {:arguments => []}
	
	if @path.absolute?
		raise AbsolutePathError.new("Path #{path} may not be absolute!", :path => path)
	end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



77
78
79
# File 'lib/lsync/directory.rb', line 77

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



76
77
78
# File 'lib/lsync/directory.rb', line 76

def path
  @path
end

Instance Method Details

#exclude(pattern) ⇒ Object

Exclude a specific shell glob pattern.



80
81
82
83
# File 'lib/lsync/directory.rb', line 80

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.



86
87
88
# File 'lib/lsync/directory.rb', line 86

def to_s
	@path.to_s
end