module Primer::ViewComponents

def self.dump(stats)

dump generates the requested stat hash and outputs it to a file.
def self.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 self.generate_audited_at

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

def self.generate_constants

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

def self.generate_statuses

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

def self.read(stats)

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