Class: Ralphttp::Fixit

Inherits:
Object
  • Object
show all
Defined in:
lib/ralphttp/fixit.rb

Overview

Public: Format data for a reasonable output

Direct Known Subclasses

Wreckit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Fixit

Public: Start the class based on selected options

options - Hash containing settings

Returns nil



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

def initialize(options)
  @status = {}
  @error = []
  @detailed = options[:detail]

  unless options[:csv].nil?
    @csv = options[:csv]
    assign_csv_report
  end
end

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



7
8
9
# File 'lib/ralphttp/fixit.rb', line 7

def bucket
  @bucket
end

#csvObject

Returns the value of attribute csv.



5
6
7
# File 'lib/ralphttp/fixit.rb', line 5

def csv
  @csv
end

#csvexportObject

Returns the value of attribute csvexport.



6
7
8
# File 'lib/ralphttp/fixit.rb', line 6

def csvexport
  @csvexport
end

#detailedObject

Returns the value of attribute detailed.



4
5
6
# File 'lib/ralphttp/fixit.rb', line 4

def detailed
  @detailed
end

#errorObject

Returns the value of attribute error.



10
11
12
# File 'lib/ralphttp/fixit.rb', line 10

def error
  @error
end

#reqObject

Returns the value of attribute req.



11
12
13
# File 'lib/ralphttp/fixit.rb', line 11

def req
  @req
end

#statusObject

Returns the value of attribute status.



9
10
11
# File 'lib/ralphttp/fixit.rb', line 9

def status
  @status
end

#total_timeObject

Returns the value of attribute total_time.



8
9
10
# File 'lib/ralphttp/fixit.rb', line 8

def total_time
  @total_time
end

Instance Method Details

#analyzeObject

Public: Analyze collected data and show reasonable output

Return Text output



32
33
34
35
36
37
38
39
40
41
# File 'lib/ralphttp/fixit.rb', line 32

def analyze
  if @error.empty?
    display_results
  else
    puts 'Errors encountered when connecting:'
    @error.each do |e|
      puts e
    end
  end
end

#display_resultsObject

Public - Displays the results of the parsed data

Returns nil



46
47
48
49
50
51
# File 'lib/ralphttp/fixit.rb', line 46

def display_results
  print_header
  print_detailed_report
  write_csv_report
  display_status
end

Public: Output the header information

Returns nil



56
57
58
59
60
# File 'lib/ralphttp/fixit.rb', line 56

def print_header
  unless @detailed.nil?
    puts sprintf('%-30s %-10s %-10s', 'Time', 'Req/s', 'Avg resp (ms)')
  end
end