class SifttterRedux::DropboxUploader

DropboxUploader Class Wrapper class for the Dropbox Uploader project

Attributes

local_target[RW]

Stores the local filepath. @return [String]

message[RW]

Stores the message to display. @return [String]

remote_target[RW]

Stores the remote filepath. @return [String]

verbose[RW]

Stores the verbosity level. @return [Boolean]

Public Class Methods

new(dbu_path, logger = nil) click to toggle source

Loads the location of dropbox_uploader.sh. @param [String] dbu_path The local filepath to the script @param [Logger] A Logger to use @return [void]

# File lib/sifttter-redux/dropbox-uploader.rb, line 25
def initialize(dbu_path, logger = nil)
  @dbu = dbu_path
  @logger = logger
end

Public Instance Methods

download() click to toggle source

Downloads files from Dropbox (assumes that both local_target and remote_target have been set). @return [void]

# File lib/sifttter-redux/dropbox-uploader.rb, line 33
def download
  if !@local_target.nil? && !@remote_target.nil?
    if @verbose
      system "#{ @dbu } download #{ @remote_target } #{ @local_target }"
    else
      exec = `#{ @dbu } download #{ @remote_target } #{ @local_target }`
    end
  else
    error_msg = 'Local and remote targets cannot be nil'
    @logger.error(error_msg) if @logger
    fail StandardError, error_msg
  end
end
upload() click to toggle source

Uploads files tro Dropbox (assumes that both local_target and remote_target have been set). @return [void]

# File lib/sifttter-redux/dropbox-uploader.rb, line 50
def upload
  if !@local_target.nil? && !@remote_target.nil?
    if @verbose
      system "#{ @dbu } upload #{ @local_target } #{ @remote_target }"
    else
      exec = `#{ @dbu } upload #{ @local_target } #{ @remote_target }`
    end
  else
    error_msg = 'Local and remote targets cannot be nil'
    @logger.error(error_msg) if @logger
    fail StandardError, error_msg
  end
end