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