[ANN] Kwalify 0.7.0 - parser, schema validator, and data binding forYAML and JSON

Discussion in 'Ruby' started by makoto kuwata, Jan 27, 2008.

  1. Hi,

    I have released Kwalify 0.7.0.
    http://www.kuwata-lab.com/kwalify/

    Kwalify is an integrated tool for YAML and JSON.
    Kwalify contains parser, schema validator, and data binding tool.

    This release has many enhancements and changes.
    See
    http://kuwata-lab.com/kwalify/ruby/CHANGES.txt
    for details.

    From this release, Kwalify supports data binding.
    If you specify class name in schema definition, Kwalify parses YAML/
    JSON
    and create instance object of that class instead of Hash object.
    Data binding makes handling YAML easier.

    Example:

    * schema file (config.schema.yaml)
    --------------------
    type: map
    class: Config
    mapping:
    "host": { type: str, required: true }
    "port": { type: int }
    "user": { type: str, required: true }
    "pass": { type: str, required: true }
    --------------------

    * configuration file (config.yaml)
    --------------------
    host: localhost
    user: user1
    pass: password1
    --------------------

    * ruby program (ex1.rb)
    --------------------
    ## class definition
    require 'kwalify/util/hashlike'
    class Config
    include Kwalify::Util::HashLike # defines [], []=, ...
    attr_accessor :host, :posrt, :user, :pass
    def initialize
    @port = 80
    end
    end
    ## create validator object
    require 'kwalify'
    schema = Kwalify::Yaml.load_file('config.schema.yaml')
    validator = Kwalify::Validator.new(schema)
    ## parse configuration file with data binding
    parser = Kwalify::Yaml::parser.new(validator)
    parser.data_binding = true # enable data binding
    config = parser.parse_file('config.yaml')
    p config #=> #<Config:0x542590 @user="user1", @port=80,
    # @pass="password1", @host="localhost">
    --------------------


    See User's Guide for details.
    http://www.kuwata-lab.com/kwalify/ruby/users-guide.html

    --
    regards,
    makoto kuwata
    makoto kuwata, Jan 27, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kwatch
    Replies:
    0
    Views:
    163
    kwatch
    May 30, 2006
  2. makoto kuwata
    Replies:
    0
    Views:
    146
    makoto kuwata
    Jul 18, 2010
  3. Jean-Christophe Le Lann

    require 'kwalify' fails

    Jean-Christophe Le Lann, Feb 4, 2011, in forum: Ruby
    Replies:
    1
    Views:
    81
    Jörg W Mittag
    Feb 5, 2011
  4. Jörg Weule
    Replies:
    20
    Views:
    1,257
    Arno Welzel
    Dec 2, 2011
  5. Acácio Centeno
    Replies:
    1
    Views:
    248
    dieter
    Feb 15, 2013
Loading...

Share This Page