From: Aaron Patterson Date: 2012-08-09T02:58:45+09:00 Subject: [ruby-core:47078] Re: [ruby-trunk - Feature #6840] YAML tag method --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 08, 2012 at 09:52:15PM +0900, trans (Thomas Sawyer) wrote: >=20 > Issue #6840 has been updated by trans (Thomas Sawyer). >=20 >=20 > As I stated before, for my use case, I do *not* want users to use a suppo= rt library. In fact, it's not just want, its a requirement. This format mus= t be inter-operable. It doesn't mater if the user is programming in Perl, P= ython, Javascript or any other language. They need to be able to access the= information just as readily. I'm not about to write a library for each pos= sible language. The same holds for Ruby. >=20 > The "foo" type is a very specific YAML specification. If the user simply = knows the name and version of the spec then they know what to expect. That'= s the most important thing. Any "Foo" library I write to support "foo" is j= ust a convenience if it suites the purposes of the specifications user. But= usually it will not, and should not.=20 >=20 > But this isn't really about my specific use case. There is a more fundame= ntal issue here. Having to define a global handler upfront makes it impossi= ble to handle the incoming information dynamically. It is one thing to make= something difficult, it's another to make it impossible. You're welcome to access the AST and translate yourself: require 'psych' =20 Psych.parse_stream("---\n- !foo/2 omg\n- zomg") do |ast| ast.each do |node| if node.tag p [:tag, node.tag, node.to_ruby] else p [node.class, :notag, node.to_ruby] end end end You can be as dynamic as you want here. > I realize it sucks to add core methods, but in this case its really a fea= ture that's needed. Sorry, I'm not convinced. --=20 Aaron Patterson http://tenderlovemaking.com/ --UugvWAfsgieZRqgk Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) iQEcBAEBAgAGBQJQIqjJAAoJEJUxcLy0/6/GFL4IAJn7vGh6cFnKwUGsTYxDUZ2n 3VlNoxn3CuFNzJ2rIXYfwnl/ciTVUKlD4BovHx2qFaUZt7XP10yiB6DjAjg4MCLa 5fcmYH/PlMMj3EJOeBuR43s35zUeKPvPCvikssmz4BZSeUU+S0MB8GA2aSKy9wFh R0osA6ETQxw0aigSXc6w9JQYoAzQ15mnF8AA6wrCd6in1+Uv68l3o04JOLhXt0OX 7+etzqc+bUSV0ugOh9KUtJ4gmP7utfr+Ku5tr/f40v7l5rt7vdXQ7DB/Yum7OPaK iadQGQ9/cxacJV+ghvohg3PtrLu1CeHfpR6wG3QYjQtqYPpYJNycBzLdfM0fFmA= =01HA -----END PGP SIGNATURE----- --UugvWAfsgieZRqgk--