From 615542c95a11ebea114c3aa7710bdf75ef5b3d60 Mon Sep 17 00:00:00 2001 From: Patrik Date: Mon, 6 Oct 2025 12:20:07 +0000 Subject: [PATCH 01/13] Refactoring to reflect that GemStone has Dictionary only without order --- .../NeoJSONObjectTests.class/instance/testFindPaths.st | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st index c25e3e9..ae436cd 100644 --- a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st @@ -1,8 +1,6 @@ testing testFindPaths - | json paths testingArray | json := self class exampleJSONSchema. - testingArray := #((#'properties' #'street_address') (#'$defs' #'country')). paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'$anchor' ] ]. self deny: paths isEmpty. @@ -24,3 +22,4 @@ testFindPaths paths := json findPaths: [ :_ | true ]. paths do: [ :each | self assert: (json atPath: each) notNil ] + From c7b1f7301b77233655f8ce10e853a7025352d0ab Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 8 Jan 2026 11:20:13 +0000 Subject: [PATCH 02/13] Message quicker re-implementation for SmallInteger - taken from Pharo --- .../SmallInteger.extension/instance/decimalDigitLength.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/decimalDigitLength.st b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/decimalDigitLength.st index a83473a..2295f2e 100644 --- a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/decimalDigitLength.st +++ b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/decimalDigitLength.st @@ -6,7 +6,7 @@ decimalDigitLength "100000000 decimalDigitLength >>> 9" "SmallInteger maxVal decimalDigitLength >>> 19" - self negative ifTrue: [^self negated decimalDigitLength]. + self negative ifTrue: [ ^ self negated decimalDigitLength ]. ^self < 10000 ifTrue: [self < 100 From e77cd0e576a0eed8f3da282395eb41cc1f35c1e5 Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 26 Mar 2026 10:22:22 +0000 Subject: [PATCH 03/13] Revert "Refactoring to reflect that GemStone has Dictionary only without order" This reverts commit 7bc3245206c2ac383a13f05ffce39d97c5f59de5. Now we load OrderedDictionary, the patch is not needed --- .../instance/testFindPaths.st | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st index ae436cd..465ffc8 100644 --- a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st @@ -4,13 +4,10 @@ testFindPaths paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'$anchor' ] ]. self deny: paths isEmpty. - (paths asArray) do: [ :eachArray | - self assert: (testingArray includes: eachArray) ]. - paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'street_address' ] ]. - self assert: (testingArray includes: paths flattened). - paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'country' ] ]. - self assert: (testingArray includes: paths flattened). - + self assert: paths asArray equals: #((properties street_address) (#'$defs' #'country')). + self assert: ((json atPath: paths first) at: #'$anchor') equals: 'street_address'. + self assert: ((json atPath: paths second) at: #'$anchor') equals: 'country'. + paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'foo') = 'bar' ] ]. self assert: paths isEmpty. @@ -22,4 +19,3 @@ testFindPaths paths := json findPaths: [ :_ | true ]. paths do: [ :each | self assert: (json atPath: each) notNil ] - From 5aafe80de115d3114790d7f004c2f41af6a80e88 Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 26 Mar 2026 11:53:04 +0000 Subject: [PATCH 04/13] Fixing incorrect category name for classes --- .../Attachment.class/properties.json | 2 +- .../BittrexResponse.class/properties.json | 2 +- .../Market.class/properties.json | 2 +- .../NeoJSONPharoExamples.class/properties.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json index d27738c..47127ce 100644 --- a/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json +++ b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "Neo-JSON-Gemstone-Examples", + "category" : "Neo-JSON-GemStone-Examples", "classinstvars" : [ ], "classvars" : [ diff --git a/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json index 3888853..3660b85 100644 --- a/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json +++ b/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "Neo-JSON-Gemstone-Examples", + "category" : "Neo-JSON-GemStone-Examples", "classinstvars" : [ ], "classvars" : [ diff --git a/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json index 735a637..095da18 100644 --- a/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json +++ b/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "Neo-JSON-Gemstone-Examples", + "category" : "Neo-JSON-GemStone-Examples", "classinstvars" : [ ], "classvars" : [ diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json index 77da182..839a656 100644 --- a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "Neo-JSON-Gemstone-Examples", + "category" : "Neo-JSON-GemStone-Examples", "classinstvars" : [ ], "classvars" : [ From 671faa4716d553b02220974864c24492d766de75 Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 26 Mar 2026 12:10:38 +0000 Subject: [PATCH 05/13] OrderedDictionary extension code unified for GemStone and Pharo --- .../OrderedDictionary.extension/instance/neoJsonOn..st | 2 +- .../OrderedDictionary.extension/properties.json | 0 .../SmallInteger.extension/instance/numberOfDigitsInBase..st | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename filetree/{Neo-JSON-Pharo-Core.package => Neo-JSON-Core.package}/OrderedDictionary.extension/instance/neoJsonOn..st (72%) rename filetree/{Neo-JSON-Pharo-Core.package => Neo-JSON-Core.package}/OrderedDictionary.extension/properties.json (100%) diff --git a/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st similarity index 72% rename from filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st index 61a9c65..174eb53 100644 --- a/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st +++ b/filetree/Neo-JSON-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st @@ -1,3 +1,3 @@ -*neo-json-pharo-core +*neo-json-core neoJsonOn: neoJSONWriter neoJSONWriter writeMap: self \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/properties.json b/filetree/Neo-JSON-Core.package/OrderedDictionary.extension/properties.json similarity index 100% rename from filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/properties.json rename to filetree/Neo-JSON-Core.package/OrderedDictionary.extension/properties.json diff --git a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st index afe7283..7c2c785 100644 --- a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st +++ b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st @@ -4,4 +4,4 @@ numberOfDigitsInBase: b Mostly same as super but an optimized version for base 10 case" self < 0 ifTrue: [^self negated numberOfDigitsInBase: b]. - ^super numberOfDigitsInBase: b + ^ super numberOfDigitsInBase: b From 3b9d7ae7728d52db8b8cfc6f3f599b978d118ab6 Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 26 Mar 2026 12:13:02 +0000 Subject: [PATCH 06/13] When GemStone supports tonel format loading NeoJSON library is ready --- .../BaselineOfNeoJSON.class.st | 9 ++ .../OrderedDictionary.extension.st | 6 + .../BinaryFloat.extension.st | 25 ++++ .../Integer.extension.st | 85 +++++++++++ .../KeyValueDictionary.extension.st | 21 +++ .../MultiByteString.extension.st | 6 + .../OrderedDictionary.extension.st | 6 + .../SmallInteger.extension.st | 95 ++++++++++++ repository/Neo-JSON-GemStone-Core/package.st | 1 + .../Attachment.class.st | 19 +++ .../BittrexResponse.class.st | 10 ++ .../Market.class.st | 18 +++ .../NeoJSONGemStoneExamples.class.st | 137 ++++++++++++++++++ .../Neo-JSON-GemStone-Examples/package.st | 1 + repository/Neo-JSON-GemStone-Tests/package.st | 1 + 15 files changed, 440 insertions(+) create mode 100644 repository/Neo-JSON-Core/OrderedDictionary.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/Integer.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st create mode 100644 repository/Neo-JSON-GemStone-Core/package.st create mode 100644 repository/Neo-JSON-GemStone-Examples/Attachment.class.st create mode 100644 repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st create mode 100644 repository/Neo-JSON-GemStone-Examples/Market.class.st create mode 100644 repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st create mode 100644 repository/Neo-JSON-GemStone-Examples/package.st create mode 100644 repository/Neo-JSON-GemStone-Tests/package.st diff --git a/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st b/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st index eef15a6..0b56159 100644 --- a/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st +++ b/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st @@ -28,4 +28,13 @@ BaselineOfNeoJSON >> baseline: spec [ group: 'Core' with: #('Neo-JSON-Core' 'Neo-JSON-Pharo-Core'); group: 'Tests' with: #('Neo-JSON-Tests' 'Neo-JSON-Pharo-Tests'); group: 'Examples' with: #('Neo-JSON-Pharo-Examples') ]. + spec + for: #gemstone + do: [ spec + package: 'Neo-JSON-GemStone-Core' with: [ spec requires: #('Neo-JSON-Core') ]; + package: 'Neo-JSON-GemStone-Tests' with: [ spec requires: #('Neo-JSON-Tests') ]; + package: 'Neo-JSON-GemStone-Examples' with: [ spec requires: #('Neo-JSON-Core') ]; + group: 'Core' with: #('Neo-JSON-Core' 'Neo-JSON-GemStone-Core'); + group: 'Tests' with: #('Neo-JSON-Tests' 'Neo-JSON-GemStone-Tests'); + group: 'Examples' with: #('Neo-JSON-GemStone-Examples') ]. ] diff --git a/repository/Neo-JSON-Core/OrderedDictionary.extension.st b/repository/Neo-JSON-Core/OrderedDictionary.extension.st new file mode 100644 index 0000000..b76576a --- /dev/null +++ b/repository/Neo-JSON-Core/OrderedDictionary.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #OrderedDictionary } + +{ #category : #'*neo-json-core' } +OrderedDictionary >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeMap: self +] diff --git a/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st b/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st new file mode 100644 index 0000000..329c70e --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st @@ -0,0 +1,25 @@ +Extension { #name : 'BinaryFloat' } + +{ #category : '*neo-json-gemstone-core' } +BinaryFloat class >> negativeInfinity [ + + ^ self fromString: 'MinusInfinity' +] + +{ #category : '*neo-json-gemstone-core' } +BinaryFloat class >> zero [ + + ^ 0.0 +] + +{ #category : '*neo-json-gemstone-core' } +BinaryFloat >> isFinite [ + + ^(self - self) = 0.0 +] + +{ #category : '*neo-json-gemstone-core' } +BinaryFloat >> isZero [ + + ^ self = 0.0 +] diff --git a/repository/Neo-JSON-GemStone-Core/Integer.extension.st b/repository/Neo-JSON-GemStone-Core/Integer.extension.st new file mode 100644 index 0000000..446fd02 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/Integer.extension.st @@ -0,0 +1,85 @@ +Extension { #name : 'Integer' } + +{ #category : '*neo-json-gemstone-core' } +Integer >> asCharacterDigit [ + + ^ Character digitValue: self +] + +{ #category : '*neo-json-gemstone-core' } +Integer >> digitAt: anExponent base: base [ + + ^ self // (base raisedToInteger: anExponent - 1) \\ base + +] + +{ #category : '*neo-json-gemstone-core' } +Integer >> isPowerOfTwo [ + "Return true if the receiver is an integral power of two." + ^ self ~= 0 and: [ (self bitAnd: self-1) = 0 ] +] + +{ #category : '*neo-json-gemstone-core' } +Integer >> numberOfDigitsInBase: b [ + "Return how many digits are necessary to print this number in base b. + This does not count any place for minus sign, radix prefix or whatever. + Note that this algorithm may cost a few operations on LargeInteger." + + | nDigits q total | + self negative ifTrue: [^self negated numberOfDigitsInBase: b]. + self < b ifTrue: [^1]. + b isPowerOfTwo ifTrue: [^self highBit + b highBit - 2 quo: b highBit - 1]. + + "A conversion from base 2 to base b has to be performed. + This algorithm avoids Float computations like (self log: b) floor + 1, + 1) because they are inexact + 2) because LargeInteger might overflow + 3) because this algorithm might be cheaper than conversion" + + q := self. + total := 0. + ["Make an initial nDigits guess that is lower than or equal to required number of digits" + nDigits := b = 10 + ifTrue: [((q highBit - 1) * 1233 >> 12) + 1. "This is because (2 log)/(10 log)*4096 is slightly greater than 1233"] + ifFalse: [q highBit quo: b highBit]. + total := total + nDigits. + + "See how many digits remains above these first nDigits guess" + (q := q quo: (b raisedToInteger: nDigits)) < b] whileFalse. + ^q = 0 + ifTrue: [total] + ifFalse: [total + 1] +] + +{ #category : '*neo-json-gemstone-core' } +Integer >> print: positiveNumberString on: aStream prefix: prefix length: minimum padded: zeroFlag [ + "Return a String based on concatenation of positiveNumberString with prefix then padded by 0 is zeroFlag is set for a minimum length." + + "(String streamContents: [ :s | 10 print: '10' on: s prefix: 'zz' length: 4 padded: true ] ) >>> 'zz10'" + + | padLength | + padLength := minimum - positiveNumberString size - prefix size. + padLength > 0 + ifTrue: [ zeroFlag + ifTrue: [ aStream nextPutAll: prefix; nextPutAll: (String new: padLength withAll: $0) ] + ifFalse: [ aStream nextPutAll: (String new: padLength withAll: Character space); nextPutAll: prefix ] ] + ifFalse: [ aStream nextPutAll: prefix ]. + aStream nextPutAll: positiveNumberString +] + +{ #category : '*neo-json-gemstone-core' } +Integer >> printOn: aStream base: base length: minimum padded: zeroFlag [ + "Return a String representation of this number in base b with a minimum length and padded by 0 if zeroFlag is set" + + "(String streamContents: [ :s | 10 printOn: s base: 10 length: 4 padded: true] ) >>> '0010'" + "(String streamContents: [ :s | -10 printOn: s base: 10 length: 4 padded: true] ) >>> '-010'" + + | prefix | + prefix := self negative ifTrue: ['-'] ifFalse: [ '' ]. + self + print: (self abs printStringBase: base) + on: aStream + prefix: prefix + length: minimum + padded: zeroFlag +] diff --git a/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st b/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st new file mode 100644 index 0000000..7fe44c5 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st @@ -0,0 +1,21 @@ +Extension { #name : 'KeyValueDictionary' } + +{ #category : '*neo-json-gemstone-core' } +KeyValueDictionary class >> newFromPairs: anArray [ + "Answer an instance of me associating (anArray at:i) to (anArray at: i+i) + for each odd i. anArray must have an even number of entries. + Dictionary newFromPairs: {'Red' . Color red . 'Blue' . Color blue . 'Green' . Color green}. " + | newDictionary | + + newDictionary := self new: (anArray size/2). + 1 to: (anArray size-1) by: 2 do: [ :i| + newDictionary at: (anArray at: i) put: (anArray at: i+1). + ]. + ^ newDictionary + +] + +{ #category : '*neo-json-gemstone-core' } +KeyValueDictionary >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeMap: self +] diff --git a/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st b/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st new file mode 100644 index 0000000..7bab06e --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st @@ -0,0 +1,6 @@ +Extension { #name : 'MultiByteString' } + +{ #category : '*neo-json-gemstone-core' } +MultiByteString >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeString: self +] diff --git a/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st b/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st new file mode 100644 index 0000000..86e9162 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st @@ -0,0 +1,6 @@ +Extension { #name : 'OrderedDictionary' } + +{ #category : '*neo-json-gemstone-core' } +OrderedDictionary >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeMap: self +] diff --git a/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st b/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st new file mode 100644 index 0000000..fc5b7a4 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st @@ -0,0 +1,95 @@ +Extension { #name : 'SmallInteger' } + +{ #category : '*neo-json-gemstone-core' } +SmallInteger >> decimalDigitLength [ + "Answer the number of digits printed out in base 10. + Note that this only works for positive SmallIntegers up to 64-bits." + "1 decimalDigitLength >>> 1" + "100000000 decimalDigitLength >>> 9" + "SmallInteger maxVal decimalDigitLength >>> 19" + + ^self < 10000 + ifTrue: + [self < 100 + ifTrue: + [self < 10 ifTrue: [1] ifFalse: [2]] + ifFalse: + [self < 1000 ifTrue: [3] ifFalse: [4]]] + ifFalse: + [self < 100000000 + ifTrue: + [self < 1000000 + ifTrue: [self < 100000 ifTrue: [5] ifFalse: [6]] + ifFalse: [self < 10000000 ifTrue: [7] ifFalse: [8]]] + ifFalse: + [self < 1000000000000 + ifTrue: + [self < 10000000000 + ifTrue: [self < 1000000000 ifTrue: [9] ifFalse: [10]] + ifFalse: [self < 100000000000 ifTrue: [11] ifFalse: [12]]] + ifFalse: + [self < 10000000000000000 + ifTrue: + [self < 100000000000000 + ifTrue: [self < 10000000000000 ifTrue: [13] ifFalse: [14]] + ifFalse: [self < 1000000000000000 ifTrue: [15] ifFalse: [16]]] + ifFalse: + [self < 1000000000000000000 + ifTrue: [self < 100000000000000000 ifTrue: [17] ifFalse: [18]] + ifFalse: [self < 10000000000000000000 ifTrue: [19] ifFalse: [20]]]]]] + +] + +{ #category : '*neo-json-gemstone-core' } +SmallInteger >> numberOfDigitsInBase: b [ + "Return how many digits are necessary to print this number in base b. + Mostly same as super but an optimized version for base 10 case" + + b = 10 ifFalse: [^super numberOfDigitsInBase: b]. + self < 0 ifTrue: [^self negated numberOfDigitsInBase: b]. + ^ self decimalDigitLength + +] + +{ #category : '*neo-json-gemstone-core' } +SmallInteger >> printOn: stream base: base length: minimumLength padded: padWithZeroes [ + "Return a String representation of this number in base b with a minimum length and padded by 0 if zeroFlag is set" + + "(String streamContents: [ :s | 10 printOn: s base: 10 length: 4 padded: true] ) >>> '0010'" + "(String streamContents: [ :s | -10 printOn: s base: 10 length: 4 padded: true] ) >>> '-010'" + + | n numberOfDigits totalLength divisor | + self < 0 + ifTrue: [ + n := self negated. + totalLength := 1 ] + ifFalse: [ + n := self. + totalLength := 0 ]. + numberOfDigits := n numberOfDigitsInBase: base. + totalLength := totalLength + numberOfDigits. + padWithZeroes ifFalse: [ + [ totalLength < minimumLength ] whileTrue: [ + stream space. + totalLength := totalLength + 1 ] ]. + n = self ifFalse: [ stream nextPut: $- ]. + padWithZeroes ifTrue: [ + [ totalLength < minimumLength ] whileTrue: [ + stream nextPut: $0. + totalLength := totalLength + 1 ] ]. + divisor := (base raisedToInteger: numberOfDigits - 1). + [ divisor > 0 ] whileTrue: [ + | digit | + digit := n // divisor. + stream nextPut: ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' at: digit + 1). + n := n - (digit * divisor). + divisor := divisor // base ] +] + +{ #category : '*neo-json-gemstone-core' } +SmallInteger >> printOn: aStream base: b nDigits: n [ + "Append a representation of this number in base b on aStream using nDigits. + self must be positive." + + self printOn: aStream base: b length: n padded: true +] \ No newline at end of file diff --git a/repository/Neo-JSON-GemStone-Core/package.st b/repository/Neo-JSON-GemStone-Core/package.st new file mode 100644 index 0000000..df99358 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Core/package.st @@ -0,0 +1 @@ +Package { #name : 'Neo-JSON-GemStone-Core' } diff --git a/repository/Neo-JSON-GemStone-Examples/Attachment.class.st b/repository/Neo-JSON-GemStone-Examples/Attachment.class.st new file mode 100644 index 0000000..de23502 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Examples/Attachment.class.st @@ -0,0 +1,19 @@ +Class { + #name : 'Attachment', + #superclass : 'Object', + #instVars : [ + 'url', + 'fileName' + ], + #category : 'Neo-JSON-GemStone-Examples' +} + +{ #category : 'accessing' } +Attachment >> fileName: anObject [ + fileName := anObject +] + +{ #category : 'accessing' } +Attachment >> url: anObject [ + url := anObject +] diff --git a/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st b/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st new file mode 100644 index 0000000..133dff9 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st @@ -0,0 +1,10 @@ +Class { + #name : 'BittrexResponse', + #superclass : 'Object', + #instVars : [ + 'success', + 'message', + 'result' + ], + #category : 'Neo-JSON-GemStone-Examples' +} diff --git a/repository/Neo-JSON-GemStone-Examples/Market.class.st b/repository/Neo-JSON-GemStone-Examples/Market.class.st new file mode 100644 index 0000000..519ee2e --- /dev/null +++ b/repository/Neo-JSON-GemStone-Examples/Market.class.st @@ -0,0 +1,18 @@ +Class { + #name : 'Market', + #superclass : 'Object', + #instVars : [ + 'MarketCurrency', + 'BaseCurrency', + 'MarketCurrencyLong', + 'BaseCurrencyLong', + 'MinTradeSize', + 'MarketName', + 'IsActive', + 'Created', + 'Notice', + 'IsSponsored', + 'LogoUrl' + ], + #category : 'Neo-JSON-GemStone-Examples' +} diff --git a/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st b/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st new file mode 100644 index 0000000..488c404 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st @@ -0,0 +1,137 @@ +Class { + #name : 'NeoJSONGemStoneExamples', + #superclass : 'TestCase', + #category : 'Neo-JSON-GemStone-Examples' +} + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testAccessingTheNewYorkPublicLibrary [ + + | client reader data networkStream | + (client := ZnClient new) + streaming: true; + url: 'https://github.com/NYPL-publicdomain/data-and-utilities/blob/master/items/pd_items_1.ndjson?raw=true'; + get. + networkStream := ZnCharacterReadStream on: client contents. + reader := NeoJSONReader on: networkStream. + data := Array streamContents: [ :out | [ reader atEnd ] whileFalse: [ out nextPut: reader next ] ]. + client close. + data +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testAttachmentsExample [ + | collectionOne json | + "Let's create a collection of two instances:" + collectionOne := {(Attachment new + url: 'http://example.com/random-name.txt' asZnUrl; + fileName: 'chapter-one.txt' yourself). + (Attachment new + url: 'http://example.com/random-name.png' asZnUrl; + fileName: 'image.png'; + yourself)}. + + "And let's map it to a JSON structure:" + json := String + streamContents: [ :aStream | + (NeoJSONWriter on: aStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + mapAllInstVarsFor: Attachment; + for: ZnUrl customDo: [ :mapping | mapping encoder: [ :aZnUrl | aZnUrl asString ] ]; + nextPut: collectionOne as: #CollectionOfAttachments ]. + + + "And read the JSON structure:" + (NeoJSONReader on: json readStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + for: Attachment + do: [ :mapping | + mapping mapInstVar: 'fileName'. + (mapping mapInstVar: 'url') valueSchema: ZnUrl ]; + for: ZnUrl customDo: [ :mapping | mapping decoder: [ :string | string asZnUrl ] ]; + nextAs: #CollectionOfAttachments +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testBittrexLitecoinAsDictionary [ + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarketSummary?market=BTC-LTC'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader next ]; + get. + +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testBittrexLitecoinAsDomainObjects [ + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarkets'; + enforceHttpSuccess: true; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader for: BittrexResponse do: [:m| + m mapInstVar: #success. + m mapInstVar: #message. + (m mapInstVar: #result) valueSchema: #ArrayOfMarkets]. + reader for: #ArrayOfMarkets customDo: [ :mapping | mapping listOfElementSchema: Market ]. + reader mapInstVarsFor: Market. + reader nextAs: BittrexResponse ]; + get +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testDoomtownDBCards [ + + NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testFeed [ + | json | + json := ZnClient new + systemPolicy; + url: 'https://daringfireball.net/feeds/json'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | NeoJSONObject fromString: entity contents ]; + get. + json items collect: #title. + json items collect: [ :each | each title -> each url ]. + json +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testGetWorldCapitals [ + ((NeoJSONReader fromString: (ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) + collect: [ :d | d at: #capital ] +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testGoogleMapsAPI [ + + ZnClient new + url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testParsingUserAgentStrings [ + ZnClient new + http; + host: 'useragentstring.com'; + queryAt: 'uas' put: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4'; + queryAt: 'getJSON' put: 'all'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get +] + +{ #category : 'tests' } +NeoJSONGemStoneExamples >> testStackOverflowInfo [ + + ZnClient new + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get: 'http://api.stackexchange.com/2.1/info?site=stackoverflow' +] diff --git a/repository/Neo-JSON-GemStone-Examples/package.st b/repository/Neo-JSON-GemStone-Examples/package.st new file mode 100644 index 0000000..838edc2 --- /dev/null +++ b/repository/Neo-JSON-GemStone-Examples/package.st @@ -0,0 +1 @@ +Package { #name : 'Neo-JSON-GemStone-Examples' } diff --git a/repository/Neo-JSON-GemStone-Tests/package.st b/repository/Neo-JSON-GemStone-Tests/package.st new file mode 100644 index 0000000..6ba3bda --- /dev/null +++ b/repository/Neo-JSON-GemStone-Tests/package.st @@ -0,0 +1 @@ +Package { #name : 'Neo-JSON-GemStone-Tests' } From ad82cd9e6c248e3d82061275ec645c67585807c4 Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 26 Mar 2026 16:07:49 +0000 Subject: [PATCH 07/13] Pharo-like tonel for GemStone files --- .../BinaryFloat.extension.st | 12 +++---- .../Integer.extension.st | 14 ++++---- .../KeyValueDictionary.extension.st | 6 ++-- .../MultiByteString.extension.st | 4 +-- .../OrderedDictionary.extension.st | 4 +-- .../SmallInteger.extension.st | 10 +++--- repository/Neo-JSON-GemStone-Core/package.st | 2 +- .../Attachment.class.st | 8 ++--- .../BittrexResponse.class.st | 4 +-- .../Market.class.st | 4 +-- .../NeoJSONGemStoneExamples.class.st | 34 +++++++++---------- .../Neo-JSON-GemStone-Examples/package.st | 2 +- repository/Neo-JSON-GemStone-Tests/package.st | 2 +- 13 files changed, 53 insertions(+), 53 deletions(-) diff --git a/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st b/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st index 329c70e..02d57d6 100644 --- a/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st +++ b/repository/Neo-JSON-GemStone-Core/BinaryFloat.extension.st @@ -1,24 +1,24 @@ -Extension { #name : 'BinaryFloat' } +Extension { #name : #'BinaryFloat' } -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } BinaryFloat class >> negativeInfinity [ - ^ self fromString: 'MinusInfinity' + ^ self fromString: #'MinusInfinity' ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } BinaryFloat class >> zero [ ^ 0.0 ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } BinaryFloat >> isFinite [ ^(self - self) = 0.0 ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } BinaryFloat >> isZero [ ^ self = 0.0 diff --git a/repository/Neo-JSON-GemStone-Core/Integer.extension.st b/repository/Neo-JSON-GemStone-Core/Integer.extension.st index 446fd02..6598390 100644 --- a/repository/Neo-JSON-GemStone-Core/Integer.extension.st +++ b/repository/Neo-JSON-GemStone-Core/Integer.extension.st @@ -1,25 +1,25 @@ -Extension { #name : 'Integer' } +Extension { #name : #'Integer' } -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } Integer >> asCharacterDigit [ ^ Character digitValue: self ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } Integer >> digitAt: anExponent base: base [ ^ self // (base raisedToInteger: anExponent - 1) \\ base ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } Integer >> isPowerOfTwo [ "Return true if the receiver is an integral power of two." ^ self ~= 0 and: [ (self bitAnd: self-1) = 0 ] ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } Integer >> numberOfDigitsInBase: b [ "Return how many digits are necessary to print this number in base b. This does not count any place for minus sign, radix prefix or whatever. @@ -51,7 +51,7 @@ Integer >> numberOfDigitsInBase: b [ ifFalse: [total + 1] ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } Integer >> print: positiveNumberString on: aStream prefix: prefix length: minimum padded: zeroFlag [ "Return a String based on concatenation of positiveNumberString with prefix then padded by 0 is zeroFlag is set for a minimum length." @@ -67,7 +67,7 @@ Integer >> print: positiveNumberString on: aStream prefix: prefix length: minimu aStream nextPutAll: positiveNumberString ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } Integer >> printOn: aStream base: base length: minimum padded: zeroFlag [ "Return a String representation of this number in base b with a minimum length and padded by 0 if zeroFlag is set" diff --git a/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st b/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st index 7fe44c5..5dcefe5 100644 --- a/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st +++ b/repository/Neo-JSON-GemStone-Core/KeyValueDictionary.extension.st @@ -1,6 +1,6 @@ -Extension { #name : 'KeyValueDictionary' } +Extension { #name : #'KeyValueDictionary' } -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } KeyValueDictionary class >> newFromPairs: anArray [ "Answer an instance of me associating (anArray at:i) to (anArray at: i+i) for each odd i. anArray must have an even number of entries. @@ -15,7 +15,7 @@ KeyValueDictionary class >> newFromPairs: anArray [ ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } KeyValueDictionary >> neoJsonOn: neoJSONWriter [ neoJSONWriter writeMap: self ] diff --git a/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st b/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st index 7bab06e..1177b4f 100644 --- a/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st +++ b/repository/Neo-JSON-GemStone-Core/MultiByteString.extension.st @@ -1,6 +1,6 @@ -Extension { #name : 'MultiByteString' } +Extension { #name : #'MultiByteString' } -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } MultiByteString >> neoJsonOn: neoJSONWriter [ neoJSONWriter writeString: self ] diff --git a/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st b/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st index 86e9162..7b32635 100644 --- a/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st +++ b/repository/Neo-JSON-GemStone-Core/OrderedDictionary.extension.st @@ -1,6 +1,6 @@ -Extension { #name : 'OrderedDictionary' } +Extension { #name : #'OrderedDictionary' } -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } OrderedDictionary >> neoJsonOn: neoJSONWriter [ neoJSONWriter writeMap: self ] diff --git a/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st b/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st index fc5b7a4..0635458 100644 --- a/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st +++ b/repository/Neo-JSON-GemStone-Core/SmallInteger.extension.st @@ -1,6 +1,6 @@ -Extension { #name : 'SmallInteger' } +Extension { #name : #'SmallInteger' } -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } SmallInteger >> decimalDigitLength [ "Answer the number of digits printed out in base 10. Note that this only works for positive SmallIntegers up to 64-bits." @@ -40,7 +40,7 @@ SmallInteger >> decimalDigitLength [ ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } SmallInteger >> numberOfDigitsInBase: b [ "Return how many digits are necessary to print this number in base b. Mostly same as super but an optimized version for base 10 case" @@ -51,7 +51,7 @@ SmallInteger >> numberOfDigitsInBase: b [ ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } SmallInteger >> printOn: stream base: base length: minimumLength padded: padWithZeroes [ "Return a String representation of this number in base b with a minimum length and padded by 0 if zeroFlag is set" @@ -86,7 +86,7 @@ SmallInteger >> printOn: stream base: base length: minimumLength padded: padWith divisor := divisor // base ] ] -{ #category : '*neo-json-gemstone-core' } +{ #category : #'*neo-json-gemstone-core' } SmallInteger >> printOn: aStream base: b nDigits: n [ "Append a representation of this number in base b on aStream using nDigits. self must be positive." diff --git a/repository/Neo-JSON-GemStone-Core/package.st b/repository/Neo-JSON-GemStone-Core/package.st index df99358..7185b93 100644 --- a/repository/Neo-JSON-GemStone-Core/package.st +++ b/repository/Neo-JSON-GemStone-Core/package.st @@ -1 +1 @@ -Package { #name : 'Neo-JSON-GemStone-Core' } +Package { #name : #'Neo-JSON-GemStone-Core' } diff --git a/repository/Neo-JSON-GemStone-Examples/Attachment.class.st b/repository/Neo-JSON-GemStone-Examples/Attachment.class.st index de23502..f7a9429 100644 --- a/repository/Neo-JSON-GemStone-Examples/Attachment.class.st +++ b/repository/Neo-JSON-GemStone-Examples/Attachment.class.st @@ -1,6 +1,6 @@ Class { - #name : 'Attachment', - #superclass : 'Object', + #name : #'Attachment', + #superclass : #'Object', #instVars : [ 'url', 'fileName' @@ -8,12 +8,12 @@ Class { #category : 'Neo-JSON-GemStone-Examples' } -{ #category : 'accessing' } +{ #category : #'accessing' } Attachment >> fileName: anObject [ fileName := anObject ] -{ #category : 'accessing' } +{ #category : #'accessing' } Attachment >> url: anObject [ url := anObject ] diff --git a/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st b/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st index 133dff9..9490f07 100644 --- a/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st +++ b/repository/Neo-JSON-GemStone-Examples/BittrexResponse.class.st @@ -1,6 +1,6 @@ Class { - #name : 'BittrexResponse', - #superclass : 'Object', + #name : #'BittrexResponse', + #superclass : #'Object', #instVars : [ 'success', 'message', diff --git a/repository/Neo-JSON-GemStone-Examples/Market.class.st b/repository/Neo-JSON-GemStone-Examples/Market.class.st index 519ee2e..4300be5 100644 --- a/repository/Neo-JSON-GemStone-Examples/Market.class.st +++ b/repository/Neo-JSON-GemStone-Examples/Market.class.st @@ -1,6 +1,6 @@ Class { - #name : 'Market', - #superclass : 'Object', + #name : #'Market', + #superclass : #'Object', #instVars : [ 'MarketCurrency', 'BaseCurrency', diff --git a/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st b/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st index 488c404..abbdd8c 100644 --- a/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st +++ b/repository/Neo-JSON-GemStone-Examples/NeoJSONGemStoneExamples.class.st @@ -1,10 +1,10 @@ Class { - #name : 'NeoJSONGemStoneExamples', - #superclass : 'TestCase', + #name : #'NeoJSONGemStoneExamples', + #superclass : #'TestCase', #category : 'Neo-JSON-GemStone-Examples' } -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testAccessingTheNewYorkPublicLibrary [ | client reader data networkStream | @@ -19,7 +19,7 @@ NeoJSONGemStoneExamples >> testAccessingTheNewYorkPublicLibrary [ data ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testAttachmentsExample [ | collectionOne json | "Let's create a collection of two instances:" @@ -52,7 +52,7 @@ NeoJSONGemStoneExamples >> testAttachmentsExample [ nextAs: #CollectionOfAttachments ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testBittrexLitecoinAsDictionary [ ZnClient new url: 'https://bittrex.com/api/v1.1/public/getmarketSummary?market=BTC-LTC'; @@ -60,11 +60,11 @@ NeoJSONGemStoneExamples >> testBittrexLitecoinAsDictionary [ contentReader: [ :entity | |reader| reader := (NeoJSONReader on: entity readStream). reader next ]; - get. + get. ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testBittrexLitecoinAsDomainObjects [ ZnClient new url: 'https://bittrex.com/api/v1.1/public/getmarkets'; @@ -72,23 +72,23 @@ NeoJSONGemStoneExamples >> testBittrexLitecoinAsDomainObjects [ accept: ZnMimeType applicationJson; contentReader: [ :entity | |reader| reader := (NeoJSONReader on: entity readStream). - reader for: BittrexResponse do: [:m| + reader for: BittrexResponse do: [ :m | m mapInstVar: #success. m mapInstVar: #message. (m mapInstVar: #result) valueSchema: #ArrayOfMarkets]. reader for: #ArrayOfMarkets customDo: [ :mapping | mapping listOfElementSchema: Market ]. - reader mapInstVarsFor: Market. - reader nextAs: BittrexResponse ]; - get + reader mapInstVarsFor: Market. + reader nextAs: BittrexResponse ]; + get ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testDoomtownDBCards [ NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testFeed [ | json | json := ZnClient new @@ -102,13 +102,13 @@ NeoJSONGemStoneExamples >> testFeed [ json ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testGetWorldCapitals [ ((NeoJSONReader fromString: (ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) collect: [ :d | d at: #capital ] ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testGoogleMapsAPI [ ZnClient new @@ -117,7 +117,7 @@ NeoJSONGemStoneExamples >> testGoogleMapsAPI [ get ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testParsingUserAgentStrings [ ZnClient new http; @@ -128,7 +128,7 @@ NeoJSONGemStoneExamples >> testParsingUserAgentStrings [ get ] -{ #category : 'tests' } +{ #category : #'tests' } NeoJSONGemStoneExamples >> testStackOverflowInfo [ ZnClient new diff --git a/repository/Neo-JSON-GemStone-Examples/package.st b/repository/Neo-JSON-GemStone-Examples/package.st index 838edc2..8b6060b 100644 --- a/repository/Neo-JSON-GemStone-Examples/package.st +++ b/repository/Neo-JSON-GemStone-Examples/package.st @@ -1 +1 @@ -Package { #name : 'Neo-JSON-GemStone-Examples' } +Package { #name : #'Neo-JSON-GemStone-Examples' } diff --git a/repository/Neo-JSON-GemStone-Tests/package.st b/repository/Neo-JSON-GemStone-Tests/package.st index 6ba3bda..4f467b9 100644 --- a/repository/Neo-JSON-GemStone-Tests/package.st +++ b/repository/Neo-JSON-GemStone-Tests/package.st @@ -1 +1 @@ -Package { #name : 'Neo-JSON-GemStone-Tests' } +Package { #name : #'Neo-JSON-GemStone-Tests' } From b92654bd2de3c21c3f09f87c629c23d04166abac Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 27 Mar 2026 10:28:27 +0000 Subject: [PATCH 08/13] Adding missing dependency testFindPaths test fails when OrderedDictionary is not loaded --- .../BaselineOfNeoJSON.class/instance/baseline..st | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st index 82257eb..37a3a82 100644 --- a/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st +++ b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st @@ -20,7 +20,13 @@ baseline: spec group: 'Examples' with: #('Neo-JSON-Pharo-Examples') ]. spec for: #gemstone - do: [ spec + do: [ + spec + baseline: 'OrderedDictionary' + with: [ spec + loads: #('Core'); + repository: 'github://GsDevKit/OrderedDictionary:master/repository' ]. + spec package: 'Neo-JSON-GemStone-Core' with: [ spec requires: #('Neo-JSON-Core') ]; package: 'Neo-JSON-GemStone-Tests' with: [ spec requires: #('Neo-JSON-Tests') ]; package: 'Neo-JSON-GemStone-Examples' with: [ spec requires: #('Neo-JSON-Core') ]; From df1c435fb3475476f529756ac86df6c90f5f4d9e Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 27 Mar 2026 12:12:54 +0100 Subject: [PATCH 09/13] Removing Windows line-ends (CRLF) --- .smalltalkci/.unit-tests.ston | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.smalltalkci/.unit-tests.ston b/.smalltalkci/.unit-tests.ston index c5b9853..96b67de 100644 --- a/.smalltalkci/.unit-tests.ston +++ b/.smalltalkci/.unit-tests.ston @@ -1,16 +1,16 @@ -SmalltalkCISpec { - #loading : [ - SCIMetacelloLoadSpec { - #baseline : 'NeoJSON', - #directory : '../repository', - #load : [ 'build' ], - #platforms : [ #pharo ] - } - ], - #testing : { - #coverage : { - #packages : [ 'Neo-JSON*' ], - #format: #lcov - } - } -} +SmalltalkCISpec { + #loading : [ + SCIMetacelloLoadSpec { + #baseline : 'NeoJSON', + #directory : '../repository', + #load : [ 'build' ], + #platforms : [ #pharo ] + } + ], + #testing : { + #coverage : { + #packages : [ 'Neo-JSON*' ], + #format: #lcov + } + } +} From 378bf5e66c78f3dfe004c2d0274e16e74cb34ed1 Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 27 Mar 2026 12:32:28 +0100 Subject: [PATCH 10/13] Adding missing dependency for tonel baseline --- repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st b/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st index 0b56159..4153388 100644 --- a/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st +++ b/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st @@ -30,7 +30,13 @@ BaselineOfNeoJSON >> baseline: spec [ group: 'Examples' with: #('Neo-JSON-Pharo-Examples') ]. spec for: #gemstone - do: [ spec + do: [ + spec + baseline: 'OrderedDictionary' + with: [ spec + loads: #('Core'); + repository: 'github://GsDevKit/OrderedDictionary:master/repository' ]. + spec package: 'Neo-JSON-GemStone-Core' with: [ spec requires: #('Neo-JSON-Core') ]; package: 'Neo-JSON-GemStone-Tests' with: [ spec requires: #('Neo-JSON-Tests') ]; package: 'Neo-JSON-GemStone-Examples' with: [ spec requires: #('Neo-JSON-Core') ]; From 7c155d5ca40b42e581e1f2fb1ae522fe7b1fd42c Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 27 Mar 2026 12:35:56 +0100 Subject: [PATCH 11/13] Adding missing code to the test (during rebase) --- .../NeoJSONObjectTests.class/instance/testFindPaths.st | 1 + 1 file changed, 1 insertion(+) diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st index 465ffc8..87e317d 100644 --- a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st @@ -1,5 +1,6 @@ testing testFindPaths + | json paths | json := self class exampleJSONSchema. paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'$anchor' ] ]. From 96fdcc72c8383434e24bb94cbe4f1dc90b0cf5fa Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 27 Mar 2026 12:47:23 +0100 Subject: [PATCH 12/13] Changing tonel code to match filetree --- repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st b/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st index db8c0d0..c67d482 100644 --- a/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st +++ b/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st @@ -10,7 +10,7 @@ Class { } { #category : 'accessing' } -NeoJSONObjectTests >> exampleJSONSchema [ +NeoJSONObjectTests class >> exampleJSONSchema [ ^ NeoJSONObject fromString: '{ "$id" : "https://example.com/schemas/address", "type" : "object", @@ -122,7 +122,7 @@ NeoJSONObjectTests >> testCRUD [ { #category : 'testing' } NeoJSONObjectTests >> testFindPath [ | json path | - json := self exampleJSONSchema. + json := self class exampleJSONSchema. path := json findPath: [ :object | object isDictionary and: [ (object at: '$anchor') = 'street_address' ] ]. self deny: path isNil. @@ -146,7 +146,7 @@ NeoJSONObjectTests >> testFindPath [ { #category : 'testing' } NeoJSONObjectTests >> testFindPaths [ | json paths | - json := self exampleJSONSchema. + json := self class exampleJSONSchema. paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: '$anchor' ] ]. self deny: paths isEmpty. From 066a541514b4bc7ea8ad68b3244457e563fe8cf2 Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 27 Mar 2026 13:09:25 +0100 Subject: [PATCH 13/13] Updating STON SmalltalkCI specification for GemStone --- .smalltalk_gemstone.ston | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.smalltalk_gemstone.ston b/.smalltalk_gemstone.ston index 790a06b..a6ff3b6 100644 --- a/.smalltalk_gemstone.ston +++ b/.smalltalk_gemstone.ston @@ -1,10 +1,16 @@ SmalltalkCISpec { + #name : 'NeoJSON for GemStone', #loading : [ SCIMetacelloLoadSpec { #baseline : 'NeoJSON', #directory : 'filetree', #load : [ 'Core', 'Tests' ], - #platforms : [ #gemstone ] + #onConflict : #useIncoming, + #onWarningLog : true, + #platforms : [ #gemstone ], + #repository : 'https://github.com/GsDevKit/NeoJSON', + #useLatestMetacello : true } ] } +}