Class: Jekyll::SiteInspector

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll_site_inspector.rb

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ void

This method returns an undefined value.

Displays information about the Jekyll site

Parameters:

  • site (Jekyll.Site)

    Automatically provided by Jekyll plugin mechanism



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jekyll_site_inspector.rb', line 16

def generate(site) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
  @logger = PluginMetaLogger.instance.new_logger(self)

  mode = site.config["env"]["JEKYLL_ENV"]

  config = site.config["site_inspector"]
  return if config.nil?

  inspector_enabled = config != false
  return unless inspector_enabled

  force = config == "force"
  return unless force || mode == "development"

  @logger.info { "site is of type #{site.class}" }
  @logger.info { "site.time = #{site.time}" }
  @logger.info { "site.config['env']['JEKYLL_ENV'] = #{mode}" }
  site.collections.each do |key, _|
    @logger.info { "site.collections.#{key}" }
  end

  # key env contains all environment variables, quite verbose so output is suppressed
  site.config.sort.each { |key, value| @logger.info { "site.config.#{key} = '#{value}'" unless key == "env" } }

  site.data.sort.each { |key, value| @logger.info { "site.data.#{key} = '#{value}'" } }
  # site.documents.each {|key, value| @log.info "site.documents.#{key}" } # Generates too much output!
  @logger.info { "site.keep_files: #{site.keep_files.sort}" }
  # site.pages.each {|key, value| @log.info "site.pages.#{key}"" } # Generates too much output!
  # site.posts.each {|key, value| @log.info "site.posts.#{key}" }  # Generates too much output!
  site.tags.sort.each { |key, value| @logger.info { "site.tags.#{key} = '#{value}'" } }
end