MetacelloBaselineConstructor.st
author jv
Mon, 03 Sep 2012 11:13:41 +0000
changeset 1 9e312de5f694
permissions -rw-r--r--
- Initial commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     1
"{ Package: 'stx:goodies/metacello' }"
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     2
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     3
MetacelloAbstractVersionConstructor subclass:#MetacelloBaselineConstructor
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     4
	instanceVariableNames:''
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     5
	classVariableNames:''
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     6
	poolDictionaries:''
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     7
	category:'Metacello-Core-Constructors'
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     8
!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
     9
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    10
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    11
!MetacelloBaselineConstructor class methodsFor:'instance creation'!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    12
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    13
on: aConfig
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    14
    ^ self new
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    15
        on: aConfig;
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    16
        yourself
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    17
!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    18
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    19
on: aConfig project: aProject
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    20
    ^ self new
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    21
        on: aConfig project: aProject;
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    22
        yourself
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    23
! !
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    24
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    25
!MetacelloBaselineConstructor methodsFor:'accessing'!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    26
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    27
projectClass
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    28
    ^ MetacelloMCBaselineProject
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    29
! !
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    30
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    31
!MetacelloBaselineConstructor methodsFor:'initialization'!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    32
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    33
on: aConfig
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    34
    self calculate: aConfig project: nil
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    35
!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    36
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    37
on: aConfig project: aProject
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    38
    self calculate: aConfig project: aProject
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    39
! !
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    40
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    41
!MetacelloBaselineConstructor methodsFor:'pragma extraction'!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    42
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    43
extractBaselinePragmaFor: aClass
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    44
    | pragmas |
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    45
    pragmas := Pragma allNamed: #'baseline' in: aClass.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    46
    pragmas isEmpty
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    47
        ifTrue: [ ^ self error: 'No #baseline pragma found' ].
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    48
    ^ pragmas first
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    49
! !
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    50
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    51
!MetacelloBaselineConstructor methodsFor:'private'!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    52
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    53
calculate: aConfig project: aProject
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    54
    | pragma versionMap versionSpec |
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    55
    self configuration: aConfig.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    56
    pragma := self extractBaselinePragmaFor: aConfig class.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    57
    self
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    58
        setProject:
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    59
            (aProject
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    60
                ifNil: [ 
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    61
                    [ aConfig class project ]
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    62
                        on: MessageNotUnderstood
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    63
                        do: [ :ex | ex return: nil ] ]).
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    64
    versionSpec := self project versionSpec.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    65
    self root: versionSpec.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    66
    self evaluatePragma: pragma.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    67
    versionMap := Dictionary new.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    68
    self project attributes
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    69
        do: [ :attribute | 
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    70
            | blockList |
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    71
            (blockList := self attributeMap at: attribute ifAbsent: [  ]) ~~ nil
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    72
                ifTrue: [ blockList do: [ :block | self with: versionSpec during: block ] ] ].
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    73
    versionSpec versionString: self project singletonVersionName.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    74
    versionMap at: versionSpec versionString put: versionSpec createVersion.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    75
    self project map: versionMap.
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    76
    self project configuration: aConfig
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    77
! !
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    78
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    79
!MetacelloBaselineConstructor class methodsFor:'documentation'!
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    80
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    81
version_SVN
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    82
    ^ '$Id::                                                                                                                        $'
9e312de5f694 - Initial commit
jv
parents:
diff changeset
    83
! !