Class: Utopia::Project::ReleasesDocument

Inherits:
Document
  • Object
show all
Defined in:
lib/utopia/project/releases_document.rb

Overview

Represents project release notes organized by release headings.

Defined Under Namespace

Classes: Release, Summary

Instance Method Summary collapse

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_releaseObject

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

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
	@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_namesObject

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

#releasesObject

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