STON cannot be used to write partial, manual output because it needs to see the full object graph (like FUEL does).
If I would want to use STON for prettier looking config files, I would make an object just for that external representation, converting it where necessary to better internal objects (like from String to FileReference). > On 5 Jun 2017, at 08:58, Stephane Ducasse <stepharo.s...@gmail.com> wrote: > > Sven I know what Ston is :) > > Now Pillar dev used Ston as input and it works. Then with some hooks they let > the user convert the strings > into specific objects and this is ok. > Now I want to add export in Ston and for configurations I need to control for > the application and not as a ston object the value saved. > For example a file reference should not be just a file reference in Ston but > a string relative the the baseDirectory of the configuration. > > So I thought that I can build a hook and control the call to Ston (convert > the object before to the correct values) and export. > It should be working now doing this I found myself redoing the output of > Ston. > So I will do it. Then I thought that may be I could reuse this logic. > > Stef > > > > On Sun, Jun 4, 2017 at 11:49 PM, Sven Van Caekenberghe <s...@stfx.eu> wrote: > Stef, > > STON is like FUEL, it can write any object to a stream and read it back. > Although you can customise how this is done, only one way of doing so is > supported (i.e. you cannot change the format for each application). > > People have used STON for various applications now, including for > configuration stuff (because it is a textual format that is easy to read). > > I would suggest you just try to see what your config looks like once you have > the objects in Pharo. > > STON toStringPretty: myConfig. > > Then we can see how to tune the representation. > > Sven > > > On 4 Jun 2017, at 22:58, Stephane Ducasse <stepharo.s...@gmail.com> wrote: > > > > Hi sven > > > > I'm working on a new configuration frameworks similar to the one use > > pillar.conf. > > > > So basically I have > > > > ston := '{ > > "newLine":#unix, > > "separateOutputFiles":true > > }'. > > and I want to recreate it. > > > > So I did > > > > Object >> toConfigurationString > > > > ^ STON toString: self > > > > SimpleConfiguration >> exportStream > > > > ^ String streamContents: [ :str | > > str << '{' . > > self propertiesKeysAndValuesDo: [ :key :value| > > str << key toConfigurationString. > > str << ':'. > > str << value toConfigurationString. > > str << ','. > > str lf. > > ]. > > str << '}'. > > str contents > > ] > > > > The idea is that for special configuration values people should be able to > > define > > how to go from the object to configuration. > > For example for some FileReference I want to have just the path up to the > > baseDirectory. > > > > Now I wonder if I could not better reuse ston. > > I saw the stonOn: > > but I did not look further because I was wondering how the writer where > > passed. > > > > Any feedback is welcome. > > > > Stef (now bed time). > > > > >