dm-groonga-adapter 0.1.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +26 -0
- data/LICENSE +14 -0
- data/README.rdoc +43 -0
- data/Rakefile +52 -0
- data/VERSION.yml +5 -0
- data/dm-groonga-adapter.gemspec +85 -0
- data/examples/basic.rb +45 -0
- data/lib/groonga_adapter/adapter.rb +207 -0
- data/lib/groonga_adapter/local_index.rb +191 -0
- data/lib/groonga_adapter/model_ext.rb +12 -0
- data/lib/groonga_adapter/remote_index.rb +250 -0
- data/lib/groonga_adapter/remote_result.rb +101 -0
- data/lib/groonga_adapter/repository_ext.rb +13 -0
- data/lib/groonga_adapter/unicode_ext.rb +17 -0
- data/lib/groonga_adapter.rb +9 -0
- data/spec/rcov.opts +6 -0
- data/spec/shared/adapter_example.rb +53 -0
- data/spec/shared/search_example.rb +64 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/specs/adapter_spec.rb +25 -0
- data/spec/specs/remote_result_spec.rb +100 -0
- data/spec/specs/search_spec.rb +26 -0
- metadata +161 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe "DataMapper::Adapters::GroongaAdapter::GroongaResult" do
|
5
|
+
|
6
|
+
it "should parse status result" do
|
7
|
+
raw_value = JSON.parse '[[0,1270195421.18934,7.0e-05],{"alloc_count":143,"starttime":1270022695,"uptime":172726,"version":"0.1.7"}]'
|
8
|
+
status = DataMapper::Adapters::GroongaResult::Status.new raw_value
|
9
|
+
status.success?.should == true
|
10
|
+
status.err_code.should == 0
|
11
|
+
status.err_msg.should == nil
|
12
|
+
status.start_time.should == 1270195421.18934
|
13
|
+
status.elapsed_time == 7.0e-05
|
14
|
+
status.alloc_count.should == 143
|
15
|
+
status.process_starttime.should == 1270022695
|
16
|
+
status.uptime.should == 172726
|
17
|
+
status.version.should == '0.1.7'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should parse result with err_code" do
|
21
|
+
raw_value = JSON.parse '[[-22,1270196259.75858,0.00035,"table \'Hoge\' is not exist."]]'
|
22
|
+
err_result = DataMapper::Adapters::GroongaResult::List.new raw_value
|
23
|
+
err_result.success?.should == false
|
24
|
+
err_result.err_code.should == -22
|
25
|
+
err_result.err_msg.should == "table 'Hoge' is not exist."
|
26
|
+
err_result.start_time.should == 1270196259.75858
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should parse column_list result" do
|
30
|
+
raw_value = JSON.parse '[[0,1270196657.83001,0.000183],[[["id", "UInt32"],["name","ShortText"],["path","ShortText"],["type","ShortText"],["flags","ShortText"],["domain", "ShortText"],["range", "ShortText"],["source","ShortText"]],[273,"Story.title","test.0000111","var","COLUMN_SCALAR|COMPRESS_NONE|PERSISTENT","Story","ShortText",[]],[272,"Story.id","test.0000110","fix","COLUMN_SCALAR|COMPRESS_NONE|PERSISTENT","Story","Int32",[]],[275,"Story.author","test.0000113","var","COLUMN_SCALAR|COMPRESS_NONE|PERSISTENT","Story","ShortText",[]]]]'
|
31
|
+
column_list = DataMapper::Adapters::GroongaResult::List.new raw_value
|
32
|
+
|
33
|
+
column_list.success?.should == true
|
34
|
+
column_list.err_code.should == 0
|
35
|
+
column_list.err_msg.should == nil
|
36
|
+
column_list.start_time.should == 1270196657.83001
|
37
|
+
column_list.elapsed_time == 0.000183
|
38
|
+
|
39
|
+
column_list.columns.should == ["id", "name", "path", "type", "flags", "domain", "range", "source"]
|
40
|
+
expect_mash = Mash.new({
|
41
|
+
"id" => 273,
|
42
|
+
"name" => "Story.title",
|
43
|
+
"path" => "test.0000111",
|
44
|
+
"type" => 'var',
|
45
|
+
"flags" => "COLUMN_SCALAR|COMPRESS_NONE|PERSISTENT",
|
46
|
+
"domain" => "Story",
|
47
|
+
"range" => "ShortText",
|
48
|
+
'source' => []
|
49
|
+
})
|
50
|
+
column_list.select{|row| row[:name] == "Story.title"}.should == [ expect_mash ]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should parse table_list result" do
|
54
|
+
raw_value = JSON.parse '[[0,1270197916.25107,0.000215],[[["id", "UInt32"],["name","ShortText"],["path","ShortText"],["flags","ShortText"],["domain", "ShortText"],["range","ShortText"]],[259,"DMGTerms","test.0000103","TABLE_PAT_KEY|KEY_NORMALIZE|PERSISTENT","ShortText","null"],[267,"Image","test.000010B","TABLE_HASH_KEY|PERSISTENT","Int32","null"],[261,"Photo","test.0000105","TABLE_HASH_KEY|PERSISTENT","ShortText","null"],[271,"Story","test.000010F","TABLE_HASH_KEY|PERSISTENT","Int32","null"],[256,"User","test.0000100","TABLE_HASH_KEY|PERSISTENT","Int32","null"]]]'
|
55
|
+
|
56
|
+
table_list = DataMapper::Adapters::GroongaResult::List.new raw_value
|
57
|
+
|
58
|
+
table_list.success?.should == true
|
59
|
+
table_list.err_code.should == 0
|
60
|
+
table_list.err_msg.should == nil
|
61
|
+
table_list.start_time.should == 1270197916.25107
|
62
|
+
table_list.elapsed_time == 0.000215
|
63
|
+
|
64
|
+
table_list.map{|row| row[:name] }.should == [ 'DMGTerms', 'Image', 'Photo', 'Story', 'User' ]
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should parse select result" do
|
68
|
+
raw_value = JSON.parse '[[0,1270198116.95839,0.000182],[[[2],[["_id","UInt32"],["_key","ShortText"],["uuid","ShortText"],["happy","Bool"],["description","ShortText"]],[1,"2693a46f-ed73-4200-895c-211a49152077","2693a46f-ed73-4200-895c-211a49152077",true,"null"],[2,"93df38eb-c834-4ec3-9949-72c72760ceb7","93df38eb-c834-4ec3-9949-72c72760ceb7",true,"null"]]]]'
|
69
|
+
table_list = DataMapper::Adapters::GroongaResult::List.new raw_value
|
70
|
+
table_list.size.should == 2
|
71
|
+
table_list.map{|row| row[:happy] }.should == [true, true]
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should parse load result" do
|
75
|
+
raw_value = JSON.parse '[[0,1270199923.22467,5.2e-05],1]'
|
76
|
+
res = DataMapper::Adapters::GroongaResult::Count.new raw_value
|
77
|
+
res.count.should == 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
__END__
|
82
|
+
|
83
|
+
table_list
|
84
|
+
[
|
85
|
+
[["id", "UInt32"],["name","ShortText"],["path","ShortText"],["flags","ShortText"],["domain", "ShortText"],["range","ShortText"]],
|
86
|
+
[259,"DMGTerms","test.0000103","TABLE_PAT_KEY|KEY_NORMALIZE|PERSISTENT","ShortText","null"],
|
87
|
+
[267,"Image","test.000010B","TABLE_HASH_KEY|PERSISTENT","Int32","null"],
|
88
|
+
[261,"Photo","test.0000105","TABLE_HASH_KEY|PERSISTENT","ShortText","null"],
|
89
|
+
[271,"Story","test.000010F","TABLE_HASH_KEY|PERSISTENT","Int32","null"],
|
90
|
+
[256,"User","test.0000100","TABLE_HASH_KEY|PERSISTENT","Int32","null"]]
|
91
|
+
]
|
92
|
+
select Photo
|
93
|
+
[
|
94
|
+
[
|
95
|
+
[2],
|
96
|
+
[["_id","UInt32"],["_key","ShortText"],["uuid","ShortText"],["happy","Bool"],["description","ShortText"]],
|
97
|
+
[1,"2693a46f-ed73-4200-895c-211a49152077","2693a46f-ed73-4200-895c-211a49152077",true,"null"],
|
98
|
+
[2,"93df38eb-c834-4ec3-9949-72c72760ceb7","93df38eb-c834-4ec3-9949-72c72760ceb7",true,"null"]
|
99
|
+
]
|
100
|
+
]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "local_index search" do
|
4
|
+
def index_path;local_groonga_path;end
|
5
|
+
|
6
|
+
after(:all) do
|
7
|
+
Pathname.new(index_path).parent.children.each do |f|
|
8
|
+
f.delete
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
# remove indeces before running spec.
|
14
|
+
Pathname.new(index_path).parent.children.each do |f|
|
15
|
+
f.delete
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it_should_behave_like "as is_search plugin"
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "remote_index search" do
|
23
|
+
def index_path;remote_groonga_path;end
|
24
|
+
it_should_behave_like "as is_search plugin"
|
25
|
+
end
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dm-groonga-adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- pre
|
10
|
+
version: 0.1.0.pre
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- hiroyuki
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-04-08 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: groonga
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 9
|
31
|
+
version: "0.9"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: dm-core
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 10
|
44
|
+
- 2
|
45
|
+
version: 0.10.2
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: dm-more
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
- 10
|
58
|
+
- 2
|
59
|
+
version: 0.10.2
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 2
|
72
|
+
- 9
|
73
|
+
version: 1.2.9
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rcov
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id005
|
88
|
+
description: datamapper adapter for groonga search engine
|
89
|
+
email: hello@hryk.info
|
90
|
+
executables: []
|
91
|
+
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files:
|
95
|
+
- LICENSE
|
96
|
+
- README.rdoc
|
97
|
+
files:
|
98
|
+
- .document
|
99
|
+
- .gitignore
|
100
|
+
- LICENSE
|
101
|
+
- README.rdoc
|
102
|
+
- Rakefile
|
103
|
+
- VERSION.yml
|
104
|
+
- dm-groonga-adapter.gemspec
|
105
|
+
- examples/basic.rb
|
106
|
+
- lib/groonga_adapter.rb
|
107
|
+
- lib/groonga_adapter/adapter.rb
|
108
|
+
- lib/groonga_adapter/local_index.rb
|
109
|
+
- lib/groonga_adapter/model_ext.rb
|
110
|
+
- lib/groonga_adapter/remote_index.rb
|
111
|
+
- lib/groonga_adapter/remote_result.rb
|
112
|
+
- lib/groonga_adapter/repository_ext.rb
|
113
|
+
- lib/groonga_adapter/unicode_ext.rb
|
114
|
+
- spec/rcov.opts
|
115
|
+
- spec/shared/adapter_example.rb
|
116
|
+
- spec/shared/search_example.rb
|
117
|
+
- spec/spec.opts
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
- spec/specs/adapter_spec.rb
|
120
|
+
- spec/specs/remote_result_spec.rb
|
121
|
+
- spec/specs/search_spec.rb
|
122
|
+
has_rdoc: true
|
123
|
+
homepage: http://github.com/hryk/dm-groonga-adapter
|
124
|
+
licenses: []
|
125
|
+
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options:
|
128
|
+
- --charset=UTF-8
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
version: "0"
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
segments:
|
143
|
+
- 1
|
144
|
+
- 3
|
145
|
+
- 1
|
146
|
+
version: 1.3.1
|
147
|
+
requirements: []
|
148
|
+
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.3.6
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: datamapper adapter for groonga search engine
|
154
|
+
test_files:
|
155
|
+
- spec/shared/adapter_example.rb
|
156
|
+
- spec/shared/search_example.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
- spec/specs/adapter_spec.rb
|
159
|
+
- spec/specs/remote_result_spec.rb
|
160
|
+
- spec/specs/search_spec.rb
|
161
|
+
- examples/basic.rb
|