Attached is the changeset as discussed in my last email.

Just to be clear, this is just for reference, I'm happy to redo the PR
if it will save you and/or Pavel some time.

Cheers,
Alistair


On 30 June 2017 at 16:42, Alistair Grant <akgrant0...@gmail.com> wrote:
> Hi Stef,
>
> Good pickup.
>
> I also can't load
> SLICE-Issue-20165-Support-segment-path-printing-AlistairGrant.1.
> Somehow it is dependent on FileSystem-Core-AlistairGrant.223, and I
> have no idea what that is (I don't remember ever creating it, and I
> don't have a copy on my machine anywhere, or in any of my backups).
>
> Fortunately I do have a changeset of the patch.  I'll send it through
> as an attachment after I've sent this email in case it causes the
> response to be blocked.
>
> Do you or Pavel have a preference on how to get the PR fixed?  I'm
> happy to generate a new PR if you or Pavel can close the existing one
> (#126).
>
> Thanks,
> Alistair
>
>
> On 30 June 2017 at 16:09, Stephane Ducasse <stepharo.s...@gmail.com> wrote:
>> Hi alistair
>>
>> I'm starting to review code that is in the PR pipeline.
>> https://github.com/pharo-project/pharo/pull/126
>>
>> I noticed that you wrote in the slice
>>
>> Changes since last slice:
>>
>> - Change Path>>fullName to just print the path
>> - Fix absolute path strings
>> - Bug fix Path class>>from:delimiter:
>> - Add unit tests
>>
>> But I only see in the PR three methods.
>> Can you check because I have the impression that we are losing code 
>> somewhere?
>>
>> BTW I could not see the contents of the AlistairGrant.1 package
>> I tried on several images 70 and 60 latest
>>
>> Stef
>>
'From Pharo6.0 of 13 May 2016 [Latest update: #60501] on 21 June 2017 at 9:53:34.98814 am'!

!Path methodsFor: 'printing' stamp: 'AlistairGrant 6/21/2017 09:19'!
pathString
	"Return a string containing the path elements of the receiver, without the 'Path *' part"

	"((FileSystem workingDirectory / 'book-result' / 'W01-Welcome')
		relativeToReference: FileSystem workingDirectory) pathString
	>>> 'book-result/W01-Welcome'"

	^String streamContents: [ :stream | 
		self printPathOn: stream delimiter: self delimiter ]! !

!Path methodsFor: 'printing' stamp: 'AlistairGrant 6/21/2017 09:21'!
printPathOn: aStream delimiter: aCharacter
	"Print the receiver's path on aStream (without 'Path' prepended)"
	"String streamContents: [ :str| 
		((FileSystem workingDirectory / 'book-result' / 'W01-Welcome')
			relativeToReference: FileSystem workingDirectory) printPathOn: str delimiter: $|]
	>>> 'book-result|W01-Welcome'"

	(1 to: self size)
		do: [:index | aStream nextPutAll: (self at: index)]
		separatedBy: [aStream nextPut: aCharacter]! !

!Path methodsFor: 'printing' stamp: 'AlistairGrant 6/21/2017 09:19'!
printPathOn: aStream
	"Print the receiver's path on aStream (without 'Path' prepended) using the default delimiter"
	"String streamContents: [ :str| 
		((FileSystem workingDirectory / 'book-result' / 'W01-Welcome') 
			relativeToReference: FileSystem workingDirectory) printPathOn: str]
	>>> 'book-result/W01-Welcome'"

	self printPathOn: aStream delimiter: self delimiter.
! !

!Path methodsFor: 'accessing' stamp: 'AlistairGrant 6/19/2017 08:45'!
fullName
	"Return the fullName of the receiver."
	
	^ self pathString! !


!AbsolutePath methodsFor: 'printing' stamp: 'AlistairGrant 6/19/2017 09:02'!
printPathOn: aStream delimiter: aCharacter
	"Print the path elements of the receiver, without the 'Path *' part"

	aStream nextPut: aCharacter.
	super printPathOn: aStream delimiter: aCharacter
! !


!Path class methodsFor: 'instance creation' stamp: 'AlistairGrant 6/21/2017 09:44'!
from: aString delimiter: aDelimiterCharacter 
	"Answer a path composed of several elements delimited by aCharacter"
	| pathClass |
	aString isEmpty
		ifTrue: [ ^ self root ].
	
	pathClass :=  ((self isAbsolutePath: aString delimiter: aDelimiterCharacter) or: 
							[self isAbsoluteWindowsPath: aString]) 
		ifTrue: [ AbsolutePath ]
		ifFalse:[ RelativePath ].
	
	^ pathClass withAll: ((aDelimiterCharacter split: aString) select: 
		[ :segment | segment notEmpty ])! !

!Path class methodsFor: 'private' stamp: 'AlistairGrant 6/21/2017 09:44'!
isAbsolutePath: aString delimiter: aCharacter
	"Answer a boolean indicating whether the supplied path is considered absolute"

	^aString first = aCharacter! !


!PathTest methodsFor: 'tests' stamp: 'AlistairGrant 6/21/2017 09:41'!
testPrintPathOn

	| pathString pathSrc path |

	"Test a Relative path"
	pathSrc := 'one/two/three'.
	path := Path from: pathSrc.
	self assert: path isRelative.
	pathString := String streamContents: [ :stream | path printPathOn: stream ].
	self assert: pathSrc equals: pathString.

	"Test an Absolute path"
	pathSrc := '/one/two/three'.
	path := Path from: pathSrc.
	self assert: path isAbsolute.
	pathString := String streamContents: [ :stream | path printPathOn: stream ].
	self assert: pathSrc equals: pathString! !

!PathTest methodsFor: 'tests' stamp: 'AlistairGrant 6/21/2017 09:42'!
testPrintPathOnDelimiter

	| pathString pathSrc path |

	"Test a Relative path"
	"Use an unusal delimiter to check that the default isn't hardcoded anywhere"
	pathSrc := 'one|two|three'.
	path := Path from: pathSrc delimiter: $|.
	self assert: path isRelative.
	pathString := String streamContents: [ :stream | path printPathOn: stream delimiter: $| ].
	self assert: pathSrc equals: pathString.

	"Test an Absolute path"
	"Use an unusal delimiter to check that the default isn't hardcoded anywhere"
	pathSrc := '|one|two|three'.
	path := Path from: pathSrc delimiter: $|.
	self assert: path isAbsolute.
	pathString := String streamContents: [ :stream | path printPathOn: stream delimiter: $| ].
	self assert: pathSrc equals: pathString! !

!PathTest methodsFor: 'tests' stamp: 'AlistairGrant 6/21/2017 09:40'!
testPathString

	| path |

	path := (FileSystem workingDirectory / 'book-result' / 'W01-Welcome')
				relativeToReference: FileSystem workingDirectory.
	self assert: path isRelative.
	self assert: path pathString equals: 'book-result/W01-Welcome'
! !

!PathTest methodsFor: 'tests' stamp: 'AlistairGrant 6/21/2017 09:22'!
testFullName

	| path |

	path := (FileSystem workingDirectory / 'book-result' / 'W01-Welcome')
				relativeToReference: FileSystem workingDirectory.
	self assert: path fullName equals: 'book-result/W01-Welcome'
! !

Reply via email to