diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testDoWithoutFrom.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testDoWithoutFrom.st new file mode 100644 index 0000000..31ed5a5 --- /dev/null +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testDoWithoutFrom.st @@ -0,0 +1,26 @@ +tests +testDoWithoutFrom + | strm one two three four five ite1 entries1 ite2 entries2 | + strm := self newStreamNamed: 'testDoWithoutFrom'. + strm trimTo: 0. + self assert: strm length equals: 0. + one := 'one' -> '1'. + two := 'two' -> '2'. + three := 'three' -> '3'. + four := 'four' -> '4'. + five := 'five' -> '5'. + strm << one << two << three << four << five. + ite1 := strm iterator. + entries1 := OrderedCollection new. + ite1 do: [ :each | entries1 add: each ]. + self assert: entries1 size equals: 5. + self assert: entries1 first content equals: one. + self assert: entries1 second content equals: two. + self assert: entries1 last content equals: five. + ite2 := strm iterator. + entries2 := ite2 collect: [ :each | each ]. + self assert: entries2 size equals: 5. + self assert: entries2 first content equals: one. + self assert: entries2 last content equals: five. + strm trimTo: 0. + self assert: strm length equals: 0. \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testReverseDoWithoutFrom.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testReverseDoWithoutFrom.st new file mode 100644 index 0000000..526d05e --- /dev/null +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testReverseDoWithoutFrom.st @@ -0,0 +1,26 @@ +tests +testReverseDoWithoutFrom + | strm one two three four five ite1 entries1 ite2 entries2 | + strm := self newStreamNamed: 'testReverseDoWithoutFrom'. + strm trimTo: 0. + self assert: strm length equals: 0. + one := 'one' -> '1'. + two := 'two' -> '2'. + three := 'three' -> '3'. + four := 'four' -> '4'. + five := 'five' -> '5'. + strm << one << two << three << four << five. + ite1 := strm reverseIterator. + entries1 := OrderedCollection new. + ite1 do: [ :each | entries1 add: each ]. + self assert: entries1 size equals: 5. + self assert: entries1 first content equals: five. + self assert: entries1 second content equals: four. + self assert: entries1 last content equals: one. + ite2 := strm reverseIterator. + entries2 := ite2 collect: [ :each | each ]. + self assert: entries2 size equals: 5. + self assert: entries2 first content equals: five. + self assert: entries2 last content equals: one. + strm trimTo: 0. + self assert: strm length equals: 0. \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/iterator.st b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/iterator.st new file mode 100644 index 0000000..c7a7b8e --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/iterator.st @@ -0,0 +1,3 @@ +iterating +iterator + ^ self iteratorClass on: self \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/reverseIterator.st b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/reverseIterator.st new file mode 100644 index 0000000..4e16b54 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/reverseIterator.st @@ -0,0 +1,3 @@ +iterating +reverseIterator + ^ self iterator reversed \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.from..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.from..st new file mode 100644 index 0000000..ee33c67 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.from..st @@ -0,0 +1,5 @@ +instance creation +on: aRsStream from: fromId + ^ (self on: aRsStream) + initFromId: fromId; + yourself \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.nextFrom..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.nextFrom..st index 3633bfd..1dd3ad1 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.nextFrom..st +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.nextFrom..st @@ -1,3 +1,6 @@ instance creation on: aRsStream nextFrom: fromId - ^ (self on: aRsStream) initFromId: fromId \ No newline at end of file + ^ (self on: aRsStream) + initFromId: fromId; + initCurrentId: fromId; + yourself \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/basicCurrentId.st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/basicCurrentId.st new file mode 100644 index 0000000..2782c3e --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/basicCurrentId.st @@ -0,0 +1,3 @@ +accessing +basicCurrentId + ^ currentId \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/by.do.whileFalse..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/by.do.whileFalse..st index 44cbc12..fd8f33c 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/by.do.whileFalse..st +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/by.do.whileFalse..st @@ -1,7 +1,7 @@ actions by: step do: aBlock whileFalse: endConditionBlock | entries | - entries := self contentsNextFrom: self currentId count: step. + entries := self entriesFrom: self currentId count: step. entries do: [ :each | aBlock value: each. self currentId: each id ]. diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/contentsFrom.count..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/contentsFrom.count..st new file mode 100644 index 0000000..6a9bf19 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/contentsFrom.count..st @@ -0,0 +1,3 @@ +private +contentsFrom: entryId count: step + ^ self stream contentsFrom: entryId count: step \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/currentId.st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/currentId.st index acb5c67..e5f573c 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/currentId.st +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/currentId.st @@ -1,4 +1,4 @@ accessing currentId - - ^ currentId \ No newline at end of file + currentId ifNil: [ ^ self fallbackId ]. + ^ currentId \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/entriesFrom.count..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/entriesFrom.count..st new file mode 100644 index 0000000..efb0bbc --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/entriesFrom.count..st @@ -0,0 +1,4 @@ +private +entriesFrom: entryId count: step + self isInclusive ifTrue: [ ^ self contentsFrom: entryId count: step ]. + ^ self contentsNextFrom: entryId count: step \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/fallbackId.st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/fallbackId.st new file mode 100644 index 0000000..7148051 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/fallbackId.st @@ -0,0 +1,3 @@ +private +fallbackId + ^ self stream first id \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initCurrentId..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initCurrentId..st new file mode 100644 index 0000000..0680d3e --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initCurrentId..st @@ -0,0 +1,3 @@ +initialization +initCurrentId: fromIdLikeThing + currentId := fromIdLikeThing ifNotNil: [ fromIdLikeThing asStreamMessageId ]. \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initFromId..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initFromId..st index 8e130c5..31fc1e8 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initFromId..st +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initFromId..st @@ -1,6 +1,3 @@ initialization initFromId: fromIdLikeThing - fromId := fromIdLikeThing - ifNil: [ RsStreamMessageId zero ] - ifNotNil: [ fromIdLikeThing asStreamMessageId ]. - currentId := fromId \ No newline at end of file + fromId := fromIdLikeThing ifNotNil: [ fromIdLikeThing asStreamMessageId ]. \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive..st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive..st new file mode 100644 index 0000000..4573406 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive..st @@ -0,0 +1,3 @@ +accessing +isInclusive: aBoolean + isInclusive := aBoolean \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive.st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive.st new file mode 100644 index 0000000..e83d808 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive.st @@ -0,0 +1,4 @@ +testing +isInclusive + isInclusive ifNil: [ ^ currentId isNil ]. + ^ isInclusive \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/reversed.st b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/reversed.st index d0b4184..0773117 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/reversed.st +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/reversed.st @@ -1,3 +1,3 @@ converting reversed - ^ RsStreamReverseIterator on: self stream nextFrom: self currentId \ No newline at end of file + ^ RsStreamReverseIterator on: self stream nextFrom: self basicCurrentId \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/properties.json b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/properties.json index 22aec62..9114212 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/properties.json +++ b/repository/RediStick-Stream-Objects.package/RsStreamIterator.class/properties.json @@ -9,7 +9,8 @@ "name", "stream", "fromId", - "currentId" + "currentId", + "isInclusive" ], "name" : "RsStreamIterator", "type" : "normal" diff --git a/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/contentsFrom.count..st b/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/contentsFrom.count..st new file mode 100644 index 0000000..e32a2dc --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/contentsFrom.count..st @@ -0,0 +1,3 @@ +private +contentsFrom: entryId count: step + ^ self stream contentsReversedFrom: entryId count: step \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/fallbackId.st b/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/fallbackId.st new file mode 100644 index 0000000..a74ab44 --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/fallbackId.st @@ -0,0 +1,3 @@ +private +fallbackId + ^ self stream last id \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/reversed.st b/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/reversed.st index 903e71d..873d458 100644 --- a/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/reversed.st +++ b/repository/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/reversed.st @@ -1,3 +1,3 @@ converting reversed - ^ RsStreamIterator on: self stream nextFrom: self currentId \ No newline at end of file + ^ RsStreamIterator on: self stream nextFrom: self basicCurrentId \ No newline at end of file