Class: Agentilda::Index
- Inherits:
-
Object
- Object
- Agentilda::Index
- Defined in:
- lib/agentilda/index.rb
Overview
agentilda index — the project's plans as one browsable page.
Reporter answers "what is the state of things" in a terminal, in columns, for someone standing at a prompt. This answers "what is this project, and where is everything" for someone arriving at the repository on the web: the goal of each plan in its own words, every pull request as a link, and every document in the folder one click away.
It is generated for the same reason the conventions document is. A
hand-written index of twenty plans cannot survive a rename, and renaming is
exactly what resync dirs exists to do — the first hand-made INDEX.md this
replaced had all 82 of its links pointing at folder names that had been
padded to NNN.MM underneath it.
Constant Summary collapse
- FILENAME =
The file this writes, relative to the
.plansdirectory. "INDEX.md"- ARTIFACT_NAMES =
Documents that get a proper name rather than their filename.
{ "spec.md" => "Spec", "plan.md" => "Plan", "pull-requests.md" => "Pull Requests", "linear.md" => "Linear", "blocked.md" => "Blocked", "delayed.md" => "Deferred", "rewrite.md" => "Rewrite", "deployed.md" => "Deployed", "rollback.md" => "Rollback", "discarded.md" => "Discarded" }.freeze
Instance Attribute Summary collapse
- #tree ⇒ Agentilda::Tree readonly
Instance Method Summary collapse
-
#initialize(tree:, project: nil) ⇒ Index
constructor
A new instance of Index.
-
#project ⇒ String
The project's name, titleized from its directory.
-
#render ⇒ String
The whole document.
-
#write(path = nil) ⇒ String
Write it next to the plans it describes.
Constructor Details
#initialize(tree:, project: nil) ⇒ Index
Returns a new instance of Index.
40 41 42 43 |
# File 'lib/agentilda/index.rb', line 40 def initialize(tree:, project: nil) @tree = tree @project = project end |
Instance Attribute Details
#tree ⇒ Agentilda::Tree (readonly)
46 47 48 |
# File 'lib/agentilda/index.rb', line 46 def tree @tree end |
Instance Method Details
#project ⇒ String
Returns the project's name, titleized from its directory.
49 |
# File 'lib/agentilda/index.rb', line 49 def project = @project ||= Agentilda.titleize(File.basename(File.dirname(tree.dir))) |
#render ⇒ String
Returns the whole document.
52 53 54 |
# File 'lib/agentilda/index.rb', line 52 def render [heading, *tree.subjects.map { |subject| section(subject) }].join("\n") + end |
#write(path = nil) ⇒ String
Write it next to the plans it describes.
60 61 62 63 64 |
# File 'lib/agentilda/index.rb', line 60 def write(path = nil) path ||= File.join(tree.dir, FILENAME) File.write(path, render) path end |