From 444e60e6843f5f250b706d9ce56192efdbeeec43 Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Wed, 18 May 2022 19:03:36 +0200 Subject: [PATCH] In the beginning there was darkness. --- .project | 3 ++ src/.properties | 3 ++ .../BaselineOfClouseau.class.st | 13 ++++++ src/BaselineOfClouseau/package.st | 1 + src/Clouseau/Dictionary.extension.st | 42 +++++++++++++++++++ src/Clouseau/package.st | 1 + 6 files changed, 63 insertions(+) create mode 100644 .project create mode 100644 src/.properties create mode 100644 src/BaselineOfClouseau/BaselineOfClouseau.class.st create mode 100644 src/BaselineOfClouseau/package.st create mode 100644 src/Clouseau/Dictionary.extension.st create mode 100644 src/Clouseau/package.st diff --git a/.project b/.project new file mode 100644 index 0000000..81083cc --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory' : 'src' +} \ No newline at end of file diff --git a/src/.properties b/src/.properties new file mode 100644 index 0000000..ad0471d --- /dev/null +++ b/src/.properties @@ -0,0 +1,3 @@ +{ + #format : #tonel +} \ No newline at end of file diff --git a/src/BaselineOfClouseau/BaselineOfClouseau.class.st b/src/BaselineOfClouseau/BaselineOfClouseau.class.st new file mode 100644 index 0000000..47f94fa --- /dev/null +++ b/src/BaselineOfClouseau/BaselineOfClouseau.class.st @@ -0,0 +1,13 @@ +Class { + #name : #BaselineOfClouseau, + #superclass : #Object, + #category : #BaselineOfClouseau +} + +{ #category : #baselines } +BaselineOfClouseau >> baseline: spec [ + + spec + for: #common + do: [ spec package: 'Clouseau' ]. +] diff --git a/src/BaselineOfClouseau/package.st b/src/BaselineOfClouseau/package.st new file mode 100644 index 0000000..3e4e634 --- /dev/null +++ b/src/BaselineOfClouseau/package.st @@ -0,0 +1 @@ +Package { #name : #BaselineOfClouseau } diff --git a/src/Clouseau/Dictionary.extension.st b/src/Clouseau/Dictionary.extension.st new file mode 100644 index 0000000..41afe30 --- /dev/null +++ b/src/Clouseau/Dictionary.extension.st @@ -0,0 +1,42 @@ +Extension { #name : #Dictionary } + +{ #category : #'*Clouseau' } +Dictionary >> asStringTablePresenter [ + | tblRows | + tblRows := OrderedCollection new. + self keysAndValuesDo: [ :aKey :aValue | tblRows add: { aKey -> aValue } ]. + ^ SpTablePresenter new + addColumn: (SpStringTableColumn title: 'Key' evaluated: [ :anObject | (anObject at: 1) key ]); + addColumn: (SpStringTableColumn title: 'Value' evaluated: [ :anObject | (anObject at: 1) value ]); + items: tblRows; + alternateRowsColor; + yourself. +] + +{ #category : #'*Clouseau' } +Dictionary >> asStringTreeTablePresenter [ + + ^ SpTreeTablePresenter new + addColumn: + (SpStringTableColumn title: 'Key' evaluated: [ :anObject | + anObject isDictionary + ifTrue: [ + anObject isEmpty + ifTrue: [ '' ] + ifFalse: [ anObject keys at: 1 ] ] + ifFalse: [ anObject key ] ]); + addColumn: + (SpStringTableColumn title: 'Value' evaluated: [ :anObject | + anObject isDictionary + ifTrue: [ '' ] + ifFalse: [ anObject value ] ]); + roots: self; + children: [ :anItem | + anItem value isDictionary + ifTrue: [ + anItem value isEmpty + ifTrue: [ { } ] + ifFalse: [ anItem value ] ] + ifFalse: [ { } ] ]; + yourself +] diff --git a/src/Clouseau/package.st b/src/Clouseau/package.st new file mode 100644 index 0000000..f0dee7b --- /dev/null +++ b/src/Clouseau/package.st @@ -0,0 +1 @@ +Package { #name : #Clouseau }