Sha256: 2fac358ead6900a3d262054365c5e4914ad7f30630fe4eb7c55fa99e6f7e05df

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 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 = nil)
    remote_path = clean_remote_path(remote_path)
    local_path ||= remote_path.split("/").last
    Dbox::DB.create(remote_path, local_path)
  end

  def self.clone(remote_path, local_path = nil)
    remote_path = clean_remote_path(remote_path)
    local_path ||= remote_path.split("/").last
    Dbox::DB.clone(remote_path, local_path)
  end

  def self.pull(local_path = nil)
    local_path ||= "."
    Dbox::DB.pull(local_path)
  end

  def self.push(local_path = nil)
    local_path ||= "."
    Dbox::DB.push(local_path)
  end

  private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbox-0.2.0 lib/dbox.rb