Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev gameye v5 #2

Merged
merged 9 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gameye-Examples/GameyeExamples.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Class {

{ #category : #'1 - load datas' }
GameyeExamples class >> loadExportedSpreadsheet [
"Open a file browser and load a .csv file exported with the application"
"Open a file browser and load a .csv file exported with the application, this example works with Gameye v4.x and v5.x"
<script>

| fileReference |
Expand Down
337 changes: 25 additions & 312 deletions Gameye-Tests/GameyeCollectionFactoryTest.class.st

Large diffs are not rendered by default.

337 changes: 337 additions & 0 deletions Gameye-Tests/GameyeCollectionFactoryV4Test.class.st

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Gameye-Tests/GameyeCollectionTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ GameyeCollectionTest >> testDuplicatedVideoGames [
self assert: collection duplicatedVideoGames size equals: 6.
]

{ #category : #tests }
GameyeCollectionTest >> testGameyeVersion [

| collection |
collection := GameyeCollection new.
collection gameyeVersion: GameyeVersion v4.
self assert: collection gameyeVersion equals: GameyeVersion v4
]

{ #category : #tests }
GameyeCollectionTest >> testIncludesCollectible [

Expand All @@ -124,6 +133,7 @@ GameyeCollectionTest >> testInitialize [
collection := GameyeCollection new.
self assert: collection name isNil.
self assert: collection date isNil.
self assert: collection gameyeVersion equals: GameyeVersion unknown.
self assert: collection haveUnknowns equals: false.
self assert: collection haveVideoGames equals: false.
self assert: collection haveSystems equals: false.
Expand Down
13 changes: 13 additions & 0 deletions Gameye/GameyeCollection.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Class {
#instVars : [
'name',
'date',
'gameyeVersion',
'peripherals',
'systems',
'toysToLife',
Expand Down Expand Up @@ -137,6 +138,18 @@ GameyeCollection >> duplicatedVideoGames [
^ self duplicated: self videoGamesCollectibles
]

{ #category : #accessing }
GameyeCollection >> gameyeVersion [

^ gameyeVersion ifNil: [ gameyeVersion := GameyeVersion unknown ]
]

{ #category : #accessing }
GameyeCollection >> gameyeVersion: anObject [

gameyeVersion := anObject
]

{ #category : #testing }
GameyeCollection >> havePeripherals [

Expand Down
39 changes: 23 additions & 16 deletions Gameye/GameyeCollectionFactory.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,15 @@ GameyeCollectionFactory class >> createCollectibleFromDataArray: anArray [
^ collectible
]

{ #category : #'create collection' }
GameyeCollectionFactory class >> createCollectionFromExportedSpreadsheet: aFileReference [
"Return just the collectibles collection (not for sell and wish list collections)"

| collections |
collections := self createCollectionsFromExportedSpreadsheet: aFileReference.
collections ifNil:[ ^ nil ].

^ collections at: GameyeCollection owned
]

{ #category : #private }
GameyeCollectionFactory class >> createCollectionsFromDataArray: anArray [
"Return collections from array : collectibles, wishlist and for sell"
| collection collections wishListCollection forSellCollection |

collections := Dictionary new.
collection := GameyeCollection new.
wishListCollection := GameyeCollection new.
forSellCollection := GameyeCollection new.
collection := GameyeCollection new gameyeVersion: GameyeVersion v4; yourself.
wishListCollection := GameyeCollection new gameyeVersion: GameyeVersion v4; yourself.
forSellCollection := GameyeCollection new gameyeVersion: GameyeVersion v4; yourself.

collections at: GameyeCollection owned put: collection.
collections at: GameyeCollection wish put: wishListCollection.
Expand All @@ -92,10 +81,11 @@ GameyeCollectionFactory class >> createCollectionsFromExportedSpreadsheet: aFile
"Return all collections from a file : collectibles, for sell and wish list"
| readStream array date collections fileName |

aFileReference ifNil:[ ^ nil ].
aFileReference isFile ifFalse:[ ^ nil ].
aFileReference ifNil:[ ^ self signalNotAFile ].
aFileReference isFile ifFalse:[ ^ self signalNotAFile ].

readStream := GameyeInputDataUtils prepareExportedSpreadsheetReadStream: aFileReference readStream.

array := self parseExportedSpreadsheetReadStream: readStream.

collections := (self createCollectionsFromDataArray: array) ifNil:[ ^ nil ].
Expand Down Expand Up @@ -124,6 +114,17 @@ GameyeCollectionFactory class >> createForSellCollectionFromExportedSpreadsheet:
^ collections at: GameyeCollection forSell
]

{ #category : #'create collection' }
GameyeCollectionFactory class >> createOwnedCollectionFromExportedSpreadsheet: aFileReference [
"Return just the collectibles collection (not for sell and wish list collections)"

| collections |
collections := self createCollectionsFromExportedSpreadsheet: aFileReference.
collections ifNil:[ ^ nil ].

^ collections at: GameyeCollection owned
]

{ #category : #'create collection' }
GameyeCollectionFactory class >> createWishListCollectionFromExportedSpreadsheet: aFileReference [
"Return just the wish list collection (not collection and for sell collections)"
Expand Down Expand Up @@ -194,6 +195,12 @@ GameyeCollectionFactory class >> parseNeoNumberString: aString [
^ NeoNumberParser parse: aString ifFail: [nil]
]

{ #category : #'error signalling' }
GameyeCollectionFactory class >> signalNotAFile [

^ NotAFileGameyeError signal
]

{ #category : #'see class side' }
GameyeCollectionFactory >> seeClassSide [
]
5 changes: 5 additions & 0 deletions Gameye/GameyeError.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #GameyeError,
#superclass : #Error,
#category : #'Gameye-Error'
}
12 changes: 9 additions & 3 deletions Gameye/GameyeInputDataUtils.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ GameyeInputDataUtils class >> prepareExportedSpreadsheetReadStream: aReadstream
"Return a ReadStream of an exported SpreadSheet file with fixing all knowns generation knowns problems"

| line fixedStream columns |
aReadstream ifNil:[ ^ nil ].
aReadstream ifNil:[ ^ self signalNotSupportedSpreadsheetFile ].

"Check if the first line (normally it's columns head) have the good number of columns and the good first title"
line := aReadstream nextLine.
columns := (line substrings: ',').
columns size = self numberOfExportedSpreadsheetColumns ifFalse: [ ^ nil ].
columns first = self exportedSpreadsheetColumn01Title ifFalse:[ ^ nil ].
columns size = self numberOfExportedSpreadsheetColumns ifFalse: [ ^ self signalNotSupportedSpreadsheetFile ].
columns first = self exportedSpreadsheetColumn01Title ifFalse:[ ^ self signalNotSupportedSpreadsheetFile ].

"Build the new stream"
fixedStream := ReadWriteStream on: String new.
Expand Down Expand Up @@ -166,6 +166,12 @@ GameyeInputDataUtils class >> rebuildCells: aCellsArray [
^newCells asArray
]

{ #category : #'error signalling' }
GameyeInputDataUtils class >> signalNotSupportedSpreadsheetFile [

^ NotSupportedSpreadsheetFileGameyeError signal
]

{ #category : #'see class side' }
GameyeInputDataUtils >> seeClassSide [
]
27 changes: 27 additions & 0 deletions Gameye/GameyeVersion.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Class {
#name : #GameyeVersion,
#superclass : #Object,
#category : #'Gameye-Model'
}

{ #category : #versions }
GameyeVersion class >> unknown [

^'unknown'
]

{ #category : #versions }
GameyeVersion class >> v4 [

^'v4'
]

{ #category : #versions }
GameyeVersion class >> v5 [

^'v5'
]

{ #category : #'see class side' }
GameyeVersion >> seeClassSide [
]
10 changes: 10 additions & 0 deletions Gameye/NotAFileGameyeError.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class {
#name : #NotAFileGameyeError,
#superclass : #GameyeError,
#category : #'Gameye-Error'
}

{ #category : #accessing }
NotAFileGameyeError >> messageText [
^ 'This element is not a file'
]
10 changes: 10 additions & 0 deletions Gameye/NotSupportedSpreadsheetFileGameyeError.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Class {
#name : #NotSupportedSpreadsheetFileGameyeError,
#superclass : #GameyeError,
#category : #'Gameye-Error'
}

{ #category : #accessing }
NotSupportedSpreadsheetFileGameyeError >> messageText [
^ 'Not supported spreadsheet file'
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Platform,Type,Owned,ForSale,Wishlist,Title,Publisher,Developer,DateAdded,Ownersh
"PS2","Peripherals",1,0,0,"Black Dual Shock Controller","Missing Field","Missing Field","31/01/2022","Loose","17.27","17.71","68.42","17.27","-1.0","?","?","10"," "," ",""
"PS2","Peripherals",1,0,0,"DVD Remote Control","Missing Field","Missing Field","15/07/2021","Sealed","9.24","13.18","22.98","22.98","13.99","10","10","10"," "," ",""
"PS2","Systems",1,0,0,"Playstation 2 System","Missing Field","Missing Field","22/03/2021","CIB","61.10","256.50","378.55","256.50","?","10","10","10"," "," ",""
"amiibo","ToysToLife",1,0,0,"Zelda - Breath of Wild","Missing Field","Missing Field","19/04/2022","Loose","26.11","26.11","36.44","26.11","13.99","?","?","10"," "," ","A cool amiibo :)"
"amiibo","ToysToLife",1,0,0,"Zelda - Breath of Wild","Missing Field","Missing Field","19/04/2022","Loose","26.11","26.11","36.44","26.11","13.99","?","?","10"," "," ","A cool amiibo :)"