1
0
Fork 0
mirror of https://github.com/fmap/muflax65ngodyewp.onion synced 2024-06-29 10:36:48 +02:00
muflax65ngodyewp.onion/commands/wc.rb
muflax 1b781a23f6 transition complete
* word count
* categories in nav-bar
* next / prev item
* robots.txt (including sitemap)
* many minor tweaks
2012-04-18 23:06:03 +02:00

23 lines
592 B
Ruby

usage 'wc'
summary 'word count of logs'
description 'Prints word count of log entries for Beeminder logging.'
module Nanoc::CLI::Commands
class WordCount < ::Nanoc::CLI::CommandRunner
def run
daily_logs.each do |log|
data = File.read(log)
pieces = data.split(/^(-{5}|-{3})\s*$/)
next if pieces.size < 4
content = pieces[4..-1].join.strip
words = content.scan(/( \[.+?\]\[.*?\][[:punct:]]* | <%=?.+?%> | \S+ )/x)
puts "#{log} -> #{words.size}"
end
end
end
end
runner Nanoc::CLI::Commands::WordCount