Class: MultiSync::LocalTarget
- Inherits:
-
Target
- Object
- Target
- MultiSync::LocalTarget
show all
- Defined in:
- lib/multi_sync/targets/local_target.rb
Instance Method Summary
collapse
Methods inherited from Target
#initialize
Instance Method Details
#delete(resource) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/multi_sync/targets/local_target.rb', line 40
def delete(resource)
MultiSync.debug "Delete #{resource} '#{resource.path_without_root}' from #{self} '#{File.join(connection.local_root, destination_dir)}'"
connection.directories.get(destination_dir.to_s).files.get(resource.path_without_root.to_s).destroy
resource
end
|
#files ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/multi_sync/targets/local_target.rb', line 10
def files
files = []
directory = connection.directories.get(destination_dir.to_s)
return files if directory.nil?
directory.files.each { |file|
pathname = Pathname.new(file.key)
next if pathname.directory?
files << MultiSync::RemoteResource.new(
file: file,
path_with_root: target_dir + destination_dir + pathname,
path_without_root: pathname
)
}
files.sort
end
|
#upload(resource) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/multi_sync/targets/local_target.rb', line 31
def upload(resource)
MultiSync.debug "Upload #{resource} '#{resource.path_without_root}' to #{self} '#{File.join(connection.local_root, destination_dir)}'"
directory = connection.directories.get(destination_dir.to_s)
return if directory.nil?
directory.files.create(key: resource.path_without_root.to_s, body: resource.body)
resource
end
|