Class: Hasta::S3DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/hasta/s3_data_source.rb

Overview

Data source for reading data from S3

Instance Method Summary collapse

Constructor Details

#initialize(s3_uri, combined_storage = Hasta.combined_storage) ⇒ S3DataSource

Returns a new instance of S3DataSource.



9
10
11
12
# File 'lib/hasta/s3_data_source.rb', line 9

def initialize(s3_uri, combined_storage = Hasta.combined_storage)
  @s3_uri = s3_uri
  @combined_storage = combined_storage
end

Instance Method Details

#each_lineObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/hasta/s3_data_source.rb', line 18

def each_line
  return enum_for(:each_line) unless block_given?

  combined_storage.files_for(s3_uri).each do |file|
    Hasta.logger.debug(
      "Processing #{file.remote? ? 'remote' : 'local'} #{file.class}: #{file.key}"
    )
    file.each_line { |line| yield line }
  end
end

#nameObject



14
15
16
# File 'lib/hasta/s3_data_source.rb', line 14

def name
  s3_uri.to_s
end

#to_aObject



29
30
31
# File 'lib/hasta/s3_data_source.rb', line 29

def to_a
  each_line.to_a
end

#to_sObject



33
34
35
# File 'lib/hasta/s3_data_source.rb', line 33

def to_s
  "#<#{self.class.name}:#{s3_uri}>"
end