Class: JekyllRecker::Generators::Stats
- Inherits:
-
Jekyll::Generator
- Object
- Jekyll::Generator
- JekyllRecker::Generators::Stats
- Includes:
- Base, JekyllRecker::Graphs
- Defined in:
- lib/jekyll_recker/generators.rb
Overview
Stats Generator
Instance Method Summary collapse
Methods included from JekyllRecker::Graphs
Methods included from Base
#bodies, #dates, #entries, #production?, #word_counts, #words
Methods included from Math
Methods included from Logging
Methods included from Date
#calculate_streaks, #slice_by_consecutive
Instance Method Details
#data ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jekyll_recker/generators.rb', line 57 def data { 'total_words' => total(word_counts), 'average_words' => average(word_counts), 'total_posts' => entries.size, 'consecutive_posts' => calculate_streaks(dates).first['days'], 'swears' => { 'total' => swear_results.map(&:last).reduce(0, :+), 'words' => swear_results } } end |
#generate(site) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/jekyll_recker/generators.rb', line 44 def generate(site) @site = site logger.info 'calculating statistics' @site.data['stats'] = data if production? logger.info 'production detected. skipping graphs' else require 'gruff' logger.info 'generating graphs' generate_graphs(entries, swear_results, graphs_dir) end end |