Class: Closync::Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/closync/sync.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Sync

Returns a new instance of Sync.



6
7
8
9
10
11
12
# File 'lib/closync/sync.rb', line 6

def initialize(config)
  @config = config
  raise 'Local directory not configured' unless config.local
  raise 'Remote directory not configured' unless config.remote
  @local = Closync::Storage.new(config, config.local)
  @remote = Closync::Storage.new(config, config.remote)
end

Instance Method Details

#push!Object



14
15
16
17
18
19
20
21
# File 'lib/closync/sync.rb', line 14

def push!
  @local.directory.files.each do |local_file|
    upload!(local_file) if stale_on_remote?(local_file)
  end
  @remote.directory.files.each do |remote_file|
    remote_file.destroy unless exists_locally?(remote_file)
  end
end