output/timespan.rb in wvanbergen-request-log-analyzer-0.2.2 vs output/timespan.rb in wvanbergen-request-log-analyzer-0.3.0

- old
+ new

@@ -1,16 +1,18 @@ # Prints the total timespan found in the parsed log files. puts puts green("========================================================================") -if $summarizer.has_timestamps? - puts "Timestamp first request: #{$summarizer.first_request_at}" - puts "Timestamp last request: #{$summarizer.last_request_at}" - puts "Total time analyzed: #{$summarizer.duration} days" +if @summarizer.has_timestamps? + puts "Timestamp first request: #{@summarizer.first_request_at}" + puts "Timestamp last request: #{@summarizer.last_request_at}" + puts "Total time analyzed: #{@summarizer.duration} days" + puts "" + puts "Total requests analyzed: #{@summarizer.request_count}" end methods_print_array = [] -methods_request_count = $summarizer.methods.inject(0) { |subtotal, (k, v)| subtotal + v } -$summarizer.methods.each do |key, value| - methods_print_array << "%s (%0.01f%%)" % [key, green((value * 100) / methods_request_count.to_f)] +methods_request_count = @summarizer.methods.inject(0) { |subtotal, (k, v)| subtotal + v } +@summarizer.methods.each do |key, value| + methods_print_array << green("%s (%0.01f%%)") % [key, (value * 100) / methods_request_count.to_f] end -puts 'Methods: ' + methods_print_array.join(', ') + '.' \ No newline at end of file +puts 'Methods: ' + methods_print_array.join(', ') + '.'