lib/vclog/release.rb in vclog-1.5.0 vs lib/vclog/release.rb in vclog-1.6.0

- old
+ new

@@ -1,38 +1,53 @@ module VCLog - # + # A Release encapsulate a collection of + # Change objects associated to 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 + # def initialize(tag, changes) @tag = tag @changes = changes end + # Group +changes+ by type and sort by level. + # 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 } + ) + end + + # Compare release by tag. + def <=>(other) + @tag <=> other.tag + end + + # Convert Release to Hash. def to_h { 'version' => tag.name, 'date' => tag.date, 'message' => tag.message, 'author' => tag.author, 'revision' => tag.revision, 'changes' => changes.map{|change| change.to_h} } end - # Group +changes+ by tag type. - def groups - @groups ||= changes.group_by{ |e| e.type_number } - end - #def to_json # to_h.to_json #end - - def <=>(other) - @tag <=> other.tag - end end end