Module: JekyllRecker::Generators::Base

Includes:
Date, Logging, Math
Included in:
Git, Graphs, ImageResize, Stats
Defined in:
lib/jekyll_recker/generators.rb

Overview

Base Generator

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



12
13
14
# File 'lib/jekyll_recker/generators.rb', line 12

def site
  @site
end

Instance Method Details

#data_file_targetObject



29
30
31
# File 'lib/jekyll_recker/generators.rb', line 29

def data_file_target
  File.join site.data_dir, "#{name}.json"
end

#generate(site) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/jekyll_recker/generators.rb', line 18

def generate(site)
  @site = Site.new(site)
  if @site.production?
    info "skipping #{name} generator"
  else
    info "running #{name} generator"
    data = crunch
    File.open(data_file_target, 'w') { |f| f.write(JSON.pretty_generate(data)) } unless data.nil?
  end
end

#nameObject



14
15
16
# File 'lib/jekyll_recker/generators.rb', line 14

def name
  self.class.name.split('::').last.downcase
end