Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ef82664
Showing
24 changed files
with
2,405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
doc | ||
doc.local | ||
pkg | ||
tmp | ||
.gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
= Revision history for libcdb-ruby | ||
|
||
== 0.0.1 [2012-01-12] | ||
|
||
* Birthday :-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
= libcdb-ruby - Ruby bindings for CDB Constant Databases. | ||
|
||
== VERSION | ||
|
||
This documentation refers to libcdb-ruby version 0.0.1 | ||
|
||
|
||
== DESCRIPTION | ||
|
||
The libcdb-ruby library provides Ruby bindings for the | ||
TinyCDB[http://corpit.ru/mjt/tinycdb.html] package for | ||
creating and reading {constant databases}[http://cr.yp.to/cdb.html]. | ||
|
||
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 | ||
|
||
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| | ||
cdb.store(cdb.to_h) | ||
|
||
cdb['d'] = '42' | ||
|
||
cdb['a'] #=> "two" | ||
cdb['b'] #=> nil | ||
cdb['c'] #=> "xyz" | ||
cdb['d'] #=> "42" | ||
} | ||
|
||
|
||
== SUPPORTED PLATFORMS | ||
|
||
Linux:: 1.8 & 1.9 | ||
Windows:: 1.9 only | ||
|
||
|
||
== LINKS | ||
|
||
<b></b> | ||
Documentation:: http://blackwinter.github.com/libcdb-ruby | ||
Source code:: http://github.com/blackwinter/libcdb-ruby | ||
RubyGem:: http://rubygems.org/gems/libcdb-ruby | ||
TinyCDB:: http://corpit.ru/mjt/tinycdb.html | ||
CDB:: http://cr.yp.to/cdb.html | ||
|
||
|
||
== AUTHORS | ||
|
||
* Jens Wille <mailto:jens.wille@uni-koeln.de> | ||
|
||
|
||
== LICENSE AND COPYRIGHT | ||
|
||
Copyright (C) 2012 University of Cologne, | ||
Albertus-Magnus-Platz, 50923 Cologne, Germany | ||
|
||
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 <http://www.gnu.org/licenses/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require File.expand_path(%q{../lib/libcdb/version}, __FILE__) | ||
|
||
begin | ||
require 'hen' | ||
|
||
cco = [] | ||
|
||
if dir = ENV['TINYCDB'] | ||
cco << "--with-cdb-include=#{dir}" | ||
cco << "--with-cdb-lib=#{dir}" | ||
end | ||
|
||
if dir = ENV['MINGW32'] | ||
cco << "--with-cflags=\"-I#{dir}/include -L#{dir}/lib\"" | ||
end | ||
|
||
Hen.lay! {{ | ||
:gem => { | ||
:name => %q{libcdb-ruby}, | ||
:version => LibCDB::CDB::VERSION, | ||
:summary => %q{Ruby bindings for CDB Constant Databases.}, | ||
:author => %q{Jens Wille}, | ||
:email => %q{jens.wille@uni-koeln.de}, | ||
:homepage => :blackwinter, | ||
:extension => { :cross_config_options => cco } | ||
} | ||
}} | ||
rescue LoadError => err | ||
warn "Please install the `hen' gem. (#{err})" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* More specs!! | ||
* More Documentation! | ||
* Atomic updates? (rename after create) | ||
* Benchmarks? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'mkmf' | ||
|
||
dir_config('cdb') | ||
|
||
if have_library('cdb', 'cdb_init') && have_header('cdb.h') && have_macro('TINYCDB_VERSION', 'cdb.h') | ||
have_header('ruby/io.h') | ||
have_header('ruby/st.h') | ||
create_makefile('libcdb/libcdb_ruby') | ||
else | ||
abort '*** ERROR: missing required library to compile this module' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "ruby_libcdb.h" | ||
|
||
void | ||
Init_libcdb_ruby(void) { | ||
char libcdb_version[8]; | ||
snprintf(libcdb_version, 7, "%g", TINYCDB_VERSION); | ||
|
||
/* | ||
* LibCDB namespace. | ||
*/ | ||
mLibCDB = rb_define_module("LibCDB"); | ||
|
||
rcdb_init_cdb(); | ||
rcdb_init_reader(); | ||
rcdb_init_writer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
LIBRARY libcdb_ruby.so | ||
EXPORTS | ||
Init_libcdb_ruby | ||
|
||
cCDBReader DATA | ||
cCDBWriter DATA | ||
mLibCDB DATA | ||
cCDB DATA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "ruby_libcdb.h" | ||
|
||
void | ||
rcdb_init_cdb(void) { | ||
char libcdb_version[8]; | ||
snprintf(libcdb_version, 7, "%g", TINYCDB_VERSION); | ||
|
||
/* | ||
* See README. | ||
*/ | ||
cCDB = rb_define_class_under(mLibCDB, "CDB", rb_cObject); | ||
|
||
/* The TinyCDB library version. */ | ||
rb_define_const(cCDB, "LIBCDB_VERSION", rb_str_new2(libcdb_version)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __RUBY_CDB_H__ | ||
#define __RUBY_CDB_H__ | ||
|
||
#ifdef HAVE_RUBY_IO_H | ||
#define GetFileFD(fptr) (fptr)->fd | ||
#else | ||
#define GetFileFD(fptr) fileno((fptr)->f) | ||
#endif | ||
|
||
VALUE cCDB; | ||
void rcdb_init_cdb(void); | ||
|
||
#endif /* __RUBY_CDB_H__ */ |
Oops, something went wrong.