Class: Jekyll::RpLogs::Page
- Inherits:
-
Object
- Object
- Jekyll::RpLogs::Page
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll/rp_logs/rp_page.rb
Class Attribute Summary collapse
-
.tag_implication_handler ⇒ Object
readonly
Returns the value of attribute tag_implication_handler.
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Jekyll::Page object.
Class Method Summary collapse
Instance Method Summary collapse
-
#[](key) ⇒ Object
Pass the request along to the page’s data hash, and allow symbols to be used by converting them to strings first.
- #[]=(key, value) ⇒ Object
- #canon ⇒ Object
- #convert_rp(parsers) ⇒ Object
-
#errors?(supported_formats) ⇒ Boolean
Check this page for errors, using the provided list of supported parse formats.
-
#initialize(page) ⇒ Page
constructor
A new instance of Page.
- #options ⇒ Object
- #tag_strings ⇒ Object
- #tags ⇒ Object
-
#update_tags ⇒ Object
Updates tags with implications and aliases.
Constructor Details
#initialize(page) ⇒ Page
Returns a new instance of Page.
22 23 24 25 26 27 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 22 def initialize(page) @page = page # If the tags exist, try to convert them to a list of Tag objects self[:rp_tags] = Tag[self[:rp_tags].split(",")] if self[:rp_tags].is_a?(String) end |
Class Attribute Details
.tag_implication_handler ⇒ Object (readonly)
Returns the value of attribute tag_implication_handler.
15 16 17 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 15 def tag_implication_handler @tag_implication_handler end |
Instance Attribute Details
#page ⇒ Object (readonly)
Jekyll::Page object
12 13 14 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 12 def page @page end |
Class Method Details
.extract_settings(config) ⇒ Object
17 18 19 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 17 def extract_settings(config) @tag_implication_handler = TagImplicationHandler.new(config) end |
Instance Method Details
#[](key) ⇒ Object
Pass the request along to the page’s data hash, and allow symbols to be used by converting them to strings first.
32 33 34 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 32 def [](key) @page.data[key.to_s] end |
#[]=(key, value) ⇒ Object
36 37 38 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 36 def []=(key, value) @page.data[key.to_s] = value end |
#canon ⇒ Object
48 49 50 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 48 def canon self[:canon] ? "canon" : "noncanon" end |
#convert_rp(parsers) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 52 def convert_rp(parsers) compiled_lines = convert_all_lines(parsers) merge_lines! compiled_lines stats = extract_stats compiled_lines # A decent amount of this could be moved into Page split_output = compiled_lines.map(&:output) page.content = split_output.join("\n") update_page_properties(stats) true end |
#errors?(supported_formats) ⇒ Boolean
Check this page for errors, using the provided list of supported parse formats
Returns false if there is no error Returns error_message if there is an error
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 73 def errors?(supported_formats) # Verify that formats are specified if self[:format].nil? || self[:format].empty? return "No formats specified" end # Verify that the parser for each format exists self[:format].each do |format| return "Format #{format} does not exist." unless supported_formats[format] end # Verify that tags exist return "No tags specified" if self[:rp_tags].nil? # Verify that arc names are in the proper format if self[:arc_name] && !self[:arc_name].respond_to?("each") return "arc_name must be blank or a YAML list" end false end |
#options ⇒ Object
95 96 97 98 99 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 95 def { strict_ooc: self[:strict_ooc], merge_text_into_rp: self[:merge_text_into_rp], splits_by_character: self[:splits_by_character] } end |
#tag_strings ⇒ Object
44 45 46 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 44 def tag_strings .map(&:to_s) end |
#tags ⇒ Object
40 41 42 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 40 def self[:rp_tags] end |
#update_tags ⇒ Object
Updates tags with implications and aliases.
103 104 105 106 |
# File 'lib/jekyll/rp_logs/rp_page.rb', line 103 def self[:rp_tags] = Tag[self.class.tag_implication_handler.(tag_strings.to_set)] self end |