activegroonga 0.0.2 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.ja.rdoc +4 -0
- data/NEWS.rdoc +4 -0
- data/README.ja.rdoc +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +3 -4
- data/lib/active_groonga.rb +2 -0
- data/lib/active_groonga/base.rb +125 -99
- data/lib/active_groonga/column.rb +9 -0
- data/lib/active_groonga/dynamic_record_expression_builder.rb +40 -0
- data/lib/active_groonga/schema.rb +107 -204
- data/lib/active_groonga/schema_dumper.rb +40 -25
- data/lib/active_groonga/tasks/groonga.rake +2 -0
- data/lib/active_groonga/version.rb +1 -1
- data/rails_generators/index_table_groonga/USAGE +23 -0
- data/rails_generators/index_table_groonga/index_table_groonga_generator.rb +44 -0
- data/rails_generators/index_table_groonga/templates/migration.rb +12 -0
- data/rails_generators/migration_groonga/USAGE +29 -0
- data/rails_generators/migration_groonga/migration_groonga_generator.rb +19 -0
- data/rails_generators/migration_groonga/templates/migration.rb +11 -0
- data/test-unit/Rakefile +6 -1
- data/test-unit/lib/test/unit/autorunner.rb +26 -3
- data/test-unit/lib/test/unit/priority.rb +21 -1
- data/test-unit/lib/test/unit/testcase.rb +101 -36
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +7 -4
- data/test-unit/test/{test_testcase.rb → test-testcase.rb} +30 -1
- data/test-unit/test/test_assertions.rb +1 -1
- data/test/active-groonga-test-utils.rb +25 -26
- data/test/test-base.rb +16 -6
- data/test/test-schema-dumper.rb +48 -0
- data/test/test-schema.rb +20 -4
- data/test/tmp/database/database.groonga +0 -0
- data/test/tmp/database/database.groonga.0000000 +0 -0
- data/test/tmp/database/database.groonga.0000100 +0 -0
- data/test/tmp/database/database.groonga.0000101 +0 -0
- metadata +19 -7
@@ -185,10 +185,13 @@ module Test
|
|
185
185
|
|
186
186
|
def guess_color_availability
|
187
187
|
return false unless @output.tty?
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
case ENV["TERM"]
|
189
|
+
when /term(?:-color)?\z/, "screen"
|
190
|
+
true
|
191
|
+
else
|
192
|
+
return true if ENV["EMACS"] == "t"
|
193
|
+
false
|
194
|
+
end
|
192
195
|
end
|
193
196
|
|
194
197
|
def guess_progress_row_max
|
@@ -6,7 +6,7 @@ require 'test/unit'
|
|
6
6
|
|
7
7
|
module Test
|
8
8
|
module Unit
|
9
|
-
class
|
9
|
+
class TestTestCase < TestCase
|
10
10
|
def test_creation
|
11
11
|
tc = Class.new(TestCase) do
|
12
12
|
def test_with_arguments(arg1, arg2)
|
@@ -468,11 +468,40 @@ module Test
|
|
468
468
|
end
|
469
469
|
end
|
470
470
|
|
471
|
+
def test_defined_order
|
472
|
+
keep_test_order do
|
473
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
474
|
+
def test_z
|
475
|
+
end
|
476
|
+
|
477
|
+
def test_1
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_a
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
assert_equal(["test_1", "test_a", "test_z"],
|
485
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
486
|
+
|
487
|
+
test_case.test_order = :defined
|
488
|
+
assert_equal(["test_z", "test_1", "test_a"],
|
489
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
471
493
|
private
|
472
494
|
def check(message, passed)
|
473
495
|
add_assertion
|
474
496
|
raise AssertionFailedError.new(message) unless passed
|
475
497
|
end
|
498
|
+
|
499
|
+
def keep_test_order
|
500
|
+
order = TestCase.test_order
|
501
|
+
yield
|
502
|
+
ensure
|
503
|
+
TestCase.test_order = order
|
504
|
+
end
|
476
505
|
end
|
477
506
|
end
|
478
507
|
end
|
@@ -428,7 +428,7 @@ EOM
|
|
428
428
|
|
429
429
|
different_error_class = Class.new(StandardError)
|
430
430
|
message = <<-EOM
|
431
|
-
<\#<Class:
|
431
|
+
<\#<Class:[xa-f\\d]+>\\("Error"\\)> exception expected but was
|
432
432
|
Class: <RuntimeError>
|
433
433
|
Message: <"Error">
|
434
434
|
EOM
|
@@ -78,37 +78,39 @@ module ActiveGroongaTestUtils
|
|
78
78
|
|
79
79
|
def setup_users_table
|
80
80
|
@users_path = @tables_dir + "users.groonga"
|
81
|
-
@users = Groonga::Array.create(:name => "
|
82
|
-
:path => @users_path.to_s
|
81
|
+
@users = Groonga::Array.create(:name => "users",
|
82
|
+
:path => @users_path.to_s,
|
83
|
+
:sub_records => true)
|
83
84
|
|
84
85
|
columns_dir = @tables_dir + "users" + "columns"
|
85
86
|
columns_dir.mkpath
|
86
87
|
|
87
88
|
@name_column_path = columns_dir + "name.groonga"
|
88
|
-
@name_column = @users.define_column("name", "
|
89
|
+
@name_column = @users.define_column("name", "ShortText",
|
89
90
|
:path => @name_column_path.to_s)
|
90
91
|
end
|
91
92
|
|
92
93
|
def setup_bookmarks_table
|
93
94
|
@bookmarks_path = @tables_dir + "bookmarks.groonga"
|
94
|
-
@bookmarks = Groonga::Array.create(:name => "
|
95
|
-
:path => @bookmarks_path.to_s
|
95
|
+
@bookmarks = Groonga::Array.create(:name => "bookmarks",
|
96
|
+
:path => @bookmarks_path.to_s,
|
97
|
+
:sub_records => true)
|
96
98
|
|
97
99
|
columns_dir = @tables_dir + "bookmarks" + "columns"
|
98
100
|
columns_dir.mkpath
|
99
101
|
|
100
102
|
@uri_column_path = columns_dir + "uri.groonga"
|
101
|
-
@uri_column = @bookmarks.define_column("uri", "
|
103
|
+
@uri_column = @bookmarks.define_column("uri", "ShortText",
|
102
104
|
:path => @uri_column_path.to_s)
|
103
105
|
|
104
106
|
@comment_column_path = columns_dir + "comment.groonga"
|
105
107
|
@comment_column =
|
106
|
-
@bookmarks.define_column("comment", "
|
108
|
+
@bookmarks.define_column("comment", "Text",
|
107
109
|
:path => @comment_column_path.to_s)
|
108
110
|
|
109
111
|
@content_column_path = columns_dir + "content.groonga"
|
110
112
|
@content_column =
|
111
|
-
@bookmarks.define_column("content", "
|
113
|
+
@bookmarks.define_column("content", "LongText",
|
112
114
|
:path => @content_column_path.to_s)
|
113
115
|
|
114
116
|
@user_column_path = columns_dir + "user.groonga"
|
@@ -121,51 +123,48 @@ module ActiveGroongaTestUtils
|
|
121
123
|
|
122
124
|
def define_timestamp(table, columns_dir)
|
123
125
|
created_at_column_path = columns_dir + "created_at.groonga"
|
124
|
-
table.define_column("created_at", "
|
126
|
+
table.define_column("created_at", "Time",
|
125
127
|
:path => created_at_column_path.to_s)
|
126
128
|
|
127
129
|
updated_at_column_path = columns_dir + "updated_at.groonga"
|
128
|
-
table.define_column("updated_at", "
|
130
|
+
table.define_column("updated_at", "Time",
|
129
131
|
:path => updated_at_column_path.to_s)
|
130
132
|
end
|
131
133
|
|
132
134
|
def setup_bookmarks_index_tables
|
133
|
-
@
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
135
|
+
@terms_path = @tables_dir + "terms.groonga"
|
136
|
+
@terms = Groonga::PatriciaTrie.create(:name => "terms",
|
137
|
+
:key_type => "ShortText",
|
138
|
+
:path => @terms_path.to_s,
|
139
|
+
:default_tokenizer => "TokenBigram")
|
140
|
+
|
141
|
+
columns_dir = @tables_dir + "terms" + "columns"
|
142
|
+
bookmarks_index_dir = columns_dir + "bookmarks"
|
140
143
|
bookmarks_index_dir.mkpath
|
141
144
|
|
142
145
|
@bookmarks_content_index_column_path =
|
143
146
|
bookmarks_index_dir + "content.groonga"
|
144
147
|
path = @bookmarks_content_index_column_path.to_s
|
145
148
|
@bookmarks_content_index_column =
|
146
|
-
@
|
149
|
+
@terms.define_index_column("bookmarks/content", @bookmarks,
|
147
150
|
:with_section => true,
|
148
151
|
:with_weight => true,
|
149
152
|
:with_position => true,
|
150
153
|
:path => path)
|
151
154
|
@bookmarks_content_index_column.source = @content_column
|
152
|
-
|
153
|
-
record = ActiveGroonga::Schema.index_management_table.add
|
154
|
-
record["table"] = @bookmarks.name
|
155
|
-
record["column"] = "content"
|
156
|
-
record["index"] = @index.name
|
157
155
|
end
|
158
156
|
|
159
157
|
def setup_tasks_table
|
160
158
|
@tasks_path = @tables_dir + "tasks.groonga"
|
161
|
-
@tasks = Groonga::Array.create(:name => "
|
162
|
-
:path => @tasks_path.to_s
|
159
|
+
@tasks = Groonga::Array.create(:name => "tasks",
|
160
|
+
:path => @tasks_path.to_s,
|
161
|
+
:sub_records => true)
|
163
162
|
|
164
163
|
columns_dir = @tables_dir + "tasks" + "columns"
|
165
164
|
columns_dir.mkpath
|
166
165
|
|
167
166
|
@name_column_path = columns_dir + "name.groonga"
|
168
|
-
@name_column = @tasks.define_column("name", "
|
167
|
+
@name_column = @tasks.define_column("name", "ShortText",
|
169
168
|
:path => @name_column_path.to_s)
|
170
169
|
end
|
171
170
|
|
data/test/test-base.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
16
16
|
|
17
|
-
class
|
17
|
+
class TestBase < Test::Unit::TestCase
|
18
18
|
include ActiveGroongaTestUtils
|
19
19
|
|
20
20
|
def test_find
|
@@ -128,16 +128,16 @@ class BaseTest < Test::Unit::TestCase
|
|
128
128
|
}
|
129
129
|
google.save!
|
130
130
|
|
131
|
-
bookmarks = Bookmark.
|
131
|
+
bookmarks = Bookmark.find(:all) {|record| record["content"] =~ "Google"}
|
132
132
|
assert_equal([google], bookmarks)
|
133
133
|
|
134
134
|
google.content = "<html><body>...Empty...</body></html>"
|
135
135
|
google.save!
|
136
136
|
|
137
|
-
bookmarks = Bookmark.
|
137
|
+
bookmarks = Bookmark.find(:all) {|record| record["content"] =~ "Google"}
|
138
138
|
assert_equal([], bookmarks)
|
139
139
|
|
140
|
-
bookmarks = Bookmark.
|
140
|
+
bookmarks = Bookmark.find(:all) {|record| record["content"] =~ "Empty"}
|
141
141
|
assert_equal([google], bookmarks)
|
142
142
|
end
|
143
143
|
|
@@ -167,8 +167,8 @@ class BaseTest < Test::Unit::TestCase
|
|
167
167
|
"comment" => "a search engine",
|
168
168
|
"content" => "<html><body>...Google...</body></html>")
|
169
169
|
|
170
|
-
|
171
|
-
|
170
|
+
assert_equal([google],
|
171
|
+
Bookmark.find(:all) {|record| record["content"] =~ "Google"})
|
172
172
|
end
|
173
173
|
|
174
174
|
def test_find_by_model
|
@@ -191,4 +191,14 @@ class BaseTest < Test::Unit::TestCase
|
|
191
191
|
groonga.reload
|
192
192
|
assert_equal("fulltext search engine", groonga.comment)
|
193
193
|
end
|
194
|
+
|
195
|
+
def test_find_column_access_by_method
|
196
|
+
google = Bookmark.create("uri" => "http://google.com/",
|
197
|
+
"comment" => "a search engine",
|
198
|
+
"content" => "<html><body>Google</body></html>")
|
199
|
+
|
200
|
+
|
201
|
+
assert_equal([google],
|
202
|
+
Bookmark.find(:all) {|record| record.content =~ "Google"})
|
203
|
+
end
|
194
204
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
16
|
+
|
17
|
+
class TestSchemaDumper < Test::Unit::TestCase
|
18
|
+
include ActiveGroongaTestUtils
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@output = StringIO.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_dump
|
25
|
+
ActiveGroonga::SchemaDumper.dump(@output)
|
26
|
+
assert_equal(<<-EOS, @output.string.gsub(/^\s*(?:#.*)?\n/, ''))
|
27
|
+
ActiveGroonga::Schema.define(:version => 0) do
|
28
|
+
create_table "bookmarks", :force => true do |t|
|
29
|
+
t.string "uri"
|
30
|
+
t.time "updated_at"
|
31
|
+
t.time "created_at"
|
32
|
+
t.text "content"
|
33
|
+
t.text "comment"
|
34
|
+
end
|
35
|
+
create_table "tasks", :force => true do |t|
|
36
|
+
t.string "name"
|
37
|
+
end
|
38
|
+
create_table "terms", :force => true, :type => :patricia_trie, :key_type => "ShortText", :default_tokenizer => "TokenBigram" do |t|
|
39
|
+
end
|
40
|
+
create_table "users", :force => true do |t|
|
41
|
+
t.string "name"
|
42
|
+
end
|
43
|
+
add_column "bookmarks", "user", "users"
|
44
|
+
add_index_column "terms", "bookmarks", "content", :name => "bookmarks/content"
|
45
|
+
end
|
46
|
+
EOS
|
47
|
+
end
|
48
|
+
end
|
data/test/test-schema.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# License along with this library; if not, write to the Free Software
|
15
15
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
16
16
|
|
17
|
-
class
|
17
|
+
class TestSchema < Test::Unit::TestCase
|
18
18
|
include ActiveGroongaTestUtils
|
19
19
|
|
20
20
|
def test_create_table
|
@@ -34,14 +34,30 @@ class SchemaTest < Test::Unit::TestCase
|
|
34
34
|
assert_predicate(column_file, :exist?)
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_reference_column
|
38
|
+
ActiveGroonga::Schema.create_table(:categories) do |table|
|
39
|
+
table.string :name
|
40
|
+
end
|
41
|
+
|
42
|
+
column_file = @tables_dir + "posts" + "columns" + "category.groonga"
|
43
|
+
assert_not_predicate(column_file, :exist?)
|
44
|
+
ActiveGroonga::Schema.create_table(:posts) do |table|
|
45
|
+
table.reference :category
|
46
|
+
end
|
47
|
+
assert_predicate(column_file, :exist?)
|
48
|
+
end
|
49
|
+
|
37
50
|
def test_add_index
|
38
|
-
|
39
|
-
index_file =
|
51
|
+
columns_dir = @tables_dir + "words" + "columns" + "posts"
|
52
|
+
index_file = columns_dir + "posts_content.groonga"
|
40
53
|
assert_not_predicate(index_file, :exist?)
|
41
54
|
|
42
55
|
ActiveGroonga::Schema.create_table(:posts) do |table|
|
43
56
|
table.string :content
|
44
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
ActiveGroonga::Schema.create_table(:words) do |table|
|
60
|
+
table.index :posts, :content
|
45
61
|
end
|
46
62
|
|
47
63
|
assert_predicate(index_file, :exist?)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activegroonga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-01 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.6
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
@@ -44,10 +44,10 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
|
46
46
|
extra_rdoc_files:
|
47
|
-
- NEWS.ja.rdoc
|
48
|
-
- NEWS.rdoc
|
49
47
|
- README.rdoc
|
48
|
+
- NEWS.ja.rdoc
|
50
49
|
- README.ja.rdoc
|
50
|
+
- NEWS.rdoc
|
51
51
|
files:
|
52
52
|
- AUTHORS
|
53
53
|
- NEWS.ja.rdoc
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/active_groonga/base.rb
|
64
64
|
- lib/active_groonga/column.rb
|
65
65
|
- lib/active_groonga/dirty.rb
|
66
|
+
- lib/active_groonga/dynamic_record_expression_builder.rb
|
66
67
|
- lib/active_groonga/fixtures.rb
|
67
68
|
- lib/active_groonga/migration.rb
|
68
69
|
- lib/active_groonga/rails_support.rb
|
@@ -79,6 +80,12 @@ files:
|
|
79
80
|
- license/LGPL
|
80
81
|
- rails/README
|
81
82
|
- rails/init.rb
|
83
|
+
- rails_generators/index_table_groonga/USAGE
|
84
|
+
- rails_generators/index_table_groonga/index_table_groonga_generator.rb
|
85
|
+
- rails_generators/index_table_groonga/templates/migration.rb
|
86
|
+
- rails_generators/migration_groonga/USAGE
|
87
|
+
- rails_generators/migration_groonga/migration_groonga_generator.rb
|
88
|
+
- rails_generators/migration_groonga/templates/migration.rb
|
82
89
|
- rails_generators/model_groonga/USAGE
|
83
90
|
- rails_generators/model_groonga/model_groonga_generator.rb
|
84
91
|
- rails_generators/model_groonga/templates/fixtures.yml
|
@@ -149,10 +156,10 @@ files:
|
|
149
156
|
- test-unit/test/test-omission.rb
|
150
157
|
- test-unit/test/test-pending.rb
|
151
158
|
- test-unit/test/test-priority.rb
|
159
|
+
- test-unit/test/test-testcase.rb
|
152
160
|
- test-unit/test/test_assertions.rb
|
153
161
|
- test-unit/test/test_error.rb
|
154
162
|
- test-unit/test/test_failure.rb
|
155
|
-
- test-unit/test/test_testcase.rb
|
156
163
|
- test-unit/test/test_testresult.rb
|
157
164
|
- test-unit/test/test_testsuite.rb
|
158
165
|
- test-unit/test/testunit-test-util.rb
|
@@ -168,7 +175,12 @@ files:
|
|
168
175
|
- test/run-test.rb
|
169
176
|
- test/test-associations.rb
|
170
177
|
- test/test-base.rb
|
178
|
+
- test/test-schema-dumper.rb
|
171
179
|
- test/test-schema.rb
|
180
|
+
- test/tmp/database/database.groonga
|
181
|
+
- test/tmp/database/database.groonga.0000000
|
182
|
+
- test/tmp/database/database.groonga.0000100
|
183
|
+
- test/tmp/database/database.groonga.0000101
|
172
184
|
has_rdoc: true
|
173
185
|
homepage: http://groonga.rubyforge.org/
|
174
186
|
licenses: []
|
@@ -194,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
206
|
requirements: []
|
195
207
|
|
196
208
|
rubyforge_project: groonga
|
197
|
-
rubygems_version: 1.3.
|
209
|
+
rubygems_version: 1.3.4
|
198
210
|
signing_key:
|
199
211
|
specification_version: 3
|
200
212
|
summary: A library to use groonga with ActiveRecord like API.
|