jruby-mapdb 0.9.5-java → 0.9.6-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/README.md +9 -5
- data/Rakefile +12 -0
- data/lib/jruby/mapdb/version.rb +1 -1
- data/lib/jruby/mapdb.rb +4 -0
- data/test/mapdb_test.rb +73 -0
- data/test/test_helper.rb +4 -0
- metadata +42 -49
- data/test.rb +0 -68
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cbd28983814fe1f29640826969cba61f7ae13a81
|
4
|
+
data.tar.gz: 1170604b2d40a0643f813e4898195a86697aba33
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 781523f4f5672147184b3274257b5db87cb4d0f3dfd5d99403481d2650937ac62dcada5cee0034d7ccef5812cb0d2cffac0349c072103bff7c94a6a8292bccfd
|
7
|
+
data.tar.gz: ade71e1c8f299776edfd7d776530cc36b2ed2e78861dd8762b5176e6eecc91560f7e3c5cc13966f573a13f8505a7db109aaba072396cf24553b58a29e9bd7d21
|
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Jruby::Mapdb
|
2
2
|
|
3
|
-
This is a jruby-only wrapper for MapDB. MapDB is a fast key-value store java library.
|
3
|
+
This is a jruby-only wrapper for MapDB (v0.9.5). MapDB is a fast key-value store java library.
|
4
4
|
|
5
5
|
Using this gem, MapDB trees are seen as hashes in jruby, making persistence easy and cheap.
|
6
6
|
|
@@ -83,18 +83,22 @@ It is compatible with most Enumerable methods: each, find_all, select, reject, e
|
|
83
83
|
|
84
84
|
#regexp(pattern) returns array of matched keys with pattern (extended + ignorecase)
|
85
85
|
|
86
|
+
#clear empty tree (remove all previously stored keys and values)
|
87
|
+
|
86
88
|
~~~
|
87
89
|
|
88
90
|
## Testing
|
89
91
|
|
90
|
-
Testing is done
|
91
|
-
* a hack purely based on Test::Unit::TestCase and Unit::Test::Assertions
|
92
|
-
* test framework dependency removed
|
92
|
+
Testing is done using Test::Unit, and has been verified on jruby 1.6.8, 1.7.4, 1.7.5dev in both 1.8 and 1.9 modes.
|
93
93
|
|
94
94
|
~~~
|
95
|
-
$
|
95
|
+
$ rake
|
96
96
|
~~~
|
97
97
|
|
98
|
+
## Contributors
|
99
|
+
|
100
|
+
* fntzr (test refactoring)
|
101
|
+
|
98
102
|
## Contributing
|
99
103
|
|
100
104
|
1. Fork it
|
data/Rakefile
ADDED
data/lib/jruby/mapdb/version.rb
CHANGED
data/lib/jruby/mapdb.rb
CHANGED
@@ -28,6 +28,9 @@ module Jruby
|
|
28
28
|
re = Regexp.new "#{pattern}", Regexp::EXTENDED | Regexp::IGNORECASE
|
29
29
|
@tree.select{ |k,v| "#{k}" =~ re }.map(&:first)
|
30
30
|
end
|
31
|
+
def clear
|
32
|
+
@tree.clear
|
33
|
+
end
|
31
34
|
alias :[]= :encode
|
32
35
|
alias :[] :decode
|
33
36
|
alias :size :count
|
@@ -62,6 +65,7 @@ module Jruby
|
|
62
65
|
Object.const_set treename, Class.new(Tree)
|
63
66
|
Object.const_get(treename).instance_variable_set :@mapdb, @mapdb
|
64
67
|
Object.const_get(treename).instance_variable_set :@tree, @mapdb.getTreeMap("#{treename}")
|
68
|
+
Object.const_get treename
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
data/test/mapdb_test.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module MyTest
|
4
|
+
def runner(type)
|
5
|
+
db = @db
|
6
|
+
assert_instance_of Jruby::Mapdb::DB, db
|
7
|
+
assert_equal type, db.type
|
8
|
+
|
9
|
+
db.tree :People
|
10
|
+
assert People.is_a?(Enumerable)
|
11
|
+
assert_equal Jruby::Mapdb::Tree, People.superclass
|
12
|
+
assert_equal [:People], db.trees
|
13
|
+
assert_equal [], People.entries
|
14
|
+
|
15
|
+
People[0] = 'CM'
|
16
|
+
People[1] = {
|
17
|
+
:name => 'CM',
|
18
|
+
:features => {
|
19
|
+
:developer => true
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
assert People.key?(0)
|
24
|
+
assert People.key?(1)
|
25
|
+
assert_equal [1], People.regexp('^1$')
|
26
|
+
assert_equal 2, People.size
|
27
|
+
assert_equal 2, People.count
|
28
|
+
assert_equal [0,1], People.keys
|
29
|
+
|
30
|
+
assert_instance_of String, People[0]
|
31
|
+
assert_equal 'CM', People[0]
|
32
|
+
|
33
|
+
assert_instance_of Hash, People[1]
|
34
|
+
assert_equal 'CM', People[1][:name]
|
35
|
+
assert_instance_of Hash, People[1][:features]
|
36
|
+
assert People[1][:features][:developer]
|
37
|
+
|
38
|
+
People.clear
|
39
|
+
assert_equal 0, People.count
|
40
|
+
|
41
|
+
assert_raise RuntimeError do
|
42
|
+
db.tree :People
|
43
|
+
end
|
44
|
+
Object.send(:remove_const, :People)
|
45
|
+
|
46
|
+
mapdb = db.instance_variable_get(:@mapdb)
|
47
|
+
mapdb.close
|
48
|
+
assert mapdb.closed?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class MemoryDBTest < Test::Unit::TestCase
|
53
|
+
include MyTest
|
54
|
+
|
55
|
+
def test_memory_db
|
56
|
+
@db = Jruby::Mapdb::DB.new
|
57
|
+
runner(:MemoryDB)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class FileDBTest < Test::Unit::TestCase
|
62
|
+
include MyTest
|
63
|
+
def setup
|
64
|
+
@f = Tempfile.new('testdb')
|
65
|
+
end
|
66
|
+
def teardown
|
67
|
+
File.delete(@f.path + '.p')
|
68
|
+
end
|
69
|
+
def test_file_db
|
70
|
+
@db = Jruby::Mapdb::DB.new(@f.path)
|
71
|
+
runner(:FileDB)
|
72
|
+
end
|
73
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,63 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby-mapdb
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.9.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.6
|
6
5
|
platform: java
|
7
|
-
authors:
|
8
|
-
|
9
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- Christian MICHON
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2013-09-24 00:00:00 Z
|
11
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
14
12
|
dependencies: []
|
15
|
-
|
16
13
|
description: MapDB wrapper for JRuby
|
17
|
-
email:
|
18
|
-
|
14
|
+
email:
|
15
|
+
- christian.michon@gmail.com
|
19
16
|
executables: []
|
20
|
-
|
21
17
|
extensions: []
|
22
|
-
|
23
18
|
extra_rdoc_files: []
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
files:
|
20
|
+
- Gemfile
|
21
|
+
- jruby-mapdb.gemspec
|
22
|
+
- LICENSE-mapdb.txt
|
23
|
+
- LICENSE.txt
|
24
|
+
- Rakefile
|
25
|
+
- README.md
|
26
|
+
- lib/jruby-mapdb.rb
|
27
|
+
- lib/mapdb-0.9.5.jar
|
28
|
+
- lib/jruby/mapdb.rb
|
29
|
+
- lib/jruby/mapdb/version.rb
|
30
|
+
- test/mapdb_test.rb
|
31
|
+
- test/test_helper.rb
|
35
32
|
homepage: http://github.com/cmichon/jruby-mapdb
|
36
|
-
licenses:
|
37
|
-
|
38
|
-
|
33
|
+
licenses:
|
34
|
+
- MIT
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
39
37
|
rdoc_options: []
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: "0"
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
55
50
|
requirements: []
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
specification_version: 3
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 2.0.3
|
53
|
+
signing_key:
|
54
|
+
specification_version: 4
|
61
55
|
summary: MapDB wrapper
|
62
56
|
test_files: []
|
63
|
-
|
data/test.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
class TDD < Test::Unit::TestCase
|
4
|
-
def default_test
|
5
|
-
eval DATA.read
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
__END__
|
10
|
-
|
11
|
-
lib = File.expand_path('../lib', __FILE__)
|
12
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
13
|
-
|
14
|
-
%w[rubygems tempfile jruby-mapdb].map &method(:require)
|
15
|
-
|
16
|
-
f = Tempfile.new('testdb')
|
17
|
-
|
18
|
-
types = [ :MemoryDB, :FileDB ]
|
19
|
-
|
20
|
-
[ Jruby::Mapdb::DB.new,
|
21
|
-
Jruby::Mapdb::DB.new(f.path)
|
22
|
-
].each_with_index do |db,i|
|
23
|
-
assert_instance_of Jruby::Mapdb::DB, db
|
24
|
-
assert_equal types[i], db.type
|
25
|
-
|
26
|
-
db.tree :People
|
27
|
-
assert People.is_a?(Enumerable)
|
28
|
-
assert_equal Jruby::Mapdb::Tree, People.superclass
|
29
|
-
assert_equal [:People], db.trees
|
30
|
-
assert_equal [], People.entries
|
31
|
-
|
32
|
-
People[0] = 'CM'
|
33
|
-
People[1] = {
|
34
|
-
:name => 'CM',
|
35
|
-
:features => {
|
36
|
-
:developer => true
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
assert People.key?(0)
|
41
|
-
assert People.key?(1)
|
42
|
-
assert_equal [1], People.regexp('^1$')
|
43
|
-
assert_equal 2, People.size
|
44
|
-
assert_equal 2, People.count
|
45
|
-
assert_equal [0,1], People.keys
|
46
|
-
|
47
|
-
assert_instance_of String, People[0]
|
48
|
-
assert_equal 'CM', People[0]
|
49
|
-
|
50
|
-
assert_instance_of Hash, People[1]
|
51
|
-
assert_equal 'CM', People[1][:name]
|
52
|
-
assert_instance_of Hash, People[1][:features]
|
53
|
-
assert People[1][:features][:developer]
|
54
|
-
|
55
|
-
assert_raise RuntimeError do
|
56
|
-
db.tree :People
|
57
|
-
end
|
58
|
-
Object.send(:remove_const, :People)
|
59
|
-
|
60
|
-
mapdb = db.instance_variable_get(:@mapdb)
|
61
|
-
mapdb.close
|
62
|
-
assert mapdb.closed?
|
63
|
-
|
64
|
-
if i == 1
|
65
|
-
File.delete(f.path + '.p')
|
66
|
-
f.unlink
|
67
|
-
end
|
68
|
-
end
|