ConfigurableFeatures.st
author Claus Gittinger <cg@exept.de>
Tue, 03 Jan 2012 15:36:22 +0100
changeset 13887 4e82ea1082c8
parent 13874 16d95fea6cbb
child 13888 ee32d4db57f5
permissions -rw-r--r--
added: #hasDataBaseSourceCodeManagerSupport #hasDataBaseSourceCodeManagerSupportEnabled

"{ Package: 'stx:libbasic' }"

Object subclass:#ConfigurableFeatures
	instanceVariableNames:''
	classVariableNames:'LoadedFeatures'
	poolDictionaries:''
	category:'System-Support'
!

!ConfigurableFeatures class methodsFor:'documentation'!

documentation
"
    being tired of finding '(Smalltalk at:someClass) notNil' all over the place,
    start to concentrate feature queries to this single class, which might get more
    feature methods via extensions.
    Thus, to correctly ask for a feature being present, use:
        ConfigurableFeature includesFeature:featureName
    or
        ConfigurableFeature knownFeatures
    to ask for a list of features.

    Caveat: just started; more will be moved to this place as time goes by
"
! !

!ConfigurableFeatures class methodsFor:'queries'!

allFeatures
    "a list of features which are present in that smalltalk configuration"

    ^ self knownFeatures select:[:each | self includesFeature:each]

    "
     ConfigurableFeatures allFeatures 
    "

    "Created: / 07-09-2011 / 10:50:31 / cg"
!

includesFeature:featureName
    |querySelector|

    querySelector := ('has',featureName asUppercaseFirst) asSymbol.
    ^ self perform:querySelector ifNotUnderstood:false.

    "
     ConfigurableFeatures includesFeature:#SubversionSupport
    "

    "Created: / 07-09-2011 / 10:49:08 / cg"
!

knownFeatures
    "a list of known features; some of them might not be present in that smalltalk configuration"

    ^ self class methodDictionary keys
        collect:[:each | 
            (each startsWith:'has') ifTrue:[
                each copyFrom:4
            ] ifFalse:[
                nil
            ].
        ]
        thenSelect:[:nm | nm notNil]

    "
     ConfigurableFeatures allFeatures
    "

    "Created: / 07-09-2011 / 10:51:26 / cg"
! !

!ConfigurableFeatures class methodsFor:'queries-features'!

hasDataBaseSourceCodeManagerSupport
    |mgr|

    "/ use Smalltalk-at to trick the dependency/prerequisite generator
    ^ (mgr := Smalltalk at: #'DataBaseSourceCodeManager') notNil
    and:[ mgr enabled ]
    "
     ConfigurableFeatures hasDataBaseSourceCodeManagerSupport
    "

    "Created: / 03-01-2012 / 15:36:03 / cg"
!

hasDataBaseSourceCodeManagerSupportEnabled
    |repository|

    "/ use Smalltalk-at to trick the dependency/prerequisite generator
    repository := Smalltalk at: #'DataBaseSourceCodeManager'.

    ^ repository notNil
        and:[ repository isLoaded 
        and:[ repository enabled ]]

    "Created: / 03-01-2012 / 15:36:12 / cg"
!

hasFileBasedSourceCodeManagerSupport
    |mgr|

    "/ use Smalltalk-at to trick the dependency/prerequisite generator
    ^ (mgr := Smalltalk at: #'FileBasedSourceCodeManager') notNil
    and:[ mgr enabled ]
    "
     ConfigurableFeatures hasFileBasedSourceCodeManagerSupport
    "

    "Created: / 21-12-2011 / 17:07:21 / cg"
!

hasFileBasedSourceCodeManagerSupportEnabled
    |repository|

    "/ use Smalltalk-at to trick the dependency/prerequisite generator
    repository := Smalltalk at: #'FileBasedSourceCodeManager'.

    ^ repository notNil
        and:[ repository isLoaded 
        and:[ repository enabled ]]

    "Created: / 21-12-2011 / 17:07:08 / cg"
!

hasSubversionSupport
    |subVersionRepository|

    "/ use Smalltalk-at to trick the dependency/prerequisite generator
    subVersionRepository := Smalltalk at: #'SVN::RepositoryManager'.

    ^ subVersionRepository notNil

    "
     ConfigurableFeatures hasSubversionSupport
    "

    "Created: / 07-09-2011 / 10:40:40 / cg"
!

hasSubversionSupportEnabled
    |subVersionRepository|

    "/ use Smalltalk-at to trick the dependency/prerequisite generator
    subVersionRepository := Smalltalk at: #'SVN::RepositoryManager'.

    ^ subVersionRepository notNil
        and:[ subVersionRepository isLoaded 
        and:[ subVersionRepository enabled ]]

    "Created: / 07-09-2011 / 10:41:33 / cg"
! !

!ConfigurableFeatures class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/ConfigurableFeatures.st,v 1.3 2012-01-03 14:36:22 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libbasic/ConfigurableFeatures.st,v 1.3 2012-01-03 14:36:22 cg Exp $'
! !