I am planning to use the stats for my rails app for analysis.
I obtained the stats using
rake stats
All I obtained is a ascii formatted table. Is there a way to get this in JSON?
Super-hacky and not in any way clever, but, here's how to turn a | separated table into json.
lines = `rake stats`.split("\n").collect{|l| l.split("|").collect(&:strip).reject(&:blank?)}.select{|l| l.size > 1}
hashes = []
headers = lines.shift
lines.each do |line|
hash = {}
headers.each_with_index do |header,i|
hash[header] = line[i]
end
hashes << hash
end
hashes.to_json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With