Skip to content

Commit

Permalink
Merge pull request #2 from ba-st/holders
Browse files Browse the repository at this point in the history
Add Holders
  • Loading branch information
gcotelli authored Jan 27, 2017
2 parents 7497ed3 + 1345504 commit a23d791
Show file tree
Hide file tree
Showing 51 changed files with 338 additions and 2 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test
testCombiningOnlyUnusedHolders

| firstHolder secondHolder builder |

firstHolder := UnusedHolder explainedBy: 'This is expected'.
secondHolder := UnusedHolder explainedBy: 'This is expected as well'.

builder := HolderBuilder combining: (Array with: firstHolder with: secondHolder) using: [ :combinedContents :eachContent | combinedContents min: eachContent ].

#('This is expected' 'This is expected as well')
with: (builder builtHolder withContentDo: [ :model | self fail ] ifUnused: [ :explanations | explanations ])
do: [ :expected :built | self assert: expected equals: built ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test
testCombiningOnlyUsedHolders

| firstHolder secondHolder builder |

firstHolder := Holder containing: 11.
secondHolder := Holder containing: 30.

builder := HolderBuilder combining: (Array with: firstHolder with: secondHolder) using: [ :combinedContents :eachContent | combinedContents min: eachContent ].

self assert: (builder builtHolder withContentDo: [ :model | model ] ifUnused: [ :explanations | self fail ]) equals: 11
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
test
testCombiningUnusedAndUsedHolders

| firstHolder secondHolder builder |

firstHolder := UnusedHolder explainedBy: 'This is not expected'.
secondHolder := Holder containing: 34.
builder := HolderBuilder
combining: (Array with: firstHolder with: secondHolder)
using: [ :combinedContents :eachContent | combinedContents min: eachContent ].

self
assert:
(builder builtHolder withContentDo: [ :model | model ] ifUnused: [ :explanations | self fail ])
equals: 34
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
test
testCombiningUsedAndUnusedHolders

| firstHolder secondHolder builder |

firstHolder := Holder containing: 34.
secondHolder := UnusedHolder explainedBy: 'This is not expected'.
builder := HolderBuilder
combining: (Array with: firstHolder with: secondHolder)
using: [ :combinedContents :eachContent | combinedContents min: eachContent ].

self
assert:
(builder builtHolder withContentDo: [ :model | model ] ifUnused: [ :explanations | self fail ])
equals: 34
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"instance" : {
"testCombiningUnusedAndUsedHolders" : "GabrielOmarCotelli 1/5/2017 15:41",
"testCombiningUsedAndUnusedHolders" : "GabrielOmarCotelli 1/5/2017 15:42",
"testCombiningOnlyUsedHolders" : "GabrielOmarCotelli 1/5/2017 15:41",
"testCombiningOnlyUnusedHolders" : "GabrielOmarCotelli 1/5/2017 15:40"
},
"class" : { }
}
11 changes: 11 additions & 0 deletions source/Buoy-Tests.package/HolderBuilderTest.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "TestCase",
"category" : "Buoy-Tests-Holders",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "HolderBuilderTest",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test
testExplainedByAll

| holder |

holder := Holder containing: 'The model'.

self
assert: (holder withContentDo: [ :model | model ]) equals: 'The model';
assert: (holder withContentDo: [ :model | model ] ifUnused: [ :explanations | self fail ]) equals: 'The model'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"instance" : {
"testExplainedByAll" : "GabrielOmarCotelli 1/5/2017 15:42"
},
"class" : { }
}
11 changes: 11 additions & 0 deletions source/Buoy-Tests.package/HolderTest.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "TestCase",
"category" : "Buoy-Tests-Holders",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "HolderTest",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test
testExplainedBy

| holder |

holder := UnusedHolder explainedBy: 'This is expected'.

self
shouldnt: [ holder withContentDo: [ :model | self fail ] ] raise: Exception;
assert: (holder withContentDo: [ :model | self fail ] ifUnused: [ :explanations | explanations ]) equals: #('This is expected')
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test
testExplainedByAll

| holder |

holder := UnusedHolder explainedByAll: #('This is expected' 'This as well').

self
shouldnt: [ holder withContentDo: [ :model | self fail ] ] raise: Exception;
assert: (holder withContentDo: [ :model | self fail ] ifUnused: [ :explanations | explanations ]) equals: #('This is expected' 'This as well')
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"instance" : {
"testExplainedByAll" : "GabrielOmarCotelli 1/5/2017 15:44",
"testExplainedBy" : "GabrielOmarCotelli 1/5/2017 15:43"
},
"class" : { }
}
11 changes: 11 additions & 0 deletions source/Buoy-Tests.package/UnusedHolderTest.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "TestCase",
"category" : "Buoy-Tests-Holders",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "UnusedHolderTest",
"type" : "normal"
}
1 change: 1 addition & 0 deletions source/Buoy-Tests.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SystemOrganization addCategory: #'Buoy-Tests'!
SystemOrganization addCategory: 'Buoy-Tests-Assertions'!
SystemOrganization addCategory: 'Buoy-Tests-Holders'!
2 changes: 1 addition & 1 deletion source/Buoy-Tests.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'Buoy-Tests-GabrielOmarCotelli.2' message 'Renamed a method' id '4db25a31-cdbf-4d66-8e72-877e298b1b47' date '26 January 2017' time '7:51:46.200684 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.1' message 'Renamed packages' id '714b9a68-e0b3-4b48-be06-7b3f27f4ce47' date '26 January 2017' time '7:29:43.673983 pm' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())
(name 'Buoy-Tests-GabrielOmarCotelli.3' message 'Add Holders ' id '21414a7c-6b1d-134d-a01a-dad169c438de' date '27 January 2017' time '6:47:13.88642 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.2' message 'Renamed a method' id '4db25a31-cdbf-4d66-8e72-877e298b1b47' date '26 January 2017' time '7:51:46.200684 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.1' message 'Renamed packages' id '714b9a68-e0b3-4b48-be06-7b3f27f4ce47' date '26 January 2017' time '7:29:43.673983 pm' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())
1 change: 1 addition & 0 deletions source/Buoy.package/Holder.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the counterpart to UnusedHolder, to identify the existance of an object occupying a certain role.
4 changes: 4 additions & 0 deletions source/Buoy.package/Holder.class/class/containing..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
containing: aContent

^self new initializeContaining: aContent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialize-release
initializeContaining: aContent

content := aContent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
withContentDo: aOneArgumentBlock ifUnused: anUnusedBlock

^aOneArgumentBlock value: content
9 changes: 9 additions & 0 deletions source/Buoy.package/Holder.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"instance" : {
"initializeContaining:" : "MaximilianoTabacman 12/7/2016 08:55",
"withContentDo:ifUnused:" : "guest 1/2/2014 21:25"
},
"class" : {
"containing:" : "guest 1/2/2014 21:25"
}
}
13 changes: 13 additions & 0 deletions source/Buoy.package/Holder.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "MaximilianoTabacman 12/7/2016 08:53",
"super" : "HolderBehavior",
"category" : "Buoy-Holders",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"content"
],
"name" : "Holder",
"type" : "normal"
}
1 change: 1 addition & 0 deletions source/Buoy.package/HolderBehavior.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Abstract superclass for Holder implementations.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
withContentDo: aOneArgumentBlock

^ self withContentDo: aOneArgumentBlock ifUnused: [ ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
withContentDo: aOneArgumentBlock ifUnused: anUnusedBlock

self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"instance" : {
"withContentDo:ifUnused:" : "guest 1/2/2014 21:25",
"withContentDo:" : "MaximilianoTabacman 1/9/2017 20:09"
},
"class" : { }
}
11 changes: 11 additions & 0 deletions source/Buoy.package/HolderBehavior.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "MaximilianoTabacman 12/7/2016 08:52",
"super" : "Object",
"category" : "Buoy-Holders",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "HolderBehavior",
"type" : "normal"
}
1 change: 1 addition & 0 deletions source/Buoy.package/HolderBuilder.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A complex object that allows combining various holders.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
combining: aHolderCollection using: aContentCombinationBlock

^self new initializeCombining: aHolderCollection
using: aContentCombinationBlock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
builtHolder

self initializeCombinedHolder.
holders do: [:holder | self updateCombinedHolderConsidering: holder].
^combinedHolder
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialize-release
initializeCombinedHolder

combinedHolder := UnusedHolder explainedByAll: #()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
initialize-release
initializeCombining: aHolderCollection using: aContentCombinationBlock

holders := aHolderCollection.
combinationBlock := aContentCombinationBlock.

self initializeCombinedHolder
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
processing - private
updateCombinedHolderConsidering: holder

combinedHolder withContentDo:
[:combinedContent |
self updateCombinedHolderHolding: combinedContent considering: holder]
ifUnused:
[:combinedExplanations |
self updateUnusedCombinedHolderExplainedBy: combinedExplanations
considering: holder]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processing - private
updateCombinedHolderHolding: combinedContent considering: holder

holder withContentDo: [ :content | self updateCombinedHolderToHold: content combinedWith: combinedContent ] ifUnused: [ "Una vez que tengo algún contenido, no me interesan los unused recibidos" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processing - private
updateCombinedHolderToBeExplainedBy: explanations and: combinedExplanations

combinedHolder := UnusedHolder explainedByAll: ((OrderedCollection new)
addAll: combinedExplanations;
addAll: explanations;
yourself)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processing - private
updateCombinedHolderToHold: content

combinedHolder := Holder containing: content
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
processing - private
updateCombinedHolderToHold: content combinedWith: combinedContent

combinedHolder := Holder
containing: (combinationBlock value: combinedContent value: content)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
processing - private
updateUnusedCombinedHolderExplainedBy: combinedExplanations considering: holder

holder
withContentDo: [:content | self updateCombinedHolderToHold: content]
ifUnused:
[:explanations |
self updateCombinedHolderToBeExplainedBy: explanations
and: combinedExplanations]
16 changes: 16 additions & 0 deletions source/Buoy.package/HolderBuilder.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"instance" : {
"updateCombinedHolderToHold:combinedWith:" : "guest 1/2/2014 21:25",
"updateCombinedHolderHolding:considering:" : "MaximilianoTabacman 1/9/2017 20:09",
"updateCombinedHolderToBeExplainedBy:and:" : "guest 1/2/2014 21:25",
"initializeCombining:using:" : "guest 1/2/2014 21:25",
"updateCombinedHolderToHold:" : "guest 1/2/2014 21:25",
"initializeCombinedHolder" : "guest 1/2/2014 21:25",
"updateCombinedHolderConsidering:" : "guest 1/2/2014 21:25",
"updateUnusedCombinedHolderExplainedBy:considering:" : "guest 1/2/2014 21:25",
"builtHolder" : "guest 1/2/2014 21:25"
},
"class" : {
"combining:using:" : "guest 1/2/2014 21:25"
}
}
15 changes: 15 additions & 0 deletions source/Buoy.package/HolderBuilder.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"commentStamp" : "MaximilianoTabacman 12/7/2016 08:53",
"super" : "Object",
"category" : "Buoy-Holders",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"holders",
"combinationBlock",
"combinedHolder"
],
"name" : "HolderBuilder",
"type" : "normal"
}
1 change: 1 addition & 0 deletions source/Buoy.package/UnusedHolder.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a sort of generic null object, to identify something that is not there.
4 changes: 4 additions & 0 deletions source/Buoy.package/UnusedHolder.class/class/explainedBy..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
explainedBy: anExplanation

^self explainedByAll: (Array with: anExplanation)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
explainedByAll: anExplanationCollection

^self new initializeExplainedBy: anExplanationCollection
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialize-release
initializeExplainedBy: anExplanationCollection

explanations := anExplanationCollection
Loading

0 comments on commit a23d791

Please sign in to comment.