This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of rorybot warning analytics test script
- Loading branch information
1 parent
0dbf476
commit 04fc49b
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |