Module: DropboxUtil

Includes:
LoggerUtil
Defined in:
lib/JenkinsUtil/dropbox_util.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from LoggerUtil

fatal, log, verbose?

Instance Attribute Details

#uploaded_filesObject (readonly)

Returns the value of attribute uploaded_files.



9
10
11
# File 'lib/JenkinsUtil/dropbox_util.rb', line 9

def uploaded_files
  @uploaded_files
end

Class Method Details

.delete(dropbox_location) ⇒ Object



26
27
28
29
30
# File 'lib/JenkinsUtil/dropbox_util.rb', line 26

def self.delete(dropbox_location)
  @dropbox_client ||= DropboxClient.new(JenkinsUtil::DROPBOX_ACCESS_TOKEN)

  LoggerUtil.fatal('Location passed is nil') if dropbox_location.nil?
end

.upload(sources, destination, flatten = true, root = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/JenkinsUtil/dropbox_util.rb', line 11

def self.upload(sources, destination, flatten = true, root = nil)
  LoggerUtil.fatal('Sources passed is nil') if sources.nil?
  LoggerUtil.fatal('Destination passed is nil') if destination.nil?
  LoggerUtil.fatal('Root must be passed if flatten is false') if !flatten && root.nil?
  LoggerUtil.fatal('Please set environment variable DROPBOX_ACCESS_TOKEN') if ENV['DROPBOX_ACCESS_TOKEN'].nil?

  @dropbox_client ||= DropboxClient.new(ENV['DROPBOX_ACCESS_TOKEN'])
  @sources = sources
  @destination = destination
  @flatten = flatten
  @root_path = root || Dir.pwd

  upload_files
end