Sha256: 092d328f4384405571c25220fb3be48fcc2f3baaeb16080e5719362605a26edf

Contents?: true

Size: 1.84 KB

Versions: 11

Compression:

Stored size: 1.84 KB

Contents

module SifttterRedux
  # DropboxUploader Class
  # Wrapper class for the Dropbox Uploader project
  class DropboxUploader
    # Stores the local filepath.
    # @return [String]
    attr_accessor :local_target

    # Stores the remote filepath.
    # @return [String]
    attr_accessor :remote_target

    # Stores the message to display.
    # @return [String]
    attr_accessor :message

    # Stores the verbosity level.
    # @return [Boolean]
    attr_accessor :verbose

    # 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]
    def initialize(dbu_path, logger = nil)
      @dbu = dbu_path
      @logger = logger
    end

    # Downloads files from Dropbox (assumes that both
    # local_target and remote_target have been set).
    # @return [void]
    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

    # Uploads files tro Dropbox (assumes that both
    # local_target and remote_target have been set).
    # @return [void]
    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sifttter-redux-1.0.6 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-1.0.5 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-1.0.4 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-1.0.2 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-1.0.1 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-1.0.0 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-0.6.4 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-0.6.3 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-0.6.2 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-0.6.1 lib/sifttter-redux/dropbox-uploader.rb
sifttter-redux-0.6 lib/sifttter-redux/dropbox-uploader.rb