Class: GroongaQueryLog::Command::Analyzer::Reporter

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/groonga-query-log/command/analyzer/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statistics, options = {}) ⇒ Reporter

Returns a new instance of Reporter.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 28

def initialize(statistics, options={})
  @statistics = statistics
  @options = options
  self.output = @options[:output] || $stdout
  @report_summary = @options[:report_summary]
  @report_summary = true if @report_summary.nil?
  @report_command_line = @options[:report_command_line]
  @report_command_line = true if @report_command_line.nil?
  @slow_operation_threshold =
    @options[:slow_operation_threshold] ||
    Statistic::DEFAULT_SLOW_OPERATION_THRESHOLD
  @slow_response_threshold =
    @options[:slow_response_threshold] ||
    Statistic::DEFAULT_SLOW_RESPONSE_THRESHOLD
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



26
27
28
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 26

def output
  @output
end

#slow_operation_thresholdObject

Returns the value of attribute slow_operation_threshold.



27
28
29
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 27

def slow_operation_threshold
  @slow_operation_threshold
end

#slow_response_thresholdObject

Returns the value of attribute slow_response_threshold.



27
28
29
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 27

def slow_response_threshold
  @slow_response_threshold
end

Instance Method Details

#eachObject



49
50
51
52
53
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 49

def each
  @statistics.each do |statistic|
    yield statistic
  end
end

#reportObject



55
56
57
58
59
60
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 55

def report
  setup do
    report_summary if @report_summary
    report_statistics
  end
end

#report_statisticsObject



62
63
64
65
66
# File 'lib/groonga-query-log/command/analyzer/reporter.rb', line 62

def report_statistics
  each do |statistic|
    report_statistic(statistic)
  end
end