Class: Fastlane::Helper::GoogleDriveHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::GoogleDriveHelper
- Defined in:
- lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb
Class Method Summary collapse
- .create_subcollection(root_folder:, title:) ⇒ Object
- .file_by_id(session: nil, fid: nil) ⇒ Object
- .setup(keyfile: nil, service_account: false) ⇒ Object
- .upload_file(file: nil, file_name: nil, title: nil) ⇒ Object
Class Method Details
.create_subcollection(root_folder:, title:) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb', line 39 def self.create_subcollection(root_folder:, title:) root_folder.create_subcollection(title) rescue Exception => e UI.error(e.) UI.user_error!("Create '#{title}' failed") end |
.file_by_id(session: nil, fid: nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb', line 19 def self.file_by_id(session: nil, fid: nil) file = session.file_by_id(fid) file rescue Exception => e UI.error(e.) UI.user_error!("File with id '#{fid}' not found in Google Drive") end |
.setup(keyfile: nil, service_account: false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb', line 8 def self.setup(keyfile: nil, service_account: false) if service_account ::GoogleDrive::Session.from_service_account_key(keyfile) else ::GoogleDrive::Session.from_config(keyfile) end rescue Exception => e UI.error(e.) UI.user_error!('Invalid Google Drive credentials') end |
.upload_file(file: nil, file_name: nil, title: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/google_drive/helper/google_drive_helper.rb', line 27 def self.upload_file(file: nil, file_name: nil, title: nil) raise "Not Google Drive file" unless file.kind_of?(::GoogleDrive::File) begin file = file.upload_from_file(file_name, title, convert: false) file rescue Exception => e UI.error(e.) UI.user_error!("Upload '#{file_name}' failed") end end |