class TestingYourLegacy::RawFile
Public Class Methods
new(file,count = 25)
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 6 def initialize(file,count = 25) @file = file @count = count end
Public Instance Methods
each() { |record| ... }
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 11 def each to_log_summary.each { |record| yield record } end
int_to_id(url)
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 33 def int_to_id(url) url.gsub(/\d+/,"id").gsub(/\?.*/,"?search_string") end
parsed_urls()
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 37 def parsed_urls @parsed_urls ||= started_only.map do |line| line.match(/^Started (?<protocol>\w+) "(?<url>.*)"/) end end
started_only()
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 43 def started_only @started_only ||= @file.select { |line| line.match(/^Started/) && !line.match(/assets/) } end
sum()
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 27 def sum @sum ||= parsed_urls.each_with_object(Hash.new(0)) do |url,memo| memo[[int_to_id(url[:url]),url[:protocol]]] += 1 end end
to_a()
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 19 def to_a sum.keys.each_with_object([]) do | key, memo | memo << TestingYourLegacy::LogEntry.new(key[0], key[1], sum[key]) end end
to_log_summary()
click to toggle source
# File lib/testing_your_legacy/raw_file.rb, line 15 def to_log_summary TestingYourLegacy::LogSummary.new(to_a) end