Class: JekyllRecker::Generators::Stats

Inherits:
Jekyll::Generator
  • Object
show all
Includes:
Base
Defined in:
lib/jekyll_recker/generators.rb

Overview

Stats Generator

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#data_file_target, #generate, #name

Methods included from Math

#average, #occurences, #total

Methods included from Logging

included, #info, #logger

Methods included from Date

#calculate_streaks, #slice_by_consecutive, #time_to_date

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



38
39
40
# File 'lib/jekyll_recker/generators.rb', line 38

def site
  @site
end

Instance Method Details

#crunchObject



40
41
42
# File 'lib/jekyll_recker/generators.rb', line 40

def crunch
  generate_stats
end

#generate_statsObject



44
45
46
47
48
49
50
51
52
# File 'lib/jekyll_recker/generators.rb', line 44

def generate_stats
  {
    'total_words' => total(site.word_counts),
    'average_words' => average(site.word_counts),
    'total_posts' => site.entries.size,
    'consecutive_posts' => calculate_streaks(site.dates).first['days'],
    'swears' => calculate_swears
  }
end