10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/abide_dev_utils/gcloud.rb', line 10
def self.storage_bucket(name: nil, project: nil, credentials: nil)
raise MissingProjectError if project.nil? && ENV['ABIDE_GCLOUD_PROJECT'].nil?
raise MissingCredentialsError if credentials.nil? && ENV['ABIDE_GCLOUD_CREDENTIALS'].nil?
raise MissingBucketNameError if name.nil? && ENV['ABIDE_GCLOUD_BUCKET'].nil?
require 'google/cloud/storage'
@bucket = Google::Cloud::Storage.new(
project_id: project || ENV['ABIDE_GCLOUD_PROJECT'],
credentials: credentials || JSON.parse(ENV['ABIDE_GCLOUD_CREDENTIALS'])
).bucket(name || ENV['ABIDE_GCLOUD_BUCKET'])
end
|