Forum: Ruby Moving away from yaml to (where to.)

4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2013-09-03 14:15
Hi,

Are there alternatives to yaml files?

Specifically configuration formats that do not coerce the user into a
specific encoding format.

I need mostly:

key: value pairs

although the ability to load arrays directly into a .rb file would be
cool too.

Reason: I can no longer use yaml files in ruby 2.0 if they are not in
UTF. As I do not use UTF and never will, yet syck has been removed, I
need another way to load my configuration settings (I use several
hundred yaml files). Without that I would be forced to not use my
configuration settings (which is currently in yaml) so upgrading my ruby
version gives me only drawbacks and extra work and no benefit.

My current ruby in use is ruby 1.9.3p448 (2013-06-27 revision 41675)
[i686-linux]
C993c6aaffc6cf7b477a5075099e1d36?d=identicon&s=25 Peter Hickman (Guest)
on 2013-09-03 14:33
(Received via mailing list)
Any reason why JSON is not suitable?
C608970872a3048fd3077c001f44929b?d=identicon&s=25 Lars Haugseth (Guest)
on 2013-09-03 14:54
(Received via mailing list)
On 09/03/2013 02:32 PM, Peter Hickman wrote:
> Any reason why JSON is not suitable?

The JSON specification at http://tools.ietf.org/html/rfc4627 states:

  "JSON text SHALL be encoded in Unicode. The default encoding is
UTF-8."

The original poster stated:

  "As I do not use UTF and never will[…]"

I guess that rules out JSON, and a lot of other things besides.
Good luck, though.
C993c6aaffc6cf7b477a5075099e1d36?d=identicon&s=25 Peter Hickman (Guest)
on 2013-09-03 15:32
(Received via mailing list)
If the configuration settings are data structures in the Ruby program
then
you can convert them to and from JSON. The fact that they are encoded
with
UTF-8 is transparent and pretty irrelevant unless the data is in some
esoteric format (but then how would Ruby handle this anyway?).

The desire not to use UTF-8 seems to be a religious issue given the the
OP
has not given any reason or described a problem that they are having
with
YAML. If they are prepared to convert their current settings files from
YAML to some other, as yet unspecified, format they could just as easily
just convert the data to UTF-8 and be done with it.
75eb154a2d05884a8a6a8e54b6eb3deb?d=identicon&s=25 Wayne Brissette (Guest)
on 2013-09-03 15:34
(Received via mailing list)
On Sep 3, 2013, at 8:31 AM, Peter Hickman wrote:

> The desire not to use UTF-8 seems to be a religious issue given the the OP has
not given any reason or described a problem that they are having with YAML

I'm wondering about that as well. UTF-8 imposes no penalty if you want
to restrict yourself to the basic ASCII character set. Seems like an odd
avoidance given the lack of any real penalty.

Wayne
D1f1c20467562fc1d8c8aa0d328def62?d=identicon&s=25 Florian Gilcher (skade)
on 2013-09-03 16:30
(Received via mailing list)
Am 03.09.2013 um 15:34 schrieb Wayne Brissette <wbrisett@att.net>:

>
> On Sep 3, 2013, at 8:31 AM, Peter Hickman wrote:
>
>> The desire not to use UTF-8 seems to be a religious issue given the the OP has
not given any reason or described a problem that they are having with YAML
>
> I'm wondering about that as well. UTF-8 imposes no penalty if you want to
restrict yourself to the basic ASCII character set. Seems like an odd avoidance
given the lack of any real penalty.
>
> Wayne

Also, YAML is a unicode based format as well and handling other things
is a SYCK implementation detail. So, the true quesition is: "moving away
from SYCK, where to?"
15000f55138ae94b0f362ed7c625461a?d=identicon&s=25 unknown (Guest)
on 2013-09-03 17:59
(Received via mailing list)
Am 03.09.2013 16:29, schrieb Florian Gilcher:
> So, the true quesition is: "moving away from SYCK, where to?"

What's wrong with Psych (the default)?

Regards,
Marcus
15000f55138ae94b0f362ed7c625461a?d=identicon&s=25 unknown (Guest)
on 2013-09-03 18:02
(Received via mailing list)
Am 03.09.2013 14:15, schrieb Marc Heiler:
> Hi,
>
> Are there alternatives to yaml files?
>
> I need mostly:
>
> key: value pairs
>
> although the ability to load arrays directly into a .rb file would be
> cool too.

Best option: YAML (surprise)

> Reason: I can no longer use yaml files in ruby 2.0 if they are not in UTF.

???

Yes you can.

ASCII works out of the box (it is valid UTF-8),
other encodings could be converted before parsing them.

Regards,
Marcus
18813f71506ebad74179bf8c5a136696?d=identicon&s=25 Eric Wong (Guest)
on 2013-09-04 00:31
(Received via mailing list)
Marc Heiler <lists@ruby-forum.com> wrote:
> Hi,
>
> Are there alternatives to yaml files?
>
> I need mostly:
>
> key: value pairs
>
> although the ability to load arrays directly into a .rb file would be
> cool too.

You could try to make CSV work for you.

Or just inspect/pp + eval if you want to live dangerously.

> Reason: I can no longer use yaml files in ruby 2.0 if they are not in
> UTF. As I do not use UTF and never will, yet syck has been removed, I
> need another way to load my configuration settings (I use several
> hundred yaml files). Without that I would be forced to not use my
> configuration settings (which is currently in yaml) so upgrading my ruby
> version gives me only drawbacks and extra work and no benefit.

YAML can store binary, too.  It isn't pretty, but you can continue
using whatever encoding you want:

---
FOO: !binary |-
  8Ss3UyKu9iXkSC0=
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.