An interesting topic came up on one our calls today: what components in the "contributed" (i.e., not supported) section of our installation do our supported components rely on? Seems like a pain in the neck to test and figure out, but it turns out that the information is easy enough to come by. Using this code snippet, you can read the header of a parcel file:
properties := [CodeReader new readInfoFromFileNamed: 'parcelFileHere.pcl' asFilename]
on: OsError, CodeReader fileFormatSignal
do: [:ex | ex return: Dictionary new].
Armed with that, the following script was easy to create:
"get the contributed parcel names"
contributedDirs := (('..\contributed' asFilename directoryContents)
select: [:each | ('..\contributed' asFilename construct: each) isDirectory]) asOrderedCollection.
contributedDirs := contributedDirs collect:
[:each | ('..\contributed' asFilename construct: each) asString].
contributedDirs add: '..\contributed'.
all := OrderedCollection new.
contributedDirs do: [:each |
| current |
current := each asFilename directoryContents.
current := current select: [:each1 | '*.pcl' match: each1].
current := current collect: [:each2 | each2 copyUpTo: $.].
all addAll: current].
"now get the supported stuff"
top := 'c:\vw7.5.1' asFilename.
dirs := #('advanced' 'com' 'database' 'dllcc' '
DotNetConnect' 'DotNetConnect\parcels' 'dst' 'examples'
'icc' 'net' 'opentalk' 'packaging' 'parcels' 'pdp' 'plugin'
'preview' 'seaside' 'security' 'store'
'wavedev' 'waveserver' 'web' 'webservices').
bad := OrderedCollection new.
dirs do: [:each |
| dir |
dir := top construct: each.
files := dir directoryContents select: [:each1 | '*.pcl' match: each1].
files do: [:each1 |
| file |
file := dir construct: each1.
properties := [CodeReader new readInfoFromFileNamed: file]
on: OsError, CodeReader fileFormatSignal
do: [:ex | ex return: Dictionary new].
prereqs := properties at: #prerequisiteParcels ifAbsent: [#()].
prereqs notEmpty
ifTrue: [prereqs := prereqs collect: [:ea1 | ea1 first]].
(prereqs anySatisfy: [:ea | all includes: ea])
ifTrue: [bad add: (file asString ->prereqs)]]].
bad := bad collect: [:each |
reqs := each value select: [:ea | all includes: ea].
each key -> reqs].
Yes, the script could be cleaned up some, but it works for this purpose. Next, time to create a simple HTML table of results:
stream := WriteStream on: String new.
stream nextPutAll: '<table border="1" cellpadding="2"><tr>'; cr.
stream nextPutAll: '<td>Component Name</td><td>PreReq</td></tr>'; cr.
bad do: [:each |
stream nextPutAll: '<tr>'; cr.
stream nextPutAll: '<td>', each key asFilename tail, '</td>'; cr.
stream nextPutAll: '<td>'.
each value do: [:ea | stream nextPutAll: ea.
ea ~= each value last
ifTrue: [stream nextPutAll: ', ']].
stream nextPutAll: '</td></tr>'; cr].
stream nextPutAll: '</table>'.
^stream contents
And the results:
| Component Name | PreReq |
| DotNETSUnitTests.pcl |
SUnitUI |
| Non-Commercialization.pcl |
StoreForPostgreSQL |
| RBRegexExtensions.pcl |
Regex11 |
| RBStoreExtensions.pcl |
HotDraw Framework |
| RBSUnitExtensions.pcl |
SUnit |
| Tools-StartupOrderingTool.pcl |
HotDraw Framework |
| Seaside-Comet.pcl |
Seaside-Scriptaculous |
| Seaside-Crossfade.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside-CSSBarGraph.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside-FadeIn.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside-NumberedList.pcl |
Seaside-Scriptaculous |
| Seaside-PlotKit.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside-protoGrowl.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside-Reflection.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside-SeaChartDemo.pcl |
Seaside-Scriptaculous, Seaside-PlotKit, Seaside-Crossfade, Seaside-CSSBarGraph, Seaside-FadeIn, Seaside-NumberedList, Seaside-Reflection, Seaside-StarRater, Seaside-protoGrowl |
| Seaside-ShoreComponents.pcl |
Seaside-Scriptaculous |
| Seaside-StarRater.pcl |
Seaside-Scriptaculous, Seaside-HTML5 |
| Seaside.pcl |
SUnitToo |
| Wave-Server.pcl |
Regex11 |
| WebToolkit.pcl |
Regex11, Base64Encoding |
| WebServicesDemo.pcl |
Protocols-TestingExtensions |
Now, some of that is spurious - there are duplicate parcel names for Seaside, as we are still sorting that out. We don't need to worry much about the non-commercialization parcel either - but the other results are interesting. For instance, before I ran this script, I had not remembered that we use HotDraw in the browser. Interesting information all around...
Technorati Tags:
smalltalk, cincom smalltalk