Sha256: c9a559a78b390e1f60020a349a566a662a0b681e7afd4d932b122564e8c1dce3

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$:.unshift File.join(ROOT_PATH, "lib")
$:.unshift File.join(ROOT_PATH, "vendor", "dropbox-client-ruby", "lib")

require "dropbox"
require "fileutils"
require "time"
require "yaml"
require "logger"

require "dbox/loggable"
require "dbox/api"
require "dbox/db"

module Dbox
  def self.authorize
    Dbox::API.authorize
  end

  def self.create(remote_path, local_path)
    remote_path = clean_remote_path(remote_path)
    local_path = clean_local_path(local_path)
    Dbox::DB.create(remote_path, local_path)
  end

  def self.clone(remote_path, local_path)
    remote_path = clean_remote_path(remote_path)
    local_path = clean_local_path(local_path)
    Dbox::DB.clone(remote_path, local_path)
  end

  def self.pull(local_path)
    local_path = clean_local_path(local_path)
    Dbox::DB.pull(local_path)
  end

  def self.push(local_path)
    local_path = clean_local_path(local_path)
    Dbox::DB.push(local_path)
  end

  private

  def self.clean_remote_path(path)
    raise(ArgumentError, "Missing remote path") unless path
    path.sub(/\/$/,'')
    path[0].chr == "/" ? path : "/#{path}"
  end

  def self.clean_local_path(path)
    raise(ArgumentError, "Missing local path") unless path
    File.expand_path(path)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbox-0.3.0 lib/dbox.rb