STON Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

STON Question

Stephane Ducasse-3
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).

Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Sven Van Caekenberghe-2
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 <[hidden email]> 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).
>


Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Stephane Ducasse-3
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 <[hidden email]> 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 <[hidden email]> 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).
>



Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Offray Vladimir Luna Cárdenas-2

Hi,

Maybe what I'm doing in Grafoscopio could help.

I have a %metadata node which contains all configuration options for the production of the document (as shown in the image below). Exporting a document consist in looking for these nodes while traversing the notebook tree and applying that options in the proper place. You can see the source code of the current notebook STON file at [1], the exported markdown file at [2] and the exported PDF at [3]. As you can see I have pretty good control of the configuration of the document using this option (and a single place to manage all, without endless small files and folders for a document, but event that exporting options as split folders and docs, could be added also).

[1] http://mutabit.com/repos.fossil/grafoscopio/artifact/fb25442038a0d4a1
[2] http://mutabit.com/repos.fossil/grafoscopio/artifact?name=59245142cf93590b&txt=1
[3] http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/En/Books/Manual/manual.pdf



Cheers,

Offray

On 05/06/17 01:58, Stephane Ducasse 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 <[hidden email]> 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 <[hidden email]> 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).
>





0x7095B7A1.asc (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Stephane Ducasse-3
Hi offray

Thanks but pillar ha a conf since several years and it is working well. Now I'm revisiting the implementation of cocoon 
because I want to have it simpler independent of magritte and better tested.

Now I just want to add a new functionality to output a configuration file from the 
objects and in Pillar the configuration objects hold more complex ***objects***. 
So just taking the object and turning it in ston does not work. 

Stef

On Mon, Jun 5, 2017 at 6:23 PM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:

Hi,

Maybe what I'm doing in Grafoscopio could help.

I have a %metadata node which contains all configuration options for the production of the document (as shown in the image below). Exporting a document consist in looking for these nodes while traversing the notebook tree and applying that options in the proper place. You can see the source code of the current notebook STON file at [1], the exported markdown file at [2] and the exported PDF at [3]. As you can see I have pretty good control of the configuration of the document using this option (and a single place to manage all, without endless small files and folders for a document, but event that exporting options as split folders and docs, could be added also).

[1] http://mutabit.com/repos.fossil/grafoscopio/artifact/fb25442038a0d4a1
[2] http://mutabit.com/repos.fossil/grafoscopio/artifact?name=59245142cf93590b&txt=1
[3] http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/En/Books/Manual/manual.pdf



Cheers,

Offray


On 05/06/17 01:58, Stephane Ducasse 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 <[hidden email]> 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 <[hidden email]> 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).
>





Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Offray Vladimir Luna Cárdenas-2

Ok Stef. Happy that we're exploring different paths ;-).

Cheers,

Offray


On 05/06/17 13:56, Stephane Ducasse wrote:
Hi offray

Thanks but pillar ha a conf since several years and it is working well. Now I'm revisiting the implementation of cocoon 
because I want to have it simpler independent of magritte and better tested.

Now I just want to add a new functionality to output a configuration file from the 
objects and in Pillar the configuration objects hold more complex ***objects***. 
So just taking the object and turning it in ston does not work. 

Stef

On Mon, Jun 5, 2017 at 6:23 PM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:

Hi,

Maybe what I'm doing in Grafoscopio could help.

I have a %metadata node which contains all configuration options for the production of the document (as shown in the image below). Exporting a document consist in looking for these nodes while traversing the notebook tree and applying that options in the proper place. You can see the source code of the current notebook STON file at [1], the exported markdown file at [2] and the exported PDF at [3]. As you can see I have pretty good control of the configuration of the document using this option (and a single place to manage all, without endless small files and folders for a document, but event that exporting options as split folders and docs, could be added also).

[1] http://mutabit.com/repos.fossil/grafoscopio/artifact/fb25442038a0d4a1
[2] http://mutabit.com/repos.fossil/grafoscopio/artifact?name=59245142cf93590b&txt=1
[3] http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/En/Books/Manual/manual.pdf



Cheers,

Offray


On 05/06/17 01:58, Stephane Ducasse 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 <[hidden email]> 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 <[hidden email]> 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).
>






Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Sven Van Caekenberghe-2
In reply to this post by Stephane Ducasse-3
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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).
> >
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Stephane Ducasse-3
Thanks Sven.
I'm checking the STONWriter path with some tricks.

On Wed, Jun 14, 2017 at 11:06 AM, Sven Van Caekenberghe <[hidden email]> wrote:

> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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).
>> >
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re : Re: STON Question

demarey
In reply to this post by Sven Van Caekenberghe-2
+1
It is exactly what i've done with Cargo. Define your own specific object for serialization / deserialization. It is the simplest way to have a human readable conf file (e.g. urls, pathes default serialization is not what you expect)

Christophe
----- Sven Van Caekenberghe <[hidden email]> a écrit :

> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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).
> > >
> >
> >
> >
>
>


Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Sven Van Caekenberghe-2

> On 14 Jun 2017, at 15:01, Christophe Demarey <[hidden email]> wrote:
>
> +1
> It is exactly what i've done with Cargo. Define your own specific object for serialization / deserialization. It is the simplest way to have a human readable conf file (e.g. urls, pathes default serialization is not what you expect)

Maybe Steph can have a look at your approach.

> Christophe
> ----- Sven Van Caekenberghe <[hidden email]> a écrit :
>> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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).
>>>>
>>>
>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Guillermo Polito
that's what is called a DTO

Le 14 juin 2017 15:27, "Sven Van Caekenberghe" <[hidden email]> a écrit :

> On 14 Jun 2017, at 15:01, Christophe Demarey <[hidden email]> wrote:
>
> +1
> It is exactly what i've done with Cargo. Define your own specific object for serialization / deserialization. It is the simplest way to have a human readable conf file (e.g. urls, pathes default serialization is not what you expect)

Maybe Steph can have a look at your approach.

> Christophe
> ----- Sven Van Caekenberghe <[hidden email]> a écrit :
>> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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).
>>>>
>>>
>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: STON Question

Guillermo Polito
In reply to this post by Sven Van Caekenberghe-2
That's what we call a DTO

On Wed, Jun 14, 2017 at 3:01 PM, Christophe Demarey <[hidden email]> wrote:
+1
It is exactly what i've done with Cargo. Define your own specific object for serialization / deserialization. It is the simplest way to have a human readable conf file (e.g. urls, pathes default serialization is not what you expect)

Christophe
----- Sven Van Caekenberghe <[hidden email]> a écrit :
> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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).
> > >
> >
> >
> >
>
>





--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13