libcdb-ruby 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,10 @@
1
1
  = Revision history for libcdb-ruby
2
2
 
3
+ == 0.0.4 [2012-08-09]
4
+
5
+ * Fixed writing with Ruby 1.9.3 on Windows.
6
+ * Fixed leaking CDB pointer when closing reader.
7
+
3
8
  == 0.0.3 [2012-04-02]
4
9
 
5
10
  * Fixed linking error on Mac OS X. (Issue #1 reported by minaguib)
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to libcdb-ruby version 0.0.2
5
+ This documentation refers to libcdb-ruby version 0.0.4
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -63,9 +63,10 @@ creating and reading {constant databases}[http://cr.yp.to/cdb.html].
63
63
  == PREREQUISITES
64
64
 
65
65
  <b></b>
66
- * Ruby 1.8.7+ or 1.9+ (see below for details)
67
- * TinyCDB[http://corpit.ru/mjt/tinycdb.html] headers (not
68
- needed when installing the fat binary gem on Windows)
66
+ * Ruby 1.8.7+ or 1.9+ (see {below}[rdoc-label:label-SUPPORTED+PLATFORMS]
67
+ for details)
68
+ * TinyCDB[http://corpit.ru/mjt/tinycdb.html] headers (not needed when
69
+ installing the fat binary gem on Windows)
69
70
 
70
71
  Debian/Ubuntu:: +libcdb-dev+
71
72
  Fedora/SuSE:: +tinycdb-devel+
@@ -75,8 +76,8 @@ creating and reading {constant databases}[http://cr.yp.to/cdb.html].
75
76
  == SUPPORTED PLATFORMS
76
77
 
77
78
  <b></b>
78
- Linux:: 1.8 & 1.9 (Tested on Ubuntu with 1.8.7p302 and 1.9.3p19)
79
- Windows:: 1.9 only (Tested on XP with 1.9.3p0)
79
+ Linux:: 1.8 & 1.9 (Tested on Ubuntu with 1.8.7p361, 1.9.2p320 and 1.9.3p195)
80
+ Windows:: 1.9 only (Tested on XP with 1.9.2p290 and 1.9.3p194)
80
81
 
81
82
 
82
83
  == LINKS
@@ -503,6 +503,7 @@ rcdb_reader_close(VALUE self) {
503
503
  RCDB_READER_GET(self, cdb);
504
504
  rb_iv_set(self, "closed", Qtrue);
505
505
 
506
+ cdb_free(cdb);
506
507
  rb_io_close(rb_iv_get(self, "@io"));
507
508
 
508
509
  return Qnil;
@@ -77,8 +77,8 @@ rcdb_writer_put_value(struct cdb_make *cdbm, VALUE key, VALUE val, enum cdb_put_
77
77
  case CDB_PUT_INSERT:
78
78
  /* see if key already exists */
79
79
  switch (cdb_make_exists(cdbm,
80
- RSTRING_PTR(key),
81
- RSTRING_LEN(key))) {
80
+ RSTRING_PTR(key),
81
+ RSTRING_LEN(key))) {
82
82
  case 0:
83
83
  /* doesn't exist, add all */
84
84
  mode = CDB_PUT_ADD;
@@ -6,7 +6,7 @@ module LibCDB
6
6
 
7
7
  MAJOR = 0
8
8
  MINOR = 0
9
- TINY = 3
9
+ TINY = 4
10
10
 
11
11
  class << self
12
12
 
data/lib/libcdb.rb CHANGED
@@ -13,8 +13,8 @@ module LibCDB
13
13
 
14
14
  extend Forwardable
15
15
 
16
- MODE_READ = 'r' # :nodoc:
17
- MODE_WRITE = 'w' # :nodoc:
16
+ MODE_READ = 'r'.freeze # :nodoc:
17
+ MODE_WRITE = 'w'.freeze # :nodoc:
18
18
 
19
19
  class << self
20
20
 
@@ -32,20 +32,12 @@ module LibCDB
32
32
  # <tt>r+</tt>:: CDB (initially opened for reading)
33
33
  # <tt>w+</tt>:: CDB (initially opened for writing)
34
34
  def open(path, mode = MODE_READ)
35
- klass, args = self, []
36
-
37
- case mode
38
- when 'r+' then args = [mode = MODE_READ]
39
- when 'w+' then args = [ MODE_WRITE]
40
- when MODE_READ then klass = Reader
41
- when MODE_WRITE then klass, mode = Writer, 'w+'
42
- else raise ArgumentError, "illegal access mode #{mode}"
43
- end
35
+ klass, args = _open_args(path, mode)
44
36
 
45
37
  cdb = begin
46
- klass.new(io = File.open(path, mode), *args)
38
+ klass.new(*args)
47
39
  rescue
48
- io.close if io
40
+ args.first.close
49
41
  raise
50
42
  end
51
43
 
@@ -86,6 +78,22 @@ module LibCDB
86
78
  }
87
79
  end
88
80
 
81
+ private
82
+
83
+ def _open_args(path, mode)
84
+ klass, args = self, []
85
+
86
+ case mode
87
+ when 'r+' then args = [mode = MODE_READ]
88
+ when 'w+' then args = [ MODE_WRITE]
89
+ when MODE_READ then klass = Reader
90
+ when MODE_WRITE then klass, mode = Writer, 'w+'
91
+ else raise ArgumentError, "illegal access mode #{mode.inspect}"
92
+ end
93
+
94
+ [klass, args.unshift(File.open(path, mode + 'b'))]
95
+ end
96
+
89
97
  end
90
98
 
91
99
  # call-seq:
@@ -102,7 +110,7 @@ module LibCDB
102
110
  case mode
103
111
  when MODE_READ then open_read
104
112
  when MODE_WRITE then open_write
105
- else raise ArgumentError, "illegal access mode #{mode}"
113
+ else raise ArgumentError, "illegal access mode #{mode.inspect}"
106
114
  end
107
115
  end
108
116
 
@@ -248,7 +256,7 @@ module LibCDB
248
256
  @mode = new_mode
249
257
  new_mode += '+' if new_mode == MODE_WRITE
250
258
 
251
- io.reopen(io.path, new_mode)
259
+ io.reopen(io.path, new_mode + 'b')
252
260
  end
253
261
 
254
262
  end
metadata CHANGED
@@ -1,30 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: libcdb-ruby
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jens Wille
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-02 00:00:00 Z
12
+ date: 2012-08-09 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: Ruby bindings for CDB Constant Databases.
22
15
  email: jens.wille@uni-koeln.de
23
16
  executables: []
24
-
25
- extensions:
17
+ extensions:
26
18
  - ext/libcdb/extconf.rb
27
- extra_rdoc_files:
19
+ extra_rdoc_files:
28
20
  - README
29
21
  - COPYING
30
22
  - ChangeLog
@@ -32,69 +24,60 @@ extra_rdoc_files:
32
24
  - ext/libcdb/ruby_cdb.c
33
25
  - ext/libcdb/ruby_cdb_reader.c
34
26
  - ext/libcdb/ruby_cdb_writer.c
35
- files:
27
+ files:
36
28
  - lib/libcdb-ruby.rb
37
- - lib/libcdb/version.rb
38
29
  - lib/cdb.rb
30
+ - lib/libcdb/version.rb
39
31
  - lib/libcdb.rb
40
- - ChangeLog
41
32
  - COPYING
42
- - README
43
- - Rakefile
44
33
  - 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
34
+ - ChangeLog
35
+ - Rakefile
36
+ - README
50
37
  - ext/libcdb/ruby_cdb_writer.c
38
+ - ext/libcdb/ruby_cdb.h
39
+ - ext/libcdb/libcdb_ruby.def
51
40
  - ext/libcdb/extconf.rb
41
+ - ext/libcdb/ruby_cdb_writer.h
42
+ - ext/libcdb/ruby_libcdb.h
52
43
  - ext/libcdb/ruby_cdb_reader.h
53
44
  - ext/libcdb/libcdb.c
54
- - ext/libcdb/libcdb_ruby.def
55
- - spec/libcdb/writer_spec.rb
56
- - spec/libcdb/reader_spec.rb
45
+ - ext/libcdb/ruby_cdb_reader.c
46
+ - ext/libcdb/ruby_cdb.c
57
47
  - spec/spec_helper.rb
48
+ - spec/libcdb/reader_spec.rb
49
+ - spec/libcdb/writer_spec.rb
58
50
  - .rspec
59
51
  homepage: http://github.com/blackwinter/libcdb-ruby
60
52
  licenses: []
61
-
62
53
  post_install_message:
63
- rdoc_options:
64
- - --main
65
- - README
54
+ rdoc_options:
66
55
  - --charset
67
56
  - UTF-8
68
- - --title
69
- - libcdb-ruby Application documentation (v0.0.3)
70
- - --all
71
57
  - --line-numbers
72
- require_paths:
58
+ - --all
59
+ - --title
60
+ - libcdb-ruby Application documentation (v0.0.4)
61
+ - --main
62
+ - README
63
+ require_paths:
73
64
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
65
+ required_ruby_version: !ruby/object:Gem::Requirement
75
66
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
81
- - 0
82
- version: "0"
83
- required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
72
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
92
77
  requirements: []
93
-
94
78
  rubyforge_project:
95
- rubygems_version: 1.8.21
79
+ rubygems_version: 1.8.24
96
80
  signing_key:
97
81
  specification_version: 3
98
82
  summary: Ruby bindings for CDB Constant Databases.
99
83
  test_files: []
100
-