Class: Jekyll::RpLogs::RpLogGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll/rp_logs/rp_log_converter.rb

Overview

Consider renaming since it is more of a converter in practice

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ RpLogGenerator

Returns a new instance of RpLogGenerator.



32
33
34
35
36
37
38
39
40
41
# File 'lib/jekyll/rp_logs/rp_log_converter.rb', line 32

def initialize(config)
  # Should actually probably complain if things are undefined or missing
  config["rp_convert"] = true unless config.key? "rp_convert"

  RpLogGenerator.extract_settings(config)
  LogLine.extract_settings(config)
  Page.extract_settings(config)

  Jekyll.logger.info "Loaded jekyll-rp_logs #{RpLogs::VERSION}"
end

Class Attribute Details

.parsersObject (readonly)

Returns the value of attribute parsers.



17
18
19
# File 'lib/jekyll/rp_logs/rp_log_converter.rb', line 17

def parsers
  @parsers
end

.rp_keyObject (readonly)

Returns the value of attribute rp_key.



17
18
19
# File 'lib/jekyll/rp_logs/rp_log_converter.rb', line 17

def rp_key
  @rp_key
end

Class Method Details

.add(parser) ⇒ Object



19
20
21
# File 'lib/jekyll/rp_logs/rp_log_converter.rb', line 19

def add(parser)
  @parsers[parser::FORMAT_STR] = parser
end

.extract_settings(config) ⇒ Object

Extract global settings from the config file. The rp directory and collection name is pulled out; it must be the first collection defined.



27
28
29
# File 'lib/jekyll/rp_logs/rp_log_converter.rb', line 27

def extract_settings(config)
  @rp_key = config["collections"].keys[0].freeze
end

Instance Method Details

#generate(site) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/jekyll/rp_logs/rp_log_converter.rb', line 43

def generate(site)
  return unless site.config["rp_convert"]

  # There doesn't seem to be a better way to add this to all pages than
  # by modifying the configuration file, which is added onto the `site`
  # liquid variable.
  site.config["rp_logs_version"] = RpLogs::VERSION

  main_index, arc_index = extract_indexes(site)

  disable_liquid_rendering(site)
  # Pull out all the pages that are error-free
  rp_pages = extract_valid_rps(site)

  convert_all_pages(site, main_index, arc_index, rp_pages)
end