class Release

Represents a single release and its notes.

Definitions

def initialize(node)

Initialize a release from its heading node.

Signature

parameter node Markly::Node

The release heading node.

Implementation

def initialize(node)
	@node = node
end

def notes

Extract the introductory notes for the release.

Signature

returns Markly::Node

A document containing the release notes.

Implementation

def notes
	node = @node.next
	
	notes = Markly::Node.new(:document)
	
	while node and node.type != :header
		notes.append_child(node.dup)
		
		node = node.next
	end
	
	return notes
end

def changes

Enumerate the change sections for the release.

Signature

yields {|summary| ...}

If a block is given.

parameter summary Summary

A change section.

returns Enumerator(Summary)

If no block is given.

Implementation

def changes
	return to_enum(:changes) unless block_given?
	
	node = @node.next
	
	while node
		if node.type == :header
			if node.header_level <= @node.header_level
				break
			end
			
			if node.header_level == @node.header_level + 1
				yield Summary.new(node)
			end
		end
		
		node = node.next
	end
end

def name

Get the release name from its heading.

Signature

returns String

The release name.

Implementation

def name
	@node.to_plaintext.chomp
end

def href(base = "/", anchor:)

Build a link to a section within the release.

Signature

parameter base String

The base URL path.

parameter anchor String

The section anchor.

returns String

The release section URL.

Implementation

def href(base = "/", anchor:)
	"#{base}releases/index##{anchor.downcase.gsub(/\s+/, "-")}"
end