Uliska Parser Output Data Structure Standard

Specification below describes hash data structure, main goal of which is to make data produced by Uliska parser easy to use by software that does not know about internal data structure, i.e. data driven and schema-less. Data structures should be built in such a way as to make data self-documenting, easy adaptable and "software-friendly".

Hashes

GOOD:

:filesystem_size.humanize

BAD:

:fs_s.humanize

Arrays

OK:

   { :local_users => 
      [ { :name => "nobody",
         :password => "*",
         :uid => -2,
         :gid => -2,
         :gecos => "Unprivileged User",
         :homedir => "/var/empty",
         :shell => "/usr/bin/false"
       },
       { :name => "root",
         :password => "*",
         :uid => 0,
         :gid => 0,
         :gecos => "System Administrator",
         :homedir => "/var/root",
         :shell => "/bin/sh"
       }
     ]
   }

BETTER:

   { :local_users => 
      {
      :nobody => 
        { :name  =>  "nobody",
          :password => "*",
          :uid => -2,
          :gid => -2,
          :gecos => "Unprivileged User",
          :homedir => "/var/empty",
          :shell => "/usr/bin/false"
        },
      :root => 
        { :name => "root",
          :password => "*",
          :uid => 0,
          :gid => 0,
          :gecos => "System Administrator",
          :homedir => "/var/root",
          :shell => "/bin/sh"
        }
      }
   }

Example 1 -- Array of Hashes with "name" key:

 {   :local_users=>
     [{:name=>"root",
       :password=>"x",
       :uid=>0,
       :gid=>0,
       :gecos=>"root",
       :homedir=>"/root",
       :shell=>"/bin/bash"},
      {:name=>"daemon",
       :password=>"x",
       :uid=>1,
       :gid=>1,
       :gecos=>"daemon",
       :homedir=>"/usr/sbin",
       :shell=>"/bin/sh"}
     ]
 }

Example 2 -- Enclosing collection "groups" is an Array of Hashes. Each Hash has key "group":

    {:groups=>
     [ {:group=>"root",   :password=>"x", :gid=>0, :members=>[]},
       {:group=>"daemon", :password=>"x", :gid=>1, :members=>[]},
       {:group=>"bin",    :password=>"x", :gid=>2, :members=>[]},
       {:group=>"sys",    :password=>"x", :gid=>3, :members=>[]}
      ]
}

Local Variables: fill-column: 9999 End: