Class: ReqresRspec::Uploader::GoogleDrive
- Inherits:
-
Object
- Object
- ReqresRspec::Uploader::GoogleDrive
- Defined in:
- lib/reqres_rspec/uploaders/google_drive.rb
Overview
You can find more detailed information here github.com/gimite/google-drive-ruby
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ GoogleDrive
constructor
A new instance of GoogleDrive.
- #process ⇒ Object
Constructor Details
#initialize ⇒ GoogleDrive
Returns a new instance of GoogleDrive.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/reqres_rspec/uploaders/google_drive.rb', line 8 def initialize @path = ReqresRspec.configuration.output_path @logger = ReqresRspec.logger client = Google::APIClient.new auth = client. auth.client_id = ENV['GOOGLE_CLIENT_ID'] auth.client_secret = ENV['GOOGLE_CLIENT_SECRET'] auth.scope = [ 'https://www.googleapis.com/auth/drive', 'https://spreadsheets.google.com/feeds/' ] auth.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob' puts("\n\n1. Open this page:\n%s\n\n" % auth.) puts('2. Enter the authorization code shown in the page: ') auth.code = $stdin.gets.chomp auth.fetch_access_token! access_token = auth.access_token @session = GoogleDrive::GoogleDrive.login_with_oauth(access_token) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
29 30 31 |
# File 'lib/reqres_rspec/uploaders/google_drive.rb', line 29 def logger @logger end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
29 30 31 |
# File 'lib/reqres_rspec/uploaders/google_drive.rb', line 29 def path @path end |
Class Method Details
.upload ⇒ Object
31 32 33 34 |
# File 'lib/reqres_rspec/uploaders/google_drive.rb', line 31 def self.upload uploader = self.new uploader.process end |
Instance Method Details
#process ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/reqres_rspec/uploaders/google_drive.rb', line 36 def process Dir["#{path}/**/*"].each { |file| next if File.directory?(file) local_path = file.gsub("#{@path}/", '') start = Time.now @session.upload_from_file(file, local_path, convert: false) done = Time.now puts "\n[#{local_path}] Uploaded in #{done.to_i - start.to_i}s" } end |