On Mon, 7 Mar 2005 06:44:59 +0900, Joel VanderWerf
<vjoel / path.berkeley.edu> wrote:
> Bill Guindon wrote:
> > I'm trying to read in a YAML file that has a list of database specs
> > (name, fields, indexes, etc.)  Once that's read in, I'd like to turn
> > them into an array of db objects.  In the end, I want to loop through
> > the array and generate some code based on each database spec.
> 
> Is the YAML file something like this?
> 
> ---
> -
>    name: Foo
>    fields:
>      - :x
>      - :y
>      - :z
>    indexes:
> -
>    name: Bar
>    fields:
>      - :a
>      - :b
>      - :c
>    indexes:

Pretty close (should've included it)
Do I need the colons before the field names?  I'm not doing that now.

Here's a couple table's worth:
---
  -
    name: PM_Static_SettingsDB
    file: settings.dbf
    fdel: false
    dnoc: false
    fields:
      - key      CHAR 254
      - redir    CHAR 254
      - admin    CHAR 254
      - hidehelp BOOL
      - last_tab CHAR 50

    indexes:
      -
        file: cats.mvx
        expr: PM_Static_catsDB.d.cat_id
        flag: nounique, ascending
  -
    name: PM_Static_KeysDB
    file: keys.dbf
    fdel: false
    dnoc: true

    fields:
      - name CHAR 50
      - value NUMBER
    indexes:
      -
        file: keys.mvx
        expr: PM_Static_KeysDB.d.name
        flag: nounique, ascending

 
> If so, then you can just YAML.load() the file, and you'll get an array
> of hashes, which you can iterate over.
 
I'll give that a shot, was wondering if there was a way to auto create
objects from the YAML load, but yeah, I could loop through them and do
it that way.  I'll see how it goes.

-- 
Bill Guindon (aka aGorilla)