-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from mumez/feature/stream-objectify
Added RsStream>>#iterator and #reverseIteraror for supporting easiler iteration
- Loading branch information
Showing
21 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...tream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testDoWithoutFrom.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
26 changes: 26 additions & 0 deletions
26
...bjects-Tests.package/RsRedisStreamIteratorTest.class/instance/testReverseDoWithoutFrom.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
3 changes: 3 additions & 0 deletions
3
repository/RediStick-Stream-Objects.package/RsStream.class/instance/iterator.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
iterating | ||
iterator | ||
^ self iteratorClass on: self |
3 changes: 3 additions & 0 deletions
3
repository/RediStick-Stream-Objects.package/RsStream.class/instance/reverseIterator.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
iterating | ||
reverseIterator | ||
^ self iterator reversed |
5 changes: 5 additions & 0 deletions
5
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.from..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
instance creation | ||
on: aRsStream from: fromId | ||
^ (self on: aRsStream) | ||
initFromId: fromId; | ||
yourself |
5 changes: 4 additions & 1 deletion
5
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/class/on.nextFrom..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
instance creation | ||
on: aRsStream nextFrom: fromId | ||
^ (self on: aRsStream) initFromId: fromId | ||
^ (self on: aRsStream) | ||
initFromId: fromId; | ||
initCurrentId: fromId; | ||
yourself |
3 changes: 3 additions & 0 deletions
3
...sitory/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/basicCurrentId.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
accessing | ||
basicCurrentId | ||
^ currentId |
2 changes: 1 addition & 1 deletion
2
...ory/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/by.do.whileFalse..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...y/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/contentsFrom.count..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
private | ||
contentsFrom: entryId count: step | ||
^ self stream contentsFrom: entryId count: step |
4 changes: 2 additions & 2 deletions
4
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/currentId.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
accessing | ||
currentId | ||
|
||
^ currentId | ||
currentId ifNil: [ ^ self fallbackId ]. | ||
^ currentId |
4 changes: 4 additions & 0 deletions
4
...ry/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/entriesFrom.count..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
private | ||
entriesFrom: entryId count: step | ||
self isInclusive ifTrue: [ ^ self contentsFrom: entryId count: step ]. | ||
^ self contentsNextFrom: entryId count: step |
3 changes: 3 additions & 0 deletions
3
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/fallbackId.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
private | ||
fallbackId | ||
^ self stream first id |
3 changes: 3 additions & 0 deletions
3
...sitory/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initCurrentId..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
initialization | ||
initCurrentId: fromIdLikeThing | ||
currentId := fromIdLikeThing ifNotNil: [ fromIdLikeThing asStreamMessageId ]. |
5 changes: 1 addition & 4 deletions
5
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/initFromId..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
initialization | ||
initFromId: fromIdLikeThing | ||
fromId := fromIdLikeThing | ||
ifNil: [ RsStreamMessageId zero ] | ||
ifNotNil: [ fromIdLikeThing asStreamMessageId ]. | ||
currentId := fromId | ||
fromId := fromIdLikeThing ifNotNil: [ fromIdLikeThing asStreamMessageId ]. |
3 changes: 3 additions & 0 deletions
3
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
accessing | ||
isInclusive: aBoolean | ||
isInclusive := aBoolean |
4 changes: 4 additions & 0 deletions
4
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/isInclusive.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
testing | ||
isInclusive | ||
isInclusive ifNil: [ ^ currentId isNil ]. | ||
^ isInclusive |
2 changes: 1 addition & 1 deletion
2
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/reversed.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
converting | ||
reversed | ||
^ RsStreamReverseIterator on: self stream nextFrom: self currentId | ||
^ RsStreamReverseIterator on: self stream nextFrom: self basicCurrentId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...tick-Stream-Objects.package/RsStreamReverseIterator.class/instance/contentsFrom.count..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
private | ||
contentsFrom: entryId count: step | ||
^ self stream contentsReversedFrom: entryId count: step |
3 changes: 3 additions & 0 deletions
3
...ory/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/fallbackId.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
private | ||
fallbackId | ||
^ self stream last id |
2 changes: 1 addition & 1 deletion
2
...itory/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/reversed.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
converting | ||
reversed | ||
^ RsStreamIterator on: self stream nextFrom: self currentId | ||
^ RsStreamIterator on: self stream nextFrom: self basicCurrentId |