Invoracle
Invoracle (short for Inventory Oracle), is the basis of a flexible inventory reporting system that can be used to build custom reports for managing large numbers of computer systems. It is designed to provide a basis of reporting for thousands of systems using a generic, extensible JSON schema.
The Invoracle::System class is a subclass of the JsonDoc Ruby gem and adds a default JSON schema for computer systems to the functionality available in JsonDoc. It can be used as is or it can be further subclassed to add additional custom attributes.
Primary use cases include use as a core document object that various parsers can leverage to populate a strict schema JSON document and to build reporting systems such as CSV/Excel reports.
Installation
Gem Installation
Download and install invoracle with the following:
gem install invoracle
Usage
require 'invoracle'
system = Invoracle::System.new()
schema = generic_system.dSchema
system.setAttr(:sSysFqdn, system_fqdn)
system_fqdn = system.getAttr(:sSysFqdn)
system_hash = system.asHash
system_json = system.asJson
Notes
Default Schema
To view the default schema, you can use pretty print the default schema using the dSchema accessor. The default schema uses Hungarian CamelCase (HCC) names which are described below. These names are still in development so please provide feedback.
Schema Property Formats
The default properties, which can be overridden, use a short form of “Hungarian CamelCase” where properties are prefixed with type abbreviations including [‘a’,‘d’,‘f’,‘i’,‘j’,‘s’,‘x’] for:
a = array d = dictionary / hash f = float / number h = html / string i = integer / number j = JSON / string s = string x = XML / string
Subclassing
To subclass this module, override the getDefaultSchema() method and add your own schema. To add a schema on to the default schema see the Usage section above.
Schema Validation
Schema validation is not provided in this version.
Links
JSON
JSON Schema
Problems, Comments, Suggestions?
All of the above are most welcome. [email protected]
Credits
John Wang - johnwang.com
License
JsonDoc is available under an MIT-style license.
:include: MIT-LICENSE
Warranty
This software is provided “as is” and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.