class Release
Represents a single release and its notes.
Definitions
def initialize(node)
Initialize a release from its heading node.
Signature
-
parameter
nodeMarkly::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
summarySummary A change section.
-
parameter
-
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
baseString The base URL path.
-
parameter
anchorString The section anchor.
-
returns
String The release section URL.
Implementation
def href(base = "/", anchor:)
"#{base}releases/index##{anchor.downcase.gsub(/\s+/, "-")}"
end