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,
lib/primer/static/generate_form_previews.rb
Overview
:nodoc:
Defined Under Namespace
Modules: GenerateArguments, GenerateAuditedAt, GenerateConstants, GenerateFormPreviews, GenerateInfoArch, GeneratePreviews, GenerateStatuses
Constant Summary collapse
- DEFAULT_STATIC_PATH =
File.("static").freeze
- FILE_NAMES =
{ statuses: "statuses.json", constants: "constants.json", audited_at: "audited_at.json", arguments: "arguments.json", previews: "previews.json", form_previews: "form_previews.json", info_arch: "info_arch.json" }.freeze
Class Method Summary collapse
-
.dump(stats) ⇒ Object
Generates the requested stat hash and outputs it to a file.
-
.generate_arguments ⇒ Object
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.
-
.generate_audited_at ⇒ Object
Returns a hash mapping component names to the date on which the component passed an accessibility audit.
-
.generate_constants ⇒ Object
Returns a hash mapping component names to an array of the constants defined inside the component’s class.
-
.generate_form_previews ⇒ Object
Returns an array of hashes, one per example form, that contains some metadata and an array of all the form’s previews.
-
.generate_info_arch ⇒ Object
Returns an array of hashes, one per Primer component, that contains all the data needed for the new primer.style docsite.
-
.generate_previews ⇒ Object
Returns an array of hashes, one per Primer component, that contains some metadata and an array of all the component’s previews.
-
.generate_statuses ⇒ Object
Returns a hash mapping component names to component statuses (alpha, beta, etc), sorted alphabetically by the component name.
-
.read(stats) ⇒ Object
Returns the contents of the stat file.
Class Method Details
.dump(stats) ⇒ Object
Generates the requested stat hash and outputs it to a file.
68 69 70 71 72 73 |
# File 'lib/primer/static.rb', line 68 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_arguments ⇒ Object
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.
43 44 45 |
# File 'lib/primer/static.rb', line 43 def self.generate_arguments Static::GenerateArguments.call end |
.generate_audited_at ⇒ Object
Returns a hash mapping component names to the date on which the component passed an accessibility audit.
30 31 32 |
# File 'lib/primer/static.rb', line 30 def self.generate_audited_at Static::GenerateAuditedAt.call end |
.generate_constants ⇒ Object
Returns a hash mapping component names to an array of the constants defined inside the component’s class.
36 37 38 |
# File 'lib/primer/static.rb', line 36 def self.generate_constants Static::GenerateConstants.call end |
.generate_form_previews ⇒ Object
Returns an array of hashes, one per example form, that contains some metadata and an array of all the form’s previews. The preview data contains the Lookbook URL to each preview and its name.
57 58 59 |
# File 'lib/primer/static.rb', line 57 def self.generate_form_previews Static::GenerateFormPreviews.call end |
.generate_info_arch ⇒ Object
Returns an array of hashes, one per Primer component, that contains all the data needed for the new primer.style docsite.
63 64 65 |
# File 'lib/primer/static.rb', line 63 def self.generate_info_arch Static::GenerateInfoArch.call end |
.generate_previews ⇒ Object
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.
50 51 52 |
# File 'lib/primer/static.rb', line 50 def self.generate_previews Static::GeneratePreviews.call end |
.generate_statuses ⇒ Object
Returns a hash mapping component names to component statuses (alpha, beta, etc), sorted alphabetically by the component name.
24 25 26 |
# File 'lib/primer/static.rb', line 24 def self.generate_statuses Static::GenerateStatuses.call end |
.read(stats) ⇒ Object
Returns the contents of the stat file.
76 77 78 |
# File 'lib/primer/static.rb', line 76 def self.read(stats) File.read(File.join(DEFAULT_STATIC_PATH, FILE_NAMES[stats])) end |