Class: Bricolage::LogLocatorBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/loglocatorbuilder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_path_format, s3_ds, s3_key_format) ⇒ LogLocatorBuilder

Returns a new instance of LogLocatorBuilder.



11
12
13
14
15
# File 'lib/bricolage/loglocatorbuilder.rb', line 11

def initialize(log_path_format, s3_ds, s3_key_format)
  @log_path_format = log_path_format
  @s3_ds = s3_ds
  @s3_key_format = s3_key_format
end

Class Method Details

.for_options(ctx, log_path_format, s3_ds, s3_key_format) ⇒ Object



6
7
8
9
# File 'lib/bricolage/loglocatorbuilder.rb', line 6

def LogLocatorBuilder.for_options(ctx, log_path_format, s3_ds, s3_key_format)
  ds = s3_ds ? ctx.get_data_source('s3', s3_ds) : nil
  new(log_path_format, ds, s3_key_format)
end

Instance Method Details

#build(**params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bricolage/loglocatorbuilder.rb', line 17

def build(**params)
  path = @log_path_format ? @log_path_format.format(**params) : nil
  s3_writer =
    if @s3_ds and @s3_key_format
      key = @s3_key_format.format(**params)
      S3Writer.new(@s3_ds, key)
    else
      nil
    end
  LogLocator.new(path, s3_writer)
end