rufus-tokyo 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,12 @@
2
2
  = rufus-tokyo CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-tokyo - 0.1.1 released 2009/01/23
6
+
7
+ - bug : fixed dependency, it's ffi not ruby-ffi
8
+ - todo : implemented Cabinet#clear
9
+
10
+
5
11
  == rufus-tokyo - 0.1.0 released 2009/01/23
6
12
 
7
13
  - initial release
data/lib/rufus/tokyo.rb CHANGED
@@ -34,7 +34,7 @@ require 'ffi'
34
34
  module Rufus
35
35
  module Tokyo
36
36
 
37
- VERSION = '0.1.0'
37
+ VERSION = '0.1.1'
38
38
 
39
39
  module Func #:nodoc#
40
40
  extend FFI::Library
@@ -73,6 +73,9 @@ module Tokyo
73
73
  attach_function :tcadbiterinit, [ :pointer ], :int
74
74
  attach_function :tcadbiternext2, [ :pointer ], :string
75
75
 
76
+ attach_function :tcadbvanish, [ :pointer ], :int
77
+
78
+
76
79
  #def self.method_missing (m, *args)
77
80
  # mm = "tcadb#{m}"
78
81
  # self.respond_to?(mm) ? self.send(mm, *args) : super
@@ -209,6 +212,16 @@ module Tokyo
209
212
  Rufus::Tokyo::Func.tcadbrnum(@db)
210
213
  end
211
214
 
215
+ #
216
+ # Removes all the records in the cabinet (use with care)
217
+ #
218
+ # Returns self (like Ruby's Hash does).
219
+ #
220
+ def clear
221
+ Rufus::Tokyo::Func.tcadbvanish(@db)
222
+ self
223
+ end
224
+
212
225
  #
213
226
  # Returns the 'weight' of the db (in bytes)
214
227
  #
@@ -38,7 +38,19 @@ class CabinetZero < Test::Unit::TestCase
38
38
  assert db.close
39
39
  end
40
40
 
41
- # TODO : memory tests
41
+ def test_clear
42
+
43
+ db = Rufus::Tokyo::Cabinet.new('test_data.tch')
44
+
45
+ 40.times { |i| db[i.to_s] = i.to_s }
46
+ assert_equal 40, db.size
47
+
48
+ db.clear
49
+
50
+ assert_equal 0, db.size
51
+
52
+ assert db.close
53
+ end
42
54
 
43
55
  end
44
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-tokyo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -13,7 +13,7 @@ date: 2009-01-23 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: ruby-ffi
16
+ name: ffi
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  version: "0"
64
64
  version:
65
65
  requirements:
66
- - ruby-ffi
66
+ - ffi
67
67
  rubyforge_project: rufus
68
68
  rubygems_version: 1.3.1
69
69
  signing_key: