Class: Bracken::Configuration::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/bracken/configuration/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, output_stream = STDOUT, error_stream = STDERR) ⇒ Builder

Returns a new instance of Builder.



11
12
13
14
15
# File 'lib/bracken/configuration/builder.rb', line 11

def initialize(configuration, output_stream = STDOUT, error_stream = STDERR)
  @configuration = configuration
  @output_stream = output_stream
  @error_stream  = error_stream
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



7
8
9
# File 'lib/bracken/configuration/builder.rb', line 7

def configuration
  @configuration
end

#error_streamObject (readonly)

Returns the value of attribute error_stream.



9
10
11
# File 'lib/bracken/configuration/builder.rb', line 9

def error_stream
  @error_stream
end

#output_streamObject (readonly)

Returns the value of attribute output_stream.



8
9
10
# File 'lib/bracken/configuration/builder.rb', line 8

def output_stream
  @output_stream
end

Instance Method Details

#file(path, &block) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/bracken/configuration/builder.rb', line 25

def file(path, &block)
  configuration.files << Logfile.new(path, configuration.options.number_of_lines)

  if block_given?
    instance_eval(&block)
  end
end

#on(*args) ⇒ Object



33
34
35
# File 'lib/bracken/configuration/builder.rb', line 33

def on(*args)
  configuration.files.last.filters << Logfile::Filter.new(*args)
end

#parse(pathname) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/bracken/configuration/builder.rb', line 17

def parse(pathname)
  if File.exist?(pathname)
    instance_eval(File.read(pathname), pathname)
  else
    error_stream.puts("WARNING file #{pathname} does not exist!")
  end
end