libcdb-ruby 0.0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ module LibCDB
2
+
3
+ class CDB
4
+
5
+ module Version
6
+
7
+ MAJOR = 0
8
+ MINOR = 0
9
+ TINY = 1
10
+
11
+ class << self
12
+
13
+ # Returns array representation.
14
+ def to_a
15
+ [MAJOR, MINOR, TINY]
16
+ end
17
+
18
+ # Short-cut for version string.
19
+ def to_s
20
+ to_a.join('.')
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ VERSION = Version.to_s
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,142 @@
1
+ describe LibCDB::CDB::Reader do
2
+
3
+ before :all do
4
+ @temp = tempfile
5
+
6
+ db = LibCDB::CDB::Writer.new(@temp.to_io)
7
+ TEST_DATA.each { |k, v| v.each { |w| db.store(k, w) } }
8
+ db.close
9
+ end
10
+
11
+ after :all do
12
+ @temp.unlink
13
+ end
14
+
15
+ describe "#initialize" do
16
+
17
+ it "should not accept integers" do
18
+ lambda { LibCDB::CDB::Reader.new(12345) }.should raise_error(TypeError)
19
+ end
20
+
21
+ it "should not accept pipes" do
22
+ lambda { LibCDB::CDB::Reader.new(STDIN) }.should raise_error(SystemCallError)
23
+ end
24
+
25
+ end
26
+
27
+ describe "empty" do
28
+
29
+ before :all do
30
+ @empt = tempfile
31
+ LibCDB::CDB::Writer.new(@empt.to_io).close
32
+ end
33
+
34
+ after :all do
35
+ @empt.unlink
36
+ end
37
+
38
+ before :each do
39
+ @db = LibCDB::CDB::Reader.new(File.open(@empt.path))
40
+ end
41
+
42
+ after :each do
43
+ @db.close
44
+ end
45
+
46
+ it "should know that it's not closed" do
47
+ @db.should_not be_closed
48
+ end
49
+
50
+ it "should know that it's empty" do
51
+ @db.should be_empty
52
+ end
53
+
54
+ it "should know its size" do
55
+ @db.size.should == 0
56
+ end
57
+
58
+ it "should know if it doesn't have a key" do
59
+ @db.should_not have_key('key3')
60
+ end
61
+
62
+ it "should know if it doesn't have a value" do
63
+ @db.should_not have_value('value3.2')
64
+ end
65
+
66
+ end
67
+
68
+ describe "non-empty" do
69
+
70
+ before :each do
71
+ @db = LibCDB::CDB::Reader.new(File.open(@temp.path))
72
+ end
73
+
74
+ after :each do
75
+ @db.close
76
+ end
77
+
78
+ it "should know that it's not closed" do
79
+ @db.should_not be_closed
80
+ end
81
+
82
+ it "should know that it's not empty" do
83
+ @db.should_not be_empty
84
+ end
85
+
86
+ it "should know its size" do
87
+ @db.size.should == 11
88
+ end
89
+
90
+ it "should know if it has a key" do
91
+ @db.should have_key('key3')
92
+ end
93
+
94
+ it "should know if it doesn't have a key" do
95
+ @db.should_not have_key('key33')
96
+ end
97
+
98
+ it "should know if it has a value" do
99
+ @db.should have_value('value3.2')
100
+ end
101
+
102
+ it "should know if it doesn't have a value" do
103
+ @db.should_not have_value('value33.22')
104
+ end
105
+
106
+ it "should get a single value" do
107
+ @db['key1'].should == 'value1.1'
108
+ end
109
+
110
+ it "should not get non-existent value" do
111
+ @db['key33'].should be_nil
112
+ end
113
+
114
+ it "should get each value" do
115
+ TEST_DATA.each { |k, o|
116
+ r = []
117
+ @db.each(k) { |v| r << v }
118
+ r.should == o
119
+ }
120
+ end
121
+
122
+ it "should get all values" do
123
+ TEST_DATA.each { |k, o|
124
+ @db.fetch(k).should == o
125
+ }
126
+ end
127
+
128
+ it "should get last value" do
129
+ @db.fetch_last('key10').should == 'value10.10'
130
+ end
131
+
132
+ it "should find the key for a value" do
133
+ @db.key('value3.2').should == 'key3'
134
+ end
135
+
136
+ it "should not find the key for a non-existent value" do
137
+ @db.key('value33.22').should be_nil
138
+ end
139
+
140
+ end
141
+
142
+ end
@@ -0,0 +1,34 @@
1
+ describe LibCDB::CDB::Writer do
2
+
3
+ describe "#initialize" do
4
+
5
+ it "should not accept strings" do
6
+ lambda { LibCDB::CDB::Writer.new('test') }.should raise_error(TypeError)
7
+ end
8
+
9
+ it "should not accept pipes" do
10
+ lambda { LibCDB::CDB::Writer.new(STDOUT) }.should raise_error(SystemCallError)
11
+ end
12
+
13
+ end
14
+
15
+ describe "#add" do
16
+
17
+ before :each do
18
+ @temp = tempfile
19
+ @db = LibCDB::CDB::Writer.new(@temp.to_io)
20
+ end
21
+
22
+ after :each do
23
+ @temp.unlink
24
+ end
25
+
26
+ it "should add data" do
27
+ TEST_DATA.each { |k, v| v.each { |w| @db.add(k, w) } }
28
+ @db.close
29
+ @db.should be_closed
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,21 @@
1
+ $:.unshift('lib') unless $:.first == 'lib'
2
+
3
+ require 'libcdb'
4
+ require 'tempfile'
5
+
6
+ RSpec.configure { |config|
7
+ config.include(Module.new {
8
+ TEST_DATA = {}
9
+
10
+ 1.upto(10) { |i|
11
+ val = TEST_DATA[key = "key#{i}"] = []
12
+ 1.upto(i) { |j| val << "value#{i}.#{j}" }
13
+ }
14
+
15
+ TEST_DATA['a' * 1024] = Array('b' * 1024 ** 2)
16
+
17
+ def tempfile
18
+ Tempfile.open("libcdb_spec_#{object_id}_temp")
19
+ end
20
+ })
21
+ }
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libcdb-ruby
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: x86-mingw32
12
+ authors:
13
+ - Jens Wille
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-18 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Ruby bindings for CDB Constant Databases.
22
+ email: jens.wille@uni-koeln.de
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README
29
+ - COPYING
30
+ - ChangeLog
31
+ - ext/libcdb/libcdb.c
32
+ - ext/libcdb/ruby_cdb.c
33
+ - ext/libcdb/ruby_cdb_reader.c
34
+ - ext/libcdb/ruby_cdb_writer.c
35
+ files:
36
+ - lib/libcdb-ruby.rb
37
+ - lib/libcdb/version.rb
38
+ - lib/cdb.rb
39
+ - lib/libcdb.rb
40
+ - ChangeLog
41
+ - COPYING
42
+ - README
43
+ - Rakefile
44
+ - TODO
45
+ - ext/libcdb/ruby_cdb_writer.h
46
+ - ext/libcdb/ruby_cdb.c
47
+ - ext/libcdb/ruby_libcdb.h
48
+ - ext/libcdb/ruby_cdb_reader.c
49
+ - ext/libcdb/ruby_cdb.h
50
+ - ext/libcdb/ruby_cdb_writer.c
51
+ - ext/libcdb/extconf.rb
52
+ - ext/libcdb/ruby_cdb_reader.h
53
+ - ext/libcdb/libcdb.c
54
+ - ext/libcdb/libcdb_ruby.def
55
+ - spec/libcdb/writer_spec.rb
56
+ - spec/libcdb/reader_spec.rb
57
+ - spec/spec_helper.rb
58
+ - .rspec
59
+ - lib/libcdb/1.8/libcdb_ruby.so
60
+ - lib/libcdb/1.9/libcdb_ruby.so
61
+ homepage: http://github.com/blackwinter/libcdb-ruby
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --charset
67
+ - UTF-8
68
+ - --title
69
+ - libcdb-ruby Application documentation (v0.0.1)
70
+ - --main
71
+ - README
72
+ - --all
73
+ - --line-numbers
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.15
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Ruby bindings for CDB Constant Databases.
101
+ test_files: []
102
+