From: ara.t.howard@... Date: 2006-12-10T05:06:08+09:00 Subject: Re: File.yaml?(fname) On Sun, 10 Dec 2006, Trans wrote: > what's the best way to determine if a file is yaml? > > thanks, > t. in ruby queue i detect whether stdin input is a normal list or yaml in this way: if first_non_blank_line =~ %r/^\s*---\s*$/ load_yaml_from_stdin else process_line first_non_blank_line while((line = next_line[stdin])) process_line line end end not perfect, but's it worked well enough so far cheers. also, from the command line i've taken to this approach list_input_on_stdin = ARGV.delete '-' yaml_input_on_stdin = ARGV.delete '---' for, for example cat.rb - # dump stdin cat.rb --- # load the yaml doc on stdin and dump that note that '--' is used to indicate the end of options so it is not a good flag. regards. -a -- if you want others to be happy, practice compassion. if you want to be happy, practice compassion. -- the dalai lama