Hearing Structure Renderer - TISTATechnologies/caseflow GitHub Wiki
The hearing structure renderer is a Rails console add-on that generates and formats a quick overview of any hearing related model and data, inspired by and implemented from the architecture of Intake Renderer.
Usage
Same usage as IntakeRender
Two ways to call the Hearing Renderer
> # the one-liner method
> puts HearingRenderer.render(hearing)
>
> # monkey-patching makes multiple calls more convenient
> HearingRenderer.patch_hearing_classes
> puts appeal.render_hearing
> puts appeal.hearing.render_hearing
> puts appeal.hearing.virtual_hearing.render_hearing
By default, PII is omitted from the rendered output, but it can be included explicitly:
> puts HearingRenderer.render(hearing, show_pii: true)
> puts hearing.render_hearing(show_pii: true)
Hearing notes and task instructions can often contain PII so those behind show_pii flag as well.
Some sample output:
[put finalized examples here]
The breadcrumbs section at the end of the output provides broader context for the rendered object, and always leads back to a veteran.
Implementation
Same core implementation as IntakeRender Pull Request
/
using the Tree gem
A note about printing - We intentionally did not include any strings with
/
in them (URLs for example) because theTree
gem is implemented for printing directory structure and it interprets any strings with/
as folder or file paths. Underneath the hood,TTY::Tree::Node
is initialized with each given string and it usesPathname
to interpret the string as a file path and saves only the basename of the path as the node's name. Based on that, when the tree is printed, it prints only the basename. For example, if given the stringhearings/12/details
, it would only printdetails.
The following monkey patch would fix the issue but we decided not to pursue that:
module TTY
class Tree
class Node
def initialize(path, parent, prefix, level)
if path.is_a? String
# strip null bytes from the string to avoid throwing errors
path = path.delete("\0")
end
@path = Pathname.new(path)
@name = @path.to_s # <--- the only change; make node name the entire path
@parent = Pathname.new(parent)
@prefix = prefix
@level = level
end
end
end
end