Module: SimpleGdrive

Defined in:
lib/simple_gdrive.rb,
lib/simple_gdrive/base.rb,
lib/simple_gdrive/cleaner.rb,
lib/simple_gdrive/version.rb,
lib/simple_gdrive/uploader.rb,
lib/simple_gdrive/authorizer.rb,
lib/simple_gdrive/trash_cleaner.rb

Defined Under Namespace

Classes: Authorizer, Base, Cleaner, Config, TrashCleaner, Uploader

Constant Summary collapse

VERSION =
'0.6.0'.freeze

Class Method Summary collapse

Class Method Details

.clear(move_to_trash: false) ⇒ Object



40
41
42
43
44
45
# File 'lib/simple_gdrive.rb', line 40

def self.clear(move_to_trash: false)
  Cleaner.new(
    base_folder_id: config.base_folder_id,
    move_to_trash: move_to_trash
  ).call
end

.clear_trashObject



47
48
49
# File 'lib/simple_gdrive.rb', line 47

def self.clear_trash
  TrashCleaner.new.call
end

.configObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/simple_gdrive.rb', line 17

def self.config
  @config ||= Config.new.tap do |config|
    config.base_folder_id = '14lJD-WCxgCd9JxkBnsJktXhw0XrwrsLD'
    config.app_name = 'GDrive Simple Uploader'
    config.client_secrets_file = 'client_secrets.json'
    config.credential_file = File.join(
      Dir.home,
      '.credentials',
      'gdrive-uploader.yaml'
    )
  end
end

.configure {|config| ... } ⇒ Object

Yields:



30
31
32
# File 'lib/simple_gdrive.rb', line 30

def self.configure
  yield config
end

.upload(full_filename, upload_source, content_type: 'text/plain', mime_type: nil) ⇒ Object



34
35
36
37
38
# File 'lib/simple_gdrive.rb', line 34

def self.upload(full_filename, upload_source, content_type: 'text/plain', mime_type: nil)
  Uploader
    .new(base_folder_id: config.base_folder_id)
    .call(full_filename, upload_source, content_type: content_type, mime_type: mime_type)
end