Skip to content

Commit

Permalink
refactored board saver to use instances
Browse files Browse the repository at this point in the history
  • Loading branch information
FePrHPI committed Jun 3, 2024
1 parent 62fe1e1 commit b6589f9
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Squello-Core.package/SPBBoard.class/class/openLocal..st
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ startup
openLocal: aString

| localFile |
localFile := SPBBoardSaver load: aString.
localFile := SPBBoardSaver defaultSaver load: aString.
localFile ifNotNil: [:file|^ file window openInWorld].
^ self newLocalWith: aString.
2 changes: 1 addition & 1 deletion Squello-Core.package/SPBBoard.class/instance/saveBoard.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
updating
saveBoard

SPBBoardSaver save: self as: self boardProvider repo.
SPBBoardSaver defaultSaver save: self as: self boardProvider repo.
4 changes: 2 additions & 2 deletions Squello-Core.package/SPBBoard.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"newWith:" : "mcr 8/4/2022 01:09",
"open" : "FP 5/27/2024 17:40",
"openInBackground" : "FP 5/27/2024 15:33",
"openLocal:" : "FP 5/27/2024 18:06",
"openLocal:" : "FP 6/3/2024 11:21",
"promptUrl" : "FP 5/23/2024 11:00",
"registerInAppsMenu" : "lo 6/4/2022 23:19" },
"instance" : {
Expand Down Expand Up @@ -66,7 +66,7 @@
"removeColumn:" : "lo 8/1/2022 14:09",
"rerenderColumns" : "lo 7/31/2022 16:42",
"resizeColumnArea" : "jh 8/3/2022 01:07",
"saveBoard" : "FP 5/27/2024 18:02",
"saveBoard" : "FP 6/3/2024 11:22",
"setUpChangeProvider" : "Haru 5/13/2024 14:46",
"setupColumns" : "jh 8/3/2022 00:48",
"sidebar" : "mcr 8/1/2022 00:44",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
singleton
defaultSaver

instance ifNil: [instance := SPBBoardSaver new].
^ instance.
14 changes: 7 additions & 7 deletions Squello-Core.package/SPBBoardSaver.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"class" : {
"boards" : "FP 5/27/2024 15:39",
"boards:" : "FP 5/27/2024 15:39",
"clear" : "FP 5/27/2024 17:17",
"delete:" : "FP 5/27/2024 16:21",
"load:" : "FP 5/27/2024 16:18",
"save:as:" : "FP 5/27/2024 16:15" },
"defaultSaver" : "FP 6/3/2024 11:17" },
"instance" : {
} }
"boards" : "FP 6/3/2024 11:15",
"boards:" : "FP 6/3/2024 11:15",
"clear" : "FP 6/3/2024 11:15",
"delete:" : "FP 6/3/2024 11:15",
"load:" : "FP 6/3/2024 11:15",
"save:as:" : "FP 6/3/2024 11:15" } }
4 changes: 2 additions & 2 deletions Squello-Core.package/SPBBoardSaver.class/properties.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"category" : "Squello-Core",
"classinstvars" : [
"boards" ],
"instance" ],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"boards" ],
"name" : "SPBBoardSaver",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setup
setUp

SPBBoardSaver delete: self defaultKey.
saver := SPBBoardSaver new.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setup
tearDown

SPBBoardSaver delete: self defaultKey.
saver := nil.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests
testClear

| loadedValue |
saver save: self defaultValue as: self defaultKey.
saver clear.
loadedValue := saver load: self defaultKey.
self assert: loadedValue isNil.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
tests
testDeleteReturnsNil
"the delete happens in setUp"

| loadedValue |
loadedValue := SPBBoardSaver load: self defaultKey.
saver save: self defaultValue as: self defaultKey.
saver delete: self defaultKey.
loadedValue := saver load: self defaultKey.
self assert: loadedValue isNil.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tests
testLoadCreatesCopy

| obj1 obj2 |
SPBBoardSaver save: self copyableObject as: self defaultKey.
obj1 := SPBBoardSaver load: self defaultKey.
obj2 := SPBBoardSaver load: self defaultKey.
saver save: self copyableObject as: self defaultKey.
obj1 := saver load: self defaultKey.
obj2 := saver load: self defaultKey.
self assert: (obj1 hash = obj2 hash) not.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testLoadIsCopyOfSave

| insertedObject loadedObject |
insertedObject := self copyableObject.
SPBBoardSaver save: insertedObject as: self defaultKey.
loadedObject := SPBBoardSaver load: self defaultKey.
saver save: insertedObject as: self defaultKey.
loadedObject := saver load: self defaultKey.

self assert: (insertedObject hash = loadedObject hash) not.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tests
testSaveIsSameAsLoad

| valueAfterInsertion|
SPBBoardSaver save: self defaultValue as: self defaultKey.
valueAfterInsertion := SPBBoardSaver load: self defaultKey.
saver save: self defaultValue as: self defaultKey.
valueAfterInsertion := saver load: self defaultKey.

self assert: valueAfterInsertion = self defaultValue.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"copyableObject" : "FP 5/27/2024 16:03",
"defaultKey" : "FP 5/27/2024 15:57",
"defaultValue" : "FP 5/27/2024 15:57",
"setUp" : "FP 5/27/2024 16:16",
"tearDown" : "FP 5/27/2024 16:17",
"testDeleteReturnsNil" : "FP 5/27/2024 16:17",
"testLoadCreatesCopy" : "FP 5/27/2024 16:18",
"testLoadIsCopyOfSave" : "FP 5/27/2024 16:17",
"testSaveIsSameAsLoad" : "FP 5/27/2024 16:17" } }
"setUp" : "FP 6/3/2024 11:18",
"tearDown" : "FP 6/3/2024 11:18",
"testClear" : "FP 6/3/2024 11:21",
"testDeleteReturnsNil" : "FP 6/3/2024 11:20",
"testLoadCreatesCopy" : "FP 6/3/2024 11:19",
"testLoadIsCopyOfSave" : "FP 6/3/2024 11:19",
"testSaveIsSameAsLoad" : "FP 6/3/2024 11:19" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"commentStamp" : "",
"instvars" : [
],
"saver" ],
"name" : "SPBLocalSaveTests",
"pools" : [
],
Expand Down

0 comments on commit b6589f9

Please sign in to comment.