Module: Primer::Static

Defined in:
lib/primer/static.rb,
lib/primer/static/generate_previews.rb,
lib/primer/static/generate_statuses.rb,
lib/primer/static/generate_arguments.rb,
lib/primer/static/generate_constants.rb,
lib/primer/static/generate_info_arch.rb,
lib/primer/static/generate_audited_at.rb

Overview

:nodoc:

Defined Under Namespace

Modules: GenerateArguments, GenerateAuditedAt, GenerateConstants, GenerateInfoArch, GeneratePreviews, GenerateStatuses

Constant Summary collapse

DEFAULT_STATIC_PATH =
File.expand_path("static").freeze
FILE_NAMES =
{
  statuses: "statuses.json",
  constants: "constants.json",
  audited_at: "audited_at.json",
  arguments: "arguments.json",
  previews: "previews.json",
  info_arch: "info_arch.json"
}.freeze

Class Method Summary collapse

Class Method Details

.dump(stats) ⇒ Object

Generates the requested stat hash and outputs it to a file.



60
61
62
63
64
65
# File 'lib/primer/static.rb', line 60

def self.dump(stats)
  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

.generate_argumentsObject

Returns an array of hashes, one per Primer component, that contains some metadata and a list of the arguments accepted by the component’s constructor. Arguments are enumerated with their value, data type, and docstring.



42
43
44
# File 'lib/primer/static.rb', line 42

def self.generate_arguments
  Static::GenerateArguments.call
end

.generate_audited_atObject

Returns a hash mapping component names to the date on which the component passed an accessibility audit.



29
30
31
# File 'lib/primer/static.rb', line 29

def self.generate_audited_at
  Static::GenerateAuditedAt.call
end

.generate_constantsObject

Returns a hash mapping component names to an array of the constants defined inside the component’s class.



35
36
37
# File 'lib/primer/static.rb', line 35

def self.generate_constants
  Static::GenerateConstants.call
end

.generate_info_archObject

Returns an array of hashes, one per Primer component, that contains all the data needed for the new primer.style docsite.



55
56
57
# File 'lib/primer/static.rb', line 55

def self.generate_info_arch
  Static::GenerateInfoArch.call
end

.generate_previewsObject

Returns an array of hashes, one per Primer component, that contains some metadata and an array of all the component’s previews. The preview data contains the Lookbook URL to each preview and its name.



49
50
51
# File 'lib/primer/static.rb', line 49

def self.generate_previews
  Static::GeneratePreviews.call
end

.generate_statusesObject

Returns a hash mapping component names to component statuses (alpha, beta, etc), sorted alphabetically by the component name.



23
24
25
# File 'lib/primer/static.rb', line 23

def self.generate_statuses
  Static::GenerateStatuses.call
end

.read(stats) ⇒ Object

Returns the contents of the stat file.



68
69
70
# File 'lib/primer/static.rb', line 68

def self.read(stats)
  File.read(File.join(DEFAULT_STATIC_PATH, FILE_NAMES[stats]))
end