Class: QueueryClient::UrlDataFileBundle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataFileBundle

#each_row

Constructor Details

#initialize(data_urls, manifest_url, s3_prefix:, logger: Logger.new($stderr)) ⇒ UrlDataFileBundle

Returns a new instance of UrlDataFileBundle.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/queuery_client/url_data_file_bundle.rb', line 9

def initialize(data_urls, manifest_url, s3_prefix:, logger: Logger.new($stderr))
  raise ArgumentError, 'no URL given' if data_urls.empty?
  @data_files = data_urls.map {|url| UrlDataFile.new(URI.parse(url)) }
  @manifest_file = UrlManifestFile.new(URI.parse(manifest_url)) if manifest_url
  @s3_prefix = s3_prefix
  @logger = logger
end

Instance Attribute Details

#data_filesObject (readonly)

Returns the value of attribute data_files.



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

def data_files
  @data_files
end

#loggerObject (readonly)

Returns the value of attribute logger.



20
21
22
# File 'lib/queuery_client/url_data_file_bundle.rb', line 20

def logger
  @logger
end

#manifest_fileObject (readonly)

Returns the value of attribute manifest_file.



18
19
20
# File 'lib/queuery_client/url_data_file_bundle.rb', line 18

def manifest_file
  @manifest_file
end

#s3_prefixObject (readonly)

Returns the value of attribute s3_prefix.



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

def s3_prefix
  @s3_prefix
end

Instance Method Details

#direct(bucket_opts = {}, bundle_opts = {}) ⇒ Object



29
30
31
32
33
34
# File 'lib/queuery_client/url_data_file_bundle.rb', line 29

def direct(bucket_opts = {}, bundle_opts = {})
  s3_uri = URI.parse(s3_prefix)
  bucket = s3_uri.host
  prefix = s3_uri.path[1..-1] # trim heading slash
  S3DataFileBundle.new(bucket, prefix)
end

#has_manifest?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/queuery_client/url_data_file_bundle.rb', line 36

def has_manifest?
  !@manifest_file.nil?
end

#urlObject



22
23
24
25
26
27
# File 'lib/queuery_client/url_data_file_bundle.rb', line 22

def url
  uri = data_files.first.url.dup
  uri.query = nil
  uri.path = File.dirname(uri.path)
  uri.to_s
end