Class: Utopia::Project::ReleasesDocument
- Defined in:
- lib/utopia/project/releases_document.rb
Overview
Represents project release notes organized by release headings.
Defined Under Namespace
Instance Method Summary collapse
-
#latest_release ⇒ Object
Get the first release in the document.
-
#navigation ⇒ Object
Generate a navigation from the releases.
-
#release(name) ⇒ Object
Find a release by name.
-
#release_names ⇒ Object
Enumerate release names in document order.
-
#releases ⇒ Object
Enumerate releases in document order.
Methods inherited from Document
#code_node, #first_child, #html_node, #initialize, #inline_html_node, #link_node, #paragraph_node, #replace_section, #root, #text_node, #title, #to_html, #to_markdown
Constructor Details
This class inherits a constructor from Utopia::Project::Document
Instance Method Details
#latest_release ⇒ Object
Get the first release in the document.
134 135 136 137 138 |
# File 'lib/utopia/project/releases_document.rb', line 134 def latest_release if name = release_names.first release(name) end end |
#navigation ⇒ Object
Generate a navigation from the releases.
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/utopia/project/releases_document.rb', line 154 def @navigation ||= begin entries = release_names.map do |name| anchor = name.downcase.gsub(/\s+/, "-") Sidebar::Entry.new(name, 2, anchor) end Sidebar.new(entries) end end |
#release(name) ⇒ Object
Find a release by name.
124 125 126 127 128 129 130 |
# File 'lib/utopia/project/releases_document.rb', line 124 def release(name) self.root.each do |node| if node.type == :header and node.header_level == 2 and node.to_plaintext.chomp == name return Release.new(node) end end end |
#release_names ⇒ Object
Enumerate release names in document order.
111 112 113 114 115 116 117 118 119 |
# File 'lib/utopia/project/releases_document.rb', line 111 def release_names return to_enum(:release_names) unless block_given? self.root.each do |node| if node.type == :header and node.header_level == 2 yield node.to_plaintext.chomp end end end |
#releases ⇒ Object
Enumerate releases in document order.
144 145 146 147 148 149 150 |
# File 'lib/utopia/project/releases_document.rb', line 144 def releases return to_enum(:releases) unless block_given? release_names.each do |name| yield release(name) end end |