Class: QueueryClient::S3DataFileBundle

Inherits:
DataFileBundle show all
Defined in:
lib/queuery_client/s3_data_file_bundle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataFileBundle

#each_row

Constructor Details

#initialize(bucket, prefix, s3_client: nil, logger: Logger.new($stderr)) ⇒ S3DataFileBundle

Returns a new instance of S3DataFileBundle.



8
9
10
11
12
13
# File 'lib/queuery_client/s3_data_file_bundle.rb', line 8

def initialize(bucket, prefix, s3_client: nil, logger: Logger.new($stderr))
  @s3_client = s3_client || Aws::S3::Client.new   # Use env to inject credentials
  @bucket = bucket
  @prefix = prefix
  @logger = logger
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



15
16
17
# File 'lib/queuery_client/s3_data_file_bundle.rb', line 15

def bucket
  @bucket
end

#loggerObject (readonly)

Returns the value of attribute logger.



17
18
19
# File 'lib/queuery_client/s3_data_file_bundle.rb', line 17

def logger
  @logger
end

#prefixObject (readonly)

Returns the value of attribute prefix.



16
17
18
# File 'lib/queuery_client/s3_data_file_bundle.rb', line 16

def prefix
  @prefix
end

Instance Method Details

#data_filesObject



23
24
25
26
# File 'lib/queuery_client/s3_data_file_bundle.rb', line 23

def data_files
  b = Aws::S3::Resource.new(client: @s3_client).bucket(@bucket)
  b.objects(prefix: @prefix).map {|obj| S3DataFile.new(obj) }
end

#urlObject



19
20
21
# File 'lib/queuery_client/s3_data_file_bundle.rb', line 19

def url
  "s3://#{@bucket}/#{@prefix}"
end