Class: DevTrainingBot::GoogleDriveService

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dev_training_bot/services/google_drive_service.rb

Constant Summary collapse

OOB_URI =
'urn:ietf:wg:oauth:2.0:oob'.freeze
APPLICATION_NAME =
'Dev Training Bot'.freeze
CLIENT_SECRETS_PATH =
ENV['CLIENT_SECRETS_PATH'].freeze
CREDENTIALS_PATH =
'token.yaml'.freeze
SCOPE =
Google::Apis::DriveV3::AUTH_DRIVE_READONLY
DOC_URL =
"https://docs.google.com/document/d/#{ENV['FILE_ID']}".freeze
FORMATS =
{
  'html'        => 'text/html',
  'zip'         => 'application/zip',
  'text'        => 'text/plain',
  'rtf'         => 'application/rtf',
  'open_office' => 'application/vnd.oasis.opendocument.text',
  'pdf'         => 'application/pdf',
  'word'        => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  'epub'        => 'application/epub+zip'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGoogleDriveService

Returns a new instance of GoogleDriveService.



37
38
39
40
41
# File 'lib/dev_training_bot/services/google_drive_service.rb', line 37

def initialize
  @service = Google::Apis::DriveV3::DriveService.new
  @service.client_options.application_name = APPLICATION_NAME
  @service.authorization = authorize
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



27
28
29
# File 'lib/dev_training_bot/services/google_drive_service.rb', line 27

def service
  @service
end

Class Method Details

.formatsObject



29
30
31
# File 'lib/dev_training_bot/services/google_drive_service.rb', line 29

def self.formats
  FORMATS.keys
end

.mime(format) ⇒ Object



33
34
35
# File 'lib/dev_training_bot/services/google_drive_service.rb', line 33

def self.mime(format)
  FORMATS[format]
end