Class: Utopia::Project::ReleasesDocument::Release

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

Overview

Represents a single release and its notes.

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Release

Initialize a release from its heading node.



48
49
50
# File 'lib/utopia/project/releases_document.rb', line 48

def initialize(node)
	@node = node
end

Instance Method Details

#changesObject

Enumerate the change sections for the release.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/utopia/project/releases_document.rb', line 72

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

#href(base = "/", anchor:) ⇒ Object

Build a link to a section within the release.



102
103
104
# File 'lib/utopia/project/releases_document.rb', line 102

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

#nameObject

Get the release name from its heading.



94
95
96
# File 'lib/utopia/project/releases_document.rb', line 94

def name
	@node.to_plaintext.chomp
end

#notesObject

Extract the introductory notes for the release.



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/utopia/project/releases_document.rb', line 54

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