From: "Michael T. Richter" Date: 2008-08-18T14:43:08+09:00 Subject: Re: End of Yaml --=-neYl+WLv4ClN5VHonIo5 Content-Type: multipart/alternative; boundary="=-CCH+2w9OEtUMOjpYn8eB" --=-CCH+2w9OEtUMOjpYn8eB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 2008-08-18 at 14:12 +0900, Ryan Davis wrote: > > Is there a way to have something like this in a yaml file: > > foo: bar > > __ STOP TREATING IT AS YAML FILE FROM HERE __ > > \=C2=B2\=C2=B2\24=C2=B2=C2=BCljk > > asdjladskasd > > some noise is here and there > > asdiasdiodas > > KJLljkq @@@@j=E2=82=AC pqwjpqowj qewopjewqpjewqpjwqp728879241421=C3=BC*= 24242 > > __ END OF YAML FILE __ > No, but you can do the opposite: > ruby_code > __END__ > yaml > and access that with DATA.read This whole __END__/DATA thing does not work as expected. It's yet another situation where "principle of least surprise" doesn't work at all in Ruby. Consider: $ cat test1.rb #test1.rb p DATA.read __END__ This is the DATA stuff from test1.rb. $ cat test2.rb #test2.rb require 'test1' p DATA.read __END__ This is the DATA from test2.rb. $ ruby test2.rb "This is the DATA from test2.rb.\n" "" The source of the problem is that Ruby doesn't have a real system of modules and namespaces. All require does is bring a chunk of text into the current file being processed very much the same way that C's #include does. --=20 Michael T. Richter (GoogleTalk: ttmrichter@gmail.com) A well-designed and humane interface does not need to be split into beginner and expert subsystems. (Jef Raskin) --=-CCH+2w9OEtUMOjpYn8eB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, 2008-08-18 at 14:12 +0900, Ryan Davis wrote:
> Is there a way to have something like this in a yaml file:
> foo: bar
> __ STOP TREATING IT AS YAML FILE FROM HERE __
> \²\²\24²¼ljk
> asdjladskasd
> some noise is here and there
> asdiasdiodas
> KJLljkq @@@@j€ pqwjpqowj qewopjewqpjewqpjwqp728879241421ü*2=
4242
> __ END OF YAML FILE __

No, but you can do the opposite:
ruby_code
__END__
yaml

and access that with DATA.read

This whole __END__/DATA thing does not work as expected.  It's = yet another situation where "principle of least surprise" doesn't= work at all in Ruby.  Consider:

$ cat test1.rb
#test1.rb
p DATA.read
__END__
This is the DATA stuff from test1.rb.

$ cat test2.rb
#test2.rb
require 'test1'
p DATA.read
__END__
This is the DATA from test2.rb.

$ ruby test2.rb
"This is the DATA from test2.rb.\n"
""

The source of the problem is that Ruby doesn't have a real system of module= s and namespaces.  All require does is bring a chunk of text = into the current file being processed very much the same way that C's #= include does.

--
Michael T. Richter <ttmri= chter@gmail.com> (GoogleTalk: ttmrichter@gmail.com)
A well-designed and humane interface does not need to be split into begi= nner and expert subsystems. (Jef Raskin)
--=-CCH+2w9OEtUMOjpYn8eB-- --=-neYl+WLv4ClN5VHonIo5 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIqQyQLqyWkKVQ54QRAulkAKCUO/BvY4QN8hGzG3gqu5N7MZrmsQCfZCnJ Ztj32FUXJSgrQr3WwVa19Sc= =yQru -----END PGP SIGNATURE----- --=-neYl+WLv4ClN5VHonIo5--