class Commands::ListFiles
List all files accessible by the application.
Public Class Methods
command_name()
click to toggle source
# File lib/gdsh/list_files.rb, line 8 def self.command_name 'ls' end
function()
click to toggle source
# File lib/gdsh/list_files.rb, line 12 def self.function 'List files accessible by this application.' end
Public Instance Methods
created_at_label()
click to toggle source
# File lib/gdsh/list_files.rb, line 60 def created_at_label 'created at: '.colorize(:light_magenta) end
execute()
click to toggle source
# File lib/gdsh/list_files.rb, line 71 def execute filelist.each do |f| next if f['labels']['trashed'] puts_file_info(f) end end
filelist()
click to toggle source
# File lib/gdsh/list_files.rb, line 28 def filelist puts_banner result = [] page_token = nil loop do api_result = retrieve_file_by_page_token(page_token) if api_result.status == 200 files = api_result.data result.concat(files.items) page_token = files.next_page_token else drive_error_string page_token = nil end break if page_token.to_s.empty? end result end
id_label()
click to toggle source
# File lib/gdsh/list_files.rb, line 56 def id_label 'id: '.colorize(:light_magenta) end
puts_file_info(f)
click to toggle source
# File lib/gdsh/list_files.rb, line 64 def puts_file_info(f) puts title_label + "#{f['title']}" puts id_label + "#{f['id']}" puts created_at_label + "#{f['createdDate']}" puts '' end
retrieve_file_by_page_token(pagetoken)
click to toggle source
# File lib/gdsh/list_files.rb, line 16 def retrieve_file_by_page_token(pagetoken) parameters = pagetoken.to_s.empty? ? {} : { pageToken: pagetoken } drive = @client.discovered_api('drive', 'v2') @client.execute( api_method: drive.files.list, parameters: parameters) end
title_label()
click to toggle source
# File lib/gdsh/list_files.rb, line 52 def title_label 'Title: '.colorize(:light_magenta) end