On May 18, 9:13=A0am, Kevin Austin <nitsuani... / comcast.net> wrote:
> I am sorting through a heap of yaml files looking for the following
> fields.
>
> yml =3D YAML.load( File.open( yml_file ) )
> =A0 =A0 feed_list[ yml['name' ] ] =3D {
> =A0 =A0 =A0 =A0'description' =3D> yml[ 'description' ] || {},
> =A0 =A0 =A0 =A0'active' =A0 =A0 =A0=3D> yml[ 'active' ],
> =A0 =A0 =A0 =A0'interval' =A0 =A0=3D> yml[ 'interval' ],
> =A0 =A0 =A0 =A0'source_net' =A0=3D> net
> =A0 =A0 }
>
> My problem is that when I encounter a yml file that contains no info (or
> worse yaml designed by someone with a limited grasp of yaml) my program
> goes splat.
>
> Any ideas or direction for scanning then skipping bad yaml files.
>
> I have captured the ruby exceptions but I want to just skip the files
> before it comes to that

Don't think there is any way to do this. I suppose it might be nice if
there were a syntax check function, but it won't be much different
than actually trying to parse it. And if you are going to use the
result if it parses why would you want to waste time doing so twice?
So catching the error is really the best way to go.

~trans