reports/Builder__ChangeReport.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 273 31ab0665a9dc
permissions -rw-r--r--
#DOCUMENTATION by cg
class: stx_goodies_builder_quickSelfTest
class definition

class: stx_goodies_builder_quickSelfTest class
added:18 methods
     1 "{ Package: 'stx:goodies/builder/reports' }"
     2 
     3 "{ NameSpace: Builder }"
     4 
     5 Report subclass:#ChangeReport
     6 	instanceVariableNames:'gofer'
     7 	classVariableNames:''
     8 	poolDictionaries:''
     9 	category:'Builder-Reports-Unfinished'
    10 !
    11 
    12 
    13 !ChangeReport methodsFor:'accessing'!
    14 
    15 changesFor: aResolvedVersion
    16 	| references patch |
    17 	references := gofer allResolved
    18 		select: [ :each | each packageName = aResolvedVersion packageName ].
    19 	patch := MCPatch 
    20 		fromBase: (references size > 1 
    21 			ifTrue: [ (references at: references size - 1) version snapshot ]
    22 			ifFalse: [ MCSnapshot empty ])
    23 		target: aResolvedVersion version snapshot.
    24 	^ patch operations asSortedCollection
    25 !
    26 
    27 resolved
    28 	^ gofer resolved
    29 ! !
    30 
    31 !ChangeReport methodsFor:'generating'!
    32 
    33 generateChange: aPatch on: aStream
    34 	aPatch isAddition
    35 		ifTrue: [ ^ self generateChangeAddition: aPatch on: aStream ].
    36 	aPatch isModification
    37 		ifTrue: [ ^ self generateChangeModification: aPatch on: aStream ].
    38 	aPatch isRemoval
    39 		ifTrue: [ ^ self generateChangeRemoval: aPatch on: aStream ]
    40 !
    41 
    42 generateChangeAddition: aPatch on: aStream
    43 	aStream tab; tab; tab; nextPutAll: '<item action="add">'; nextPutAll: (self encode: (self convert: aPatch summary)); nextPutAll: '</item>'; nextPut: Character lf
    44 !
    45 
    46 generateChangeModification: aPatch on: aStream
    47 	aStream tab; tab; tab; nextPutAll: '<item action="change">'; nextPutAll: (self encode: (self convert: aPatch summary)); nextPutAll: '</item>'; nextPut: Character lf
    48 !
    49 
    50 generateChangeRemoval: aPatch on: aStream
    51 	aStream tab; tab; tab; nextPutAll: '<item action="remove">'; nextPutAll: (self encode: (self convert: aPatch summary)); nextPutAll: '</item>'; nextPut: Character lf
    52 !
    53 
    54 generateChangeSet: aResolvedVersion on: aStream
    55 	| info |
    56 	info := aResolvedVersion version info.
    57 	aStream tab; nextPutAll: '<logentry version="'; nextPutAll: (self encode: info name); nextPutAll: '">'; nextPut: Character lf.
    58 	aStream tab; tab; nextPutAll: '<date>'; nextPutAll: (self encode: info date yyyymmdd); space; nextPutAll: (self encode: info time print24); nextPutAll: '</date>'; nextPut: Character lf.
    59 	aStream tab; tab; nextPutAll: '<author>'; nextPutAll: (self encode: info author); nextPutAll: '</author>'; nextPut: Character lf.
    60 	aStream tab; tab; nextPutAll: '<msg>'; nextPutAll: (self encode: (self convert: info message)); nextPutAll: '</msg>'; nextPut: Character lf.
    61 	"aStream tab; tab; nextPutAll: '<items>'; nextPut: Character lf.
    62 	(self changesFor: aResolvedVersion)
    63 		do: [ :each | self generateChange: each on: aStream ].
    64 	aStream tab; tab; nextPutAll: '</items>'; nextPut: Character lf."
    65 	aStream tab; nextPutAll: '</logentry>'; nextPut: Character lf
    66 !
    67 
    68 generateOn: aStream
    69 	aStream nextPutAll: '<?xml version="1.0" encoding="UTF-8"?>'; nextPut: Character lf.
    70 	aStream nextPutAll: '<changelog>'; nextPut: Character lf.
    71 	self resolved
    72 		do: [ :each | self generateChangeSet: each on: aStream ].
    73 	aStream nextPutAll: '<changelog>'
    74 ! !
    75 
    76 !ChangeReport methodsFor:'initialization'!
    77 
    78 initializeOn: aCollection
    79 	gofer := Gofer new.
    80 	aCollection do: [ :each | gofer package: each ]
    81 ! !
    82 
    83 !ChangeReport methodsFor:'running'!
    84 
    85 run
    86         | stream |
    87         stream := (Filename defaultDirectory directory / 'changelog.xml') writeStream.
    88         [ self generateOn: stream ]
    89                 ensure: [ stream close ]
    90 ! !
    91 
    92 !ChangeReport class methodsFor:'documentation'!
    93 
    94 version
    95     ^ '$Header$'
    96 !
    97 
    98 version_CVS
    99     ^ '$Header$'
   100 !
   101 
   102 version_SVN
   103     ^ '$Id$'
   104 ! !
   105