Class: SifttterRedux::DropboxUploader
- Inherits:
-
Object
- Object
- SifttterRedux::DropboxUploader
- Defined in:
- lib/sifttter-redux/dropbox-uploader.rb
Overview
DropboxUploader Class Wrapper class for the Dropbox Uploader project
Instance Attribute Summary collapse
-
#local_target ⇒ String
Stores the local filepath.
-
#message ⇒ String
Stores the message to display.
-
#remote_target ⇒ String
Stores the remote filepath.
-
#verbose ⇒ Boolean
Stores the verbosity level.
Instance Method Summary collapse
-
#download ⇒ void
Downloads files from Dropbox (assumes that both local_target and remote_target have been set).
-
#initialize(dbu_path, logger = nil) ⇒ void
constructor
Loads the location of dropbox_uploader.sh.
-
#upload ⇒ void
Uploads files tro Dropbox (assumes that both local_target and remote_target have been set).
Constructor Details
#initialize(dbu_path, logger = nil) ⇒ void
Loads the location of dropbox_uploader.sh.
25 26 27 28 |
# File 'lib/sifttter-redux/dropbox-uploader.rb', line 25 def initialize(dbu_path, logger = nil) @dbu = dbu_path @logger = logger end |
Instance Attribute Details
#local_target ⇒ String
Stores the local filepath.
7 8 9 |
# File 'lib/sifttter-redux/dropbox-uploader.rb', line 7 def local_target @local_target end |
#message ⇒ String
Stores the message to display.
15 16 17 |
# File 'lib/sifttter-redux/dropbox-uploader.rb', line 15 def @message end |
#remote_target ⇒ String
Stores the remote filepath.
11 12 13 |
# File 'lib/sifttter-redux/dropbox-uploader.rb', line 11 def remote_target @remote_target end |
#verbose ⇒ Boolean
Stores the verbosity level.
19 20 21 |
# File 'lib/sifttter-redux/dropbox-uploader.rb', line 19 def verbose @verbose end |
Instance Method Details
#download ⇒ void
This method returns an undefined value.
Downloads files from Dropbox (assumes that both local_target and remote_target have been set).
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 ⇒ void
This method returns an undefined value.
Uploads files tro Dropbox (assumes that both local_target and remote_target have been set).
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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 |