lib/vclog/release.rb in vclog-1.8.2 vs lib/vclog/release.rb in vclog-1.9.0
- old
+ new
@@ -1,53 +1,67 @@
module VCLog
- # A Release encapsulate a collection of
- # Change objects associated to a Tag.
+ # A Release encapsulate a collection of {Change} objects
+ # associated with a {Tag}.
+ #
class Release
# Tag object this release represents.
attr :tag
# Array of Change objects.
attr :changes
+ #
# New Release object.
#
- # tag - Tag object
- # change - Array of Change objects
+ # @param [Tag] tag
+ # A Tag object.
#
+ # @param [Array<Change>] changes
+ # An array of Change objects.
+ #
def initialize(tag, changes)
- @tag = tag
+ @tag = tag
@changes = changes
end
+ #
# Group +changes+ by type and sort by level.
- # Returns an associative array of [type, changes].
+ #
+ # @return [Array<Array>]
+ # Returns an associative array of [type, changes].
+ #
def groups
@groups ||= (
- changes.group_by{ |e| e.type }.sort{ |a,b| b[1][0].level <=> a[1][0].level }
+ changes.group_by{ |e| e.label }.sort{ |a,b| b[1][0].level <=> a[1][0].level }
)
end
+ #
# Compare release by tag.
+ #
+ # @param [Release] other
+ # Another release instance.
+ #
def <=>(other)
@tag <=> other.tag
end
+ #
# Convert Release to Hash.
+ #
+ # @todo Should +version+ be +name+?
+ #
def to_h
{ 'version' => tag.name,
'date' => tag.date,
'message' => tag.message,
'author' => tag.author,
- 'revision' => tag.revision,
+ 'id' => tag.id,
'changes' => changes.map{|change| change.to_h}
}
end
- #def to_json
- # to_h.to_json
- #end
end
end
-