initial checkin
authorClaus Gittinger <cg@exept.de>
Wed, 07 Sep 2011 10:54:18 +0200
changeset 13641 2fe2dd2ca2d3
parent 13640 d5ffef38fdd8
child 13642 37eba7280fcf
initial checkin
ConfigurableFeatures.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConfigurableFeatures.st	Wed Sep 07 10:54:18 2011 +0200
@@ -0,0 +1,112 @@
+"{ 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'!
+
+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.1 2011-09-07 08:54:18 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libbasic/ConfigurableFeatures.st,v 1.1 2011-09-07 08:54:18 cg Exp $'
+! !