libcdb-ruby - Ruby bindings for CDB Constant Databases.

VERSION

This documentation refers to libcdb-ruby version 0.1.0

DESCRIPTION

The libcdb-ruby library provides Ruby bindings for the TinyCDB package for creating and reading constant databases.

require 'libcdb'

# creating
LibCDB::CDB.open('foo.cdb', 'w') { |cdb|
  cdb['a'] = 'one'
  cdb['b'] = '123'
}

# reading
LibCDB::CDB.open('foo.cdb') { |cdb|
  cdb['a']  #=> "one"
  cdb['b']  #=> "123"
  cdb['c']  #=> nil
}

# hybrid
LibCDB::CDB.open('foo.cdb', 'w+') { |cdb|
  cdb['a'] = 'one'
  cdb['b'] = '123'

  cdb['a']  #=> "one"
  cdb['b']  #=> "123"
  cdb['c']  #=> nil

  # database is truncated whenever
  # a new writer is opened:
  cdb['a'] = 'two'
  cdb['c'] = 'xyz'

  cdb['a']  #=> "two"
  cdb['b']  #=> nil
  cdb['c']  #=> "xyz"
}

# update existing database
LibCDB::CDB.open('foo.cdb', 'r+') { |cdb|
  # store existing records
  cdb << cdb.to_h

  # and add a new one
  cdb['d'] = '42'

  cdb['a']  #=> "two"
  cdb['b']  #=> nil
  cdb['c']  #=> "xyz"
  cdb['d']  #=> "42"
}

PREREQUISITES

SUPPORTED PLATFORMS

Linux

MRI 1.9 & 2.0 (Tested on 64-bit Ubuntu GNU/Linux with 1.9.2p323, 1.9.3p286 and 2.0.0p119)

Windows

MRI 1.9 (Tested on 32-bit Windows XP with 1.9.2p290 and 1.9.3p194)

Documentation

blackwinter.github.com/libcdb-ruby

Source code

github.com/blackwinter/libcdb-ruby

RubyGem

rubygems.org/gems/libcdb-ruby

TinyCDB

www.corpit.ru/mjt/tinycdb.html

CDB

cr.yp.to/cdb.html

AUTHORS

CREDITS

This project was inspired by ruby-cdb and cdb-full. The code organization, especially the extension part, was modeled after libxml-ruby.

And props to the rake-compiler team for making extension building such a breeze :)

LICENSE AND COPYRIGHT

Copyright (C) 2012 University of Cologne, Albertus-Magnus-Platz, 50923 Cologne, Germany

Copyright (C) 2013 Jens Wille

libcdb-ruby is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

libcdb-ruby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with libcdb-ruby. If not, see <www.gnu.org/licenses/>.