Class: Fastlane::Actions::ListFilesGoogleDriveAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



83
84
85
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 83

def self.authors
  ['SpQuyt (@spquyt)']
end

.available_optionsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 40

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :drive_keyfile,
                                env_name: 'GDRIVE_KEY_FILE',
                                description: 'Json config file',
                                type: String,
                                default_value: 'drive_key.json',
                                verify_block: proc do |value|
                                  UI.user_error!("Couldn't find config keyfile at path '#{value}'") unless File.exist?(value)
                                end),
    FastlaneCore::ConfigItem.new(key: :service_account,
                                env_name: 'GDRIVE_SERVICE_ACCOUNT',
                                description: 'Credential is service account',
                                optional: true,
                                is_string: false,
                                default_value: false),
    FastlaneCore::ConfigItem.new(key: :folder_id,
                                env_name: "GDRIVE_UPLOAD_FOLDER_ID",
                                description: "Upload target folder id",
                                optional: false,
                                type: String,
                                verify_block: proc do |value|
                                  UI.user_error!("No target folder id given, pass using `folder_id: 'some_id'`") unless value and !value.empty?
                                end),
    FastlaneCore::ConfigItem.new(key: :keyword,
                                env_name: "GDRIVE_KEYWORD_LIST_FILES",
                                description: "Keyword for filter list files",
                                optional: false,
                                type: String),
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 29

def self.description
  'List files on Google Drive'
end

.detailsObject



33
34
35
36
37
38
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 33

def self.details
  [
    'List files on Google Drive',
    'See https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md to get a keyfile'
  ].join("\n")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 87

def self.is_supported?(platform)
  true
end

.outputObject



72
73
74
75
76
77
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 72

def self.output
  [
    ['GDRIVE_FOLDER_FILES', 'Full collection of files in folder'],
    ['GDRIVE_FOLDER_FILES_TITLE', 'Title of files in folder']
  ]
end

.return_valueObject



79
80
81
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 79

def self.return_value
  # nothing
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fastlane/plugin/googledrive_spquyt/actions/list_files_google_drive_action.rb', line 11

def self.run(params)

  session = Helper::GoogledriveSpquytHelper.setup(
    keyfile: params[:drive_keyfile],
    service_account: params[:service_account]
  )

  folder = Helper::GoogledriveSpquytHelper.file_by_id(
    session: session, fid: params[:folder_id]
  )

  folder_files = params[:keyword] ? folder.files.select{|file| file.title.include? params[:keyword]} : folder.files
  folder_files_title = params[:keyword] ? folder.files.select{|file| file.title.include? params[:keyword]}.map{|file| file.title} : folder.files.map{|file| file.title}
  Actions.lane_context[SharedValues::GDRIVE_FOLDER_FILES] = folder_files
  Actions.lane_context[SharedValues::GDRIVE_FOLDER_FILES_TITLE] = folder_files_title
  UI.important("List files: #{folder_files_title}")
end