complete word count
parent
df232f7fb1
commit
12d99f0720
|
@ -18,15 +18,27 @@ module Nanoc::CLI::Commands
|
||||||
i.reps.any? {|r| r.name == :wordcount}
|
i.reps.any? {|r| r.name == :wordcount}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
total = total_practice = 0
|
||||||
logs.each do |log|
|
logs.each do |log|
|
||||||
content = log.rep_named(:wordcount).compiled_content
|
practice = words_in_content log, :wordcount
|
||||||
stripped = strip content.dup.force_encoding("utf-8")
|
all_words = words_in_content log, :default
|
||||||
words = stripped.scan(/( \S+ )/x)
|
|
||||||
puts "#{log.identifier} -> #{words.size}"
|
total += all_words
|
||||||
|
total_practice += practice
|
||||||
|
|
||||||
|
puts "#{log.identifier} -> #{practice} / #{all_words}"
|
||||||
end
|
end
|
||||||
|
puts "total: #{total_practice} / #{total}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def words_in_content log, rep
|
||||||
|
content = log.rep_named(rep).compiled_content
|
||||||
|
stripped = strip content.dup.force_encoding("utf-8")
|
||||||
|
words = stripped.scan(/( \S+ )/x)
|
||||||
|
words.size
|
||||||
|
end
|
||||||
|
|
||||||
def strip content
|
def strip content
|
||||||
Sanitize.clean(content,
|
Sanitize.clean(content,
|
||||||
:remove_contents => %w{blockquote})
|
:remove_contents => %w{blockquote})
|
||||||
|
|
Loading…
Reference in New Issue