module Primer::ViewComponents
def self.dump_statuses(path: DEFAULT_STATUSES_PATH)
dump_statuses generates the status hash and then serializes
def self.dump_statuses(path: DEFAULT_STATUSES_PATH) require "json" statuses = generate_statuses File.open(File.join(path, DEFAULT_STATUS_FILE_NAME), "w") do |f| f.write(statuses.to_json) f.write($INPUT_RECORD_SEPARATOR) end end
def self.generate_statuses
generate_statuses returns a hash mapping component name to
def self.generate_statuses statuses = Primer::Component.descendants.each_with_object({}) do |component, mem| mem[component.to_s] = component.status.to_s end statuses.sort_by { |k, _v| k }.to_h end
def self.read_statuses(path: DEFAULT_STATUSES_PATH)
read_statuses returns a JSON string matching the output of
def self.read_statuses(path: DEFAULT_STATUSES_PATH) File.read(File.join(path, DEFAULT_STATUS_FILE_NAME)) end