class RSpec::Storage::GCS::Uploader
Public Class Methods
new(gcs_client, uri)
click to toggle source
# File lib/rspec/storage/gcs.rb, line 27 def initialize(gcs_client, uri) @tempfile = Tempfile.new("rspec-storage-gcs") @gcs_client = gcs_client @uri = uri @bucket = uri.host @key = uri.path[1..-1] end
Public Instance Methods
__getobj__()
click to toggle source
# File lib/rspec/storage/gcs.rb, line 35 def __getobj__ @tempfile end
close()
click to toggle source
# File lib/rspec/storage/gcs.rb, line 39 def close @tempfile.flush @tempfile.rewind object = Google::Apis::StorageV1::Object.new(name: @key) @gcs_client.insert_object(@bucket, object, upload_source: @tempfile) $stdout.puts "Upload to #{@uri.to_s}" ensure @tempfile.close end