Class: Dbox::Syncer

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/dbox/syncer.rb

Defined Under Namespace

Classes: Operation, Pull, Push

Constant Summary collapse

MIN_BYTES_TO_STREAM_DOWNLOAD =

100kB

1024 * 100

Class Method Summary collapse

Methods included from Loggable

included, #log

Class Method Details

.apiObject



34
35
36
# File 'lib/dbox/syncer.rb', line 34

def self.api
  @@_api ||= API.connect
end

.clone(remote_path, local_path) ⇒ Object



12
13
14
15
16
# File 'lib/dbox/syncer.rb', line 12

def self.clone(remote_path, local_path)
  api.(remote_path) # ensure remote exists
  database = Database.create(remote_path, local_path)
  Pull.new(database, api).execute
end

.create(remote_path, local_path) ⇒ Object



7
8
9
10
# File 'lib/dbox/syncer.rb', line 7

def self.create(remote_path, local_path)
  api.create_dir(remote_path)
  clone(remote_path, local_path)
end

.move(new_remote_path, local_path) ⇒ Object



28
29
30
31
32
# File 'lib/dbox/syncer.rb', line 28

def self.move(new_remote_path, local_path)
  database = Database.load(local_path)
  api.move(database.[:remote_path], new_remote_path)
  database.(:remote_path => new_remote_path)
end

.pull(local_path) ⇒ Object



18
19
20
21
# File 'lib/dbox/syncer.rb', line 18

def self.pull(local_path)
  database = Database.load(local_path)
  Pull.new(database, api).execute
end

.push(local_path) ⇒ Object



23
24
25
26
# File 'lib/dbox/syncer.rb', line 23

def self.push(local_path)
  database = Database.load(local_path)
  Push.new(database, api).execute
end