filetree
filetree copied to clipboard
Convert Between Namespaces and Class Name Prefixes
When code is saved from VW, namespaces are specified as metadata. There should be a way to specify a mapping between a namespace and a class name prefix, to be used when loaded into platforms that do not support namespaces (e.g. Pharo).
This is a snippet to save Xtreams in Pharo. With some modifications to FileTree (to be pushed), it strips prefixes from class names when saving:
repo := MCFileTreeRepository new directory: (FileDirectory on: '/path/to/filetree/repo/packages/').
packages := MCWorkingCopy allInstances select: [ :e | e packageName beginsWith: 'Xtreams' ] thenCollect: [ :e | e packageName ].
repo map: 'Xtreams' namespaceToPrefix: 'XT'.
gofer := Gofer it
repository: repo.
packages do: [ :e | gofer package: e ].
gofer commit: 'initial port from squeaksource to filetree'.
"repo writeRepositoryProperties" "do this manually if the .filetree file gets deleted, because this is currently only done when the repo object is created"```
This is how you load the packages back into Pharo:
Metacello new
configuration: 'FFI';
load.
repo := MCFileTreeRepository new directory: (FileDirectory on: '//path/to/filetree/repo/packages/').
Gofer new
repository: repo;
package: 'Xtreams-Support';
package: 'Xtreams-Core';
package: 'Xtreams-Terminals';
package: 'Xtreams-Transforms';
package: 'Xtreams-Substreams';
package: 'Xtreams-Parsing';
package: 'Xtreams-CoreTests';
package: 'Xtreams-TerminalsTests';
package: 'Xtreams-TransformsTests';
package: 'Xtreams-SubstreamsTests';
package: 'Xtreams-ParsingTests';
package: 'Xtreams-Xtras';
package: 'Xtreams-XtrasTests';
load.
The proof-of-concept adaptations to filetree are in this gist until I make up something to push...
Looking good! Looking forward to a pull request when you're ready
I look forward to including this! Greate work
----- Original Message ----- | From: "Sean DeNigris" [email protected] | To: "dalehenrich/filetree" [email protected] | Sent: Saturday, September 1, 2012 11:36:42 AM | Subject: Re: [filetree] Convert Between Namespaces and Class Name Prefixes (#59) | | | | The proof-of-concept adaptations to filetree are at | https://gist.github.com/3582649 until I make up something to push... | | — | Reply to this email directly or view it on GitHub .
I'm thinking about transforming the class names in the source. Martin said it wouldn't be that important, but I think it will make keeping the platform branches in sync that much harder. I will do a second pass in the next week or so...
I tend to agree with Martin that it isn't that important ... I'd want to live without the automatic conversion for a bit to see if indeed it is a big deal ...
With that said, I would think that it should at least be a separate option for FileTree so it can be turned on/off independently of the class name mapping...