Class: SiteInspector

Inherits:
Jekyll::Generator
  • Object
show all
Defined in:
site_inspector.rb

Overview

Dumps lots of information from site if in development mode and site_inspector: true in _config.yml.

Author:

License:

  • SPDX-License-Identifier: Apache-2.0

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SiteInspector

Returns a new instance of SiteInspector.



10
11
12
13
# File 'site_inspector.rb', line 10

def initialize(config)
  super(config)
  @log = LoggerFactory.new.create_logger('site_inspector', config, :warn, $stderr)
end

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



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
47
48
# File 'site_inspector.rb', line 20

def generate(site)
  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'

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

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

  site.data.sort.each { |key, value| @log.info "site.data.#{key} = '#{value}'" }  # site.documents.each {|key, value| @log.info "site.documents.#{key}" } # Generates too much output!

  @log.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| @log.info "site.tags.#{key} = '#{value}'" }
end