diff --git a/.idea/ApacheLogStats.iml b/.idea/ApacheLogStats.iml index bd3fe53..a39aa12 100644 --- a/.idea/ApacheLogStats.iml +++ b/.idea/ApacheLogStats.iml @@ -10,21 +10,21 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/miguelnogueira.xml b/.idea/dictionaries/miguelnogueira.xml new file mode 100644 index 0000000..3cfb57d --- /dev/null +++ b/.idea/dictionaries/miguelnogueira.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/main.rb b/main.rb index 016234c..9c59f35 100644 --- a/main.rb +++ b/main.rb @@ -42,9 +42,7 @@ end def times_appeared_single(ips, ip_to_check) counter = 0 ips.each do |ip| - if ip == ip_to_check - counter += 1 - end + counter += 1 if ip == ip_to_check end counter end @@ -69,7 +67,7 @@ client_errors = {} user_agents = {} all_ips = [] -lines.each do | line | +lines.each do |line| all_ips << get_line_ip(line) end @@ -103,14 +101,14 @@ lines.each do |line| end -top_user_agents = user_agents.sort_by { |ua, count| -count }.first(5) +top_user_agents = user_agents.sort_by { |_ua, count| -count }.first(5) puts 'Top 5 User-Agents contacting the site:' top_user_agents.each do |ua, count| puts "#{ua}: #{count} visits" end -top_client_errors = client_errors.sort_by { |ip, count| -count }.first(5) +top_client_errors = client_errors.sort_by { |_ip, count| -count }.first(5) puts 'Top 5 IPs with most client errors (400-499):' top_client_errors.each do |ip, count| puts "#{ip}: #{count} errors" -end \ No newline at end of file +end