Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Initial commit of rorybot warning analytics test script
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyhansonfinger committed May 18, 2016
1 parent 0dbf476 commit 04fc49b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions analytics-test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'FileUtils'

puts "Enter the filetype you want to search (rb, erb, md, or html"
filetype = gets.chomp.to_s

puts "Processing #{filetype} files recursively in #{Dir.pwd} with Rorybot"
`rorybot **/*.#{filetype} | tee rorybot_output.txt`

input_file = File.open('rorybot_output.txt', 'r')
output_file = File.open('frequency.csv', 'w+')
warning_message = /(?:warning\s{2,}?)(.+?)(?=\s{2,})/
frequency = Hash.new(0)

puts "Counting warning messages"
input_file.read.scan(warning_message) do |word|
frequency[word] = frequency[word] + 1
end

puts "Writing result to frequency.csv"
frequency.each do |key, value|
kv = "#{key}, #{value}"
kv.encode("UTF-8")
output_file.puts kv.gsub("[", "").gsub("]", "")
end

puts "Deleting temporary files"
FileUtils.rm('rorybot_output.txt')

puts "Use Google Sheets to open frequency.csv for further processing"

0 comments on commit 04fc49b

Please sign in to comment.