class

Hwaro::Utils::HtmlStats

Inherits Reference < Object

Constants

FILE = "hwaro_stats.json"
RAW_TEXT_TAGS = {"script", "style"}

Raw-text elements: their bodies are not markup, so a < inside a script (a<b) must not read as a tag.

Class methods

read_elements(path : String) : Hash(String, JSON::Any) | Nil

The htmlElements object of a stats file, or nil when the file is missing, unreadable or not shaped like one.

Source
scan(html : String, tags : Set(String), classes : Set(String), ids : Set(String)) : Nil
Source
valid_file?(path : String) : Bool

True when path holds a stats file a partial build can extend.

Source

Instance methods

add(html : String) : Nil

Scan one rendered HTML document and merge what it uses.

Source
classes
Source
merge_file(path : String) : Nil

Fold a previously written stats file in (a partial build keeps the selectors of the pages it did not re-render). A missing or malformed file adds nothing — and makes the next --cache build render every page (see valid_file?).

Source
serialize
Source
tags
Source
write(path : String = FILE) : Nil

Write path unless it already holds these bytes, so an unchanged build keeps the file's mtime (and a watcher on it stays quiet).

Source