module Ariadne::ViewComponents

def dump(stats)

dump generates the requested stat hash and outputs it to a file.
def dump(stats)
  require "json"
  File.open(File.join(DEFAULT_STATIC_PATH, FILE_NAMES[stats]), "w") do |f|
    f.write(JSON.pretty_generate(send("generate_#{stats}")))
    f.write($INPUT_RECORD_SEPARATOR)
  end
end

def generate_audited_at

the day the component has passed an accessibility audit.
generate_audited_at returns a hash mapping component name to
def generate_audited_at
  Ariadne::Component.descendants.sort_by(&:name).each_with_object({}) do |component, mem|
    mem[component.to_s] = component.audited_at.to_s
  end
end

def generate_constants

all of its constants.
generate_constants returns a hash mapping component name to
def generate_constants
  Ariadne::Component.descendants.sort_by(&:name).each_with_object({}) do |component, mem|
    mem[component.to_s] = component.constants(false).sort.index_with do |constant|
      component.const_get(constant)
    end
  end
end

def generate_statuses

the component's status sorted alphabetically by the component name.
generate_statuses returns a hash mapping component name to
def generate_statuses
  Ariadne::Component.descendants.sort_by(&:name).each_with_object({}) do |component, mem|
    mem[component.to_s] = component.status.to_s
  end
end

def read(stats)

read returns a JSON string matching the output of the corresponding stat.
def read(stats)
  File.read(File.join(DEFAULT_STATIC_PATH, FILE_NAMES[stats]))
end