rroonga 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/NEWS.ja.rdoc +29 -0
  2. data/NEWS.rdoc +29 -0
  3. data/Rakefile +5 -3
  4. data/ext/groonga/rb-grn-array.c +1 -1
  5. data/ext/groonga/rb-grn-context.c +15 -28
  6. data/ext/groonga/rb-grn-exception.c +46 -1
  7. data/ext/groonga/rb-grn-expression.c +22 -13
  8. data/ext/groonga/rb-grn-fix-size-column.c +2 -8
  9. data/ext/groonga/rb-grn-hash.c +8 -1
  10. data/ext/groonga/rb-grn-object.c +1 -1
  11. data/ext/groonga/rb-grn-patricia-trie.c +23 -1
  12. data/ext/groonga/rb-grn-table-key-support.c +22 -0
  13. data/ext/groonga/rb-grn-table.c +37 -5
  14. data/ext/groonga/rb-grn-utils.c +20 -2
  15. data/ext/groonga/rb-groonga.c +76 -38
  16. data/extconf.rb +17 -1
  17. data/html/developer.html +32 -7
  18. data/html/footer.html.erb +5 -0
  19. data/html/heading-mark.svg +393 -0
  20. data/html/index.html +33 -3
  21. data/lib/groonga.rb +3 -7
  22. data/lib/groonga/context.rb +2 -13
  23. data/lib/groonga/expression-builder.rb +273 -67
  24. data/lib/groonga/pagination.rb +143 -0
  25. data/lib/groonga/record.rb +2 -0
  26. data/lib/groonga/schema.rb +140 -29
  27. data/rroonga-build.rb +2 -2
  28. data/test-unit/Rakefile +40 -0
  29. data/test-unit/TODO +5 -0
  30. data/test-unit/bin/testrb +5 -0
  31. data/test-unit/html/classic.html +15 -0
  32. data/test-unit/html/index.html +25 -0
  33. data/test-unit/html/index.html.ja +27 -0
  34. data/test-unit/lib/test/unit.rb +323 -0
  35. data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
  36. data/test-unit/lib/test/unit/assertions.rb +1230 -0
  37. data/test-unit/lib/test/unit/attribute.rb +125 -0
  38. data/test-unit/lib/test/unit/autorunner.rb +360 -0
  39. data/test-unit/lib/test/unit/collector.rb +36 -0
  40. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  41. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  42. data/test-unit/lib/test/unit/collector/load.rb +144 -0
  43. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  44. data/test-unit/lib/test/unit/color-scheme.rb +102 -0
  45. data/test-unit/lib/test/unit/color.rb +96 -0
  46. data/test-unit/lib/test/unit/diff.rb +724 -0
  47. data/test-unit/lib/test/unit/error.rb +130 -0
  48. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  49. data/test-unit/lib/test/unit/failure.rb +136 -0
  50. data/test-unit/lib/test/unit/fixture.rb +176 -0
  51. data/test-unit/lib/test/unit/notification.rb +129 -0
  52. data/test-unit/lib/test/unit/omission.rb +191 -0
  53. data/test-unit/lib/test/unit/pending.rb +150 -0
  54. data/test-unit/lib/test/unit/priority.rb +180 -0
  55. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  56. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  57. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  58. data/test-unit/lib/test/unit/testcase.rb +476 -0
  59. data/test-unit/lib/test/unit/testresult.rb +89 -0
  60. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  61. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  62. data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
  63. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
  64. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
  65. data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
  66. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  67. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  68. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  69. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  70. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  71. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  72. data/test-unit/lib/test/unit/version.rb +7 -0
  73. data/test-unit/sample/adder.rb +13 -0
  74. data/test-unit/sample/subtracter.rb +12 -0
  75. data/test-unit/sample/test_adder.rb +20 -0
  76. data/test-unit/sample/test_subtracter.rb +20 -0
  77. data/test-unit/sample/test_user.rb +23 -0
  78. data/test-unit/test/collector/test-descendant.rb +133 -0
  79. data/test-unit/test/collector/test-load.rb +442 -0
  80. data/test-unit/test/collector/test_dir.rb +406 -0
  81. data/test-unit/test/collector/test_objectspace.rb +100 -0
  82. data/test-unit/test/run-test.rb +15 -0
  83. data/test-unit/test/test-attribute.rb +86 -0
  84. data/test-unit/test/test-color-scheme.rb +67 -0
  85. data/test-unit/test/test-color.rb +47 -0
  86. data/test-unit/test/test-diff.rb +518 -0
  87. data/test-unit/test/test-emacs-runner.rb +60 -0
  88. data/test-unit/test/test-fixture.rb +287 -0
  89. data/test-unit/test/test-notification.rb +33 -0
  90. data/test-unit/test/test-omission.rb +81 -0
  91. data/test-unit/test/test-pending.rb +70 -0
  92. data/test-unit/test/test-priority.rb +119 -0
  93. data/test-unit/test/test-testcase.rb +544 -0
  94. data/test-unit/test/test_assertions.rb +1151 -0
  95. data/test-unit/test/test_error.rb +26 -0
  96. data/test-unit/test/test_failure.rb +33 -0
  97. data/test-unit/test/test_testresult.rb +113 -0
  98. data/test-unit/test/test_testsuite.rb +129 -0
  99. data/test-unit/test/testunit-test-util.rb +14 -0
  100. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  101. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  102. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  103. data/test-unit/test/util/test_observable.rb +102 -0
  104. data/test-unit/test/util/test_procwrapper.rb +36 -0
  105. data/test/groonga-test-utils.rb +3 -2
  106. data/test/run-test.rb +14 -2
  107. data/test/test-column.rb +7 -7
  108. data/test/test-context-select.rb +34 -11
  109. data/test/test-exception.rb +3 -0
  110. data/test/test-expression-builder.rb +11 -0
  111. data/test/test-expression.rb +3 -6
  112. data/test/test-gqtp.rb +3 -5
  113. data/test/test-pagination.rb +249 -0
  114. data/test/test-record.rb +36 -8
  115. data/test/test-remote.rb +11 -4
  116. data/test/test-schema-create-table.rb +251 -0
  117. data/test/test-schema.rb +4 -24
  118. data/test/test-table-offset-and-limit.rb +3 -5
  119. data/test/test-table-select-mecab.rb +80 -0
  120. data/test/test-table-select-weight.rb +104 -0
  121. data/test/test-table.rb +22 -4
  122. data/test/test-version.rb +1 -1
  123. data/text/TUTORIAL.ja.rdoc +2 -0
  124. data/text/expression.rdoc +1 -0
  125. metadata +96 -35
@@ -0,0 +1,104 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ class TableSelectWeightTest < Test::Unit::TestCase
19
+ include GroongaTestUtils
20
+
21
+ setup :setup_database
22
+
23
+ setup
24
+ def setup_tables
25
+ Groonga::Schema.define do |schema|
26
+ schema.create_table("Users",
27
+ :type => :hash,
28
+ :key_type => "ShortText") do |table|
29
+ end
30
+
31
+ schema.create_table("Comments") do |table|
32
+ table.short_text("title")
33
+ table.text("content")
34
+ table.time("created_at")
35
+ table.reference("user", "Users")
36
+ end
37
+
38
+ schema.create_table("Terms",
39
+ :type => :patricia_trie,
40
+ :default_tokenizer => "TokenBigram") do |table|
41
+ table.index("Comments.title", :with_section => true)
42
+ table.index("Comments.content", :with_section => true)
43
+ end
44
+
45
+ schema.change_table("Users") do |table|
46
+ table.index("Comments.user")
47
+ end
48
+ end
49
+ end
50
+
51
+ setup
52
+ def setup_comments
53
+ @comments = context["Comments"]
54
+ @hello = @comments.add(:title => "Hello",
55
+ :content => "Hello Good-bye!",
56
+ :created_at => Time.parse("2009-08-09"),
57
+ :user => "morita")
58
+ @hello_only_in_content =
59
+ @comments.add(:title => "(no title)",
60
+ :content => "Hello! Hello! Hello!",
61
+ :created_at => Time.parse("2009-07-09"))
62
+ @test = @comments.add(:title => "title",
63
+ :content => "test",
64
+ :created_at => Time.parse("2009-06-09"),
65
+ :user => "gunyara-kun")
66
+ @japanese =
67
+ @comments.add(:title => "日本語",
68
+ :content => "うちのボロTVはまだ現役です",
69
+ :created_at => Time.parse("2009-06-09"),
70
+ :user => "darashi")
71
+ end
72
+
73
+ def test_full_text_search
74
+ result = @comments.select do |record|
75
+ record.match("Hello") do |match_record|
76
+ (match_record.title * 100) |
77
+ match_record.content
78
+ end
79
+ end
80
+ assert_equal_select_result([["Hello", 101], ["(no title)", 3]],
81
+ result) do |record|
82
+ [record.title, record.score]
83
+ end
84
+ end
85
+
86
+ def test_reference
87
+ result = @comments.select do |record|
88
+ full_text_match = record.match("Hello") do |match_record|
89
+ (match_record.title * 100) |
90
+ match_record.content
91
+ end
92
+ reference_match = record.match("darashi") do |match_record|
93
+ match_record.user * 1000
94
+ end
95
+ full_text_match | reference_match
96
+ end
97
+ assert_equal_select_result([["Hello", 101],
98
+ ["(no title)", 3],
99
+ ["日本語", 1000]],
100
+ result) do |record|
101
+ [record.title, record.score]
102
+ end
103
+ end
104
+ end
data/test/test-table.rb CHANGED
@@ -46,15 +46,17 @@ class TableTest < Test::Unit::TestCase
46
46
 
47
47
  def test_temporary_table_define_column_default_persistent
48
48
  table = Groonga::Hash.create
49
- name = table.define_column("name", "ShortText")
50
- assert_predicate(name, :temporary?)
49
+ assert_raise(Groonga::InvalidArgument) do
50
+ table.define_column("name", "ShortText")
51
+ end
51
52
  end
52
53
 
53
54
  def test_temporary_table_define_index_column_default_persistent
54
55
  bookmarks = Groonga::Hash.create(:name => "Bookmarks")
55
56
  terms = Groonga::Hash.create
56
- url = terms.define_index_column("url", bookmarks)
57
- assert_predicate(url, :temporary?)
57
+ assert_raise(Groonga::InvalidArgument) do
58
+ terms.define_index_column("url", bookmarks)
59
+ end
58
60
  end
59
61
 
60
62
  def test_define_column_default_persistent
@@ -430,6 +432,22 @@ class TableTest < Test::Unit::TestCase
430
432
  bookmark["title"],
431
433
  bookmark.key]
432
434
  end)
435
+ assert_equal([[2, "groonga", "http://groonga.org/"],
436
+ [1, "Ruby", "http://ruby-lang.org/"]],
437
+ records.group(%w".bookmark").collect do |record|
438
+ bookmark = record.key
439
+ [record.n_sub_records,
440
+ bookmark["title"],
441
+ bookmark.key]
442
+ end)
443
+ end
444
+
445
+ def test_group_with_unknown_key
446
+ bookmarks = Groonga::Hash.create(:name => "Bookmarks")
447
+ message = "unknown group key: <\"nonexistent\">: <#{bookmarks.inspect}>"
448
+ assert_raise(ArgumentError.new(message)) do
449
+ bookmarks.group("nonexistent")
450
+ end
433
451
  end
434
452
 
435
453
  def test_union!
data/test/test-version.rb CHANGED
@@ -20,7 +20,7 @@ class VersionTest < Test::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_version
23
- assert_match(/\A\d+\.\d+\.\d+\z/, Groonga.version)
23
+ assert_match(/\A\d+\.\d+\.\d+(?:\.\d+-[a-zA-Z\d]+)?\z/, Groonga.version)
24
24
  assert_match(Groonga.version, Groonga::VERSION.join("."))
25
25
  end
26
26
 
@@ -1,3 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  = チュートリアル
2
4
 
3
5
  このページでは簡単なアプリケーションの作成を通して
data/text/expression.rdoc CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
 
2
3
  = grn式 (grn_expr)
3
4
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 49
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 9
8
- - 4
9
- version: 0.9.4
9
+ - 5
10
+ version: 0.9.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Kouhei Sutou
@@ -18,37 +19,10 @@ autorequire:
18
19
  bindir: bin
19
20
  cert_chain: []
20
21
 
21
- date: 2010-04-22 00:00:00 +09:00
22
+ date: 2010-07-29 00:00:00 +09:00
22
23
  default_executable:
23
- dependencies:
24
- - !ruby/object:Gem::Dependency
25
- name: rubyforge
26
- prerelease: false
27
- requirement: &id001 !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- segments:
32
- - 2
33
- - 0
34
- - 4
35
- version: 2.0.4
36
- type: :development
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: gemcutter
40
- prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- segments:
46
- - 0
47
- - 5
48
- - 0
49
- version: 0.5.0
50
- type: :development
51
- version_requirements: *id002
24
+ dependencies: []
25
+
52
26
  description: |-
53
27
  rroonga is a extension library to use groonga's DB-API
54
28
  layer. rroonga provides Rubyish readable and writable
@@ -62,11 +36,11 @@ executables: []
62
36
  extensions:
63
37
  - extconf.rb
64
38
  extra_rdoc_files:
65
- - README.rdoc
39
+ - README.ja.rdoc
66
40
  - NEWS.ja.rdoc
67
41
  - text/TUTORIAL.ja.rdoc
68
42
  - text/expression.rdoc
69
- - README.ja.rdoc
43
+ - README.rdoc
70
44
  - NEWS.rdoc
71
45
  files:
72
46
  - AUTHORS
@@ -132,6 +106,7 @@ files:
132
106
  - html/footer.html.erb
133
107
  - html/head.html.erb
134
108
  - html/header.html.erb
109
+ - html/heading-mark.svg
135
110
  - html/index.html
136
111
  - html/install.svg
137
112
  - html/logo.xcf
@@ -140,6 +115,7 @@ files:
140
115
  - lib/groonga.rb
141
116
  - lib/groonga/context.rb
142
117
  - lib/groonga/expression-builder.rb
118
+ - lib/groonga/pagination.rb
143
119
  - lib/groonga/patricia-trie.rb
144
120
  - lib/groonga/record.rb
145
121
  - lib/groonga/schema.rb
@@ -150,6 +126,83 @@ files:
150
126
  - misc/grnop2ruby.rb
151
127
  - pkg-config.rb
152
128
  - rroonga-build.rb
129
+ - test-unit/Rakefile
130
+ - test-unit/TODO
131
+ - test-unit/bin/testrb
132
+ - test-unit/html/classic.html
133
+ - test-unit/html/index.html
134
+ - test-unit/html/index.html.ja
135
+ - test-unit/lib/test/unit.rb
136
+ - test-unit/lib/test/unit/assertionfailederror.rb
137
+ - test-unit/lib/test/unit/assertions.rb
138
+ - test-unit/lib/test/unit/attribute.rb
139
+ - test-unit/lib/test/unit/autorunner.rb
140
+ - test-unit/lib/test/unit/collector.rb
141
+ - test-unit/lib/test/unit/collector/descendant.rb
142
+ - test-unit/lib/test/unit/collector/dir.rb
143
+ - test-unit/lib/test/unit/collector/load.rb
144
+ - test-unit/lib/test/unit/collector/objectspace.rb
145
+ - test-unit/lib/test/unit/color-scheme.rb
146
+ - test-unit/lib/test/unit/color.rb
147
+ - test-unit/lib/test/unit/diff.rb
148
+ - test-unit/lib/test/unit/error.rb
149
+ - test-unit/lib/test/unit/exceptionhandler.rb
150
+ - test-unit/lib/test/unit/failure.rb
151
+ - test-unit/lib/test/unit/fixture.rb
152
+ - test-unit/lib/test/unit/notification.rb
153
+ - test-unit/lib/test/unit/omission.rb
154
+ - test-unit/lib/test/unit/pending.rb
155
+ - test-unit/lib/test/unit/priority.rb
156
+ - test-unit/lib/test/unit/runner/console.rb
157
+ - test-unit/lib/test/unit/runner/emacs.rb
158
+ - test-unit/lib/test/unit/runner/tap.rb
159
+ - test-unit/lib/test/unit/testcase.rb
160
+ - test-unit/lib/test/unit/testresult.rb
161
+ - test-unit/lib/test/unit/testsuite.rb
162
+ - test-unit/lib/test/unit/ui/console/outputlevel.rb
163
+ - test-unit/lib/test/unit/ui/console/testrunner.rb
164
+ - test-unit/lib/test/unit/ui/emacs/testrunner.rb
165
+ - test-unit/lib/test/unit/ui/tap/testrunner.rb
166
+ - test-unit/lib/test/unit/ui/testrunner.rb
167
+ - test-unit/lib/test/unit/ui/testrunnermediator.rb
168
+ - test-unit/lib/test/unit/ui/testrunnerutilities.rb
169
+ - test-unit/lib/test/unit/util/backtracefilter.rb
170
+ - test-unit/lib/test/unit/util/method-owner-finder.rb
171
+ - test-unit/lib/test/unit/util/observable.rb
172
+ - test-unit/lib/test/unit/util/procwrapper.rb
173
+ - test-unit/lib/test/unit/version.rb
174
+ - test-unit/sample/adder.rb
175
+ - test-unit/sample/subtracter.rb
176
+ - test-unit/sample/test_adder.rb
177
+ - test-unit/sample/test_subtracter.rb
178
+ - test-unit/sample/test_user.rb
179
+ - test-unit/test/collector/test-descendant.rb
180
+ - test-unit/test/collector/test-load.rb
181
+ - test-unit/test/collector/test_dir.rb
182
+ - test-unit/test/collector/test_objectspace.rb
183
+ - test-unit/test/run-test.rb
184
+ - test-unit/test/test-attribute.rb
185
+ - test-unit/test/test-color-scheme.rb
186
+ - test-unit/test/test-color.rb
187
+ - test-unit/test/test-diff.rb
188
+ - test-unit/test/test-emacs-runner.rb
189
+ - test-unit/test/test-fixture.rb
190
+ - test-unit/test/test-notification.rb
191
+ - test-unit/test/test-omission.rb
192
+ - test-unit/test/test-pending.rb
193
+ - test-unit/test/test-priority.rb
194
+ - test-unit/test/test-testcase.rb
195
+ - test-unit/test/test_assertions.rb
196
+ - test-unit/test/test_error.rb
197
+ - test-unit/test/test_failure.rb
198
+ - test-unit/test/test_testresult.rb
199
+ - test-unit/test/test_testsuite.rb
200
+ - test-unit/test/testunit-test-util.rb
201
+ - test-unit/test/ui/test_testrunmediator.rb
202
+ - test-unit/test/util/test-method-owner-finder.rb
203
+ - test-unit/test/util/test_backtracefilter.rb
204
+ - test-unit/test/util/test_observable.rb
205
+ - test-unit/test/util/test_procwrapper.rb
153
206
  - test/.gitignore
154
207
  - test/groonga-test-utils.rb
155
208
  - test/run-test.rb
@@ -167,17 +220,21 @@ files:
167
220
  - test/test-hash.rb
168
221
  - test/test-index-column.rb
169
222
  - test/test-logger.rb
223
+ - test/test-pagination.rb
170
224
  - test/test-patricia-trie.rb
171
225
  - test/test-procedure.rb
172
226
  - test/test-query.rb
173
227
  - test/test-record.rb
174
228
  - test/test-remote.rb
229
+ - test/test-schema-create-table.rb
175
230
  - test/test-schema-view.rb
176
231
  - test/test-schema.rb
177
232
  - test/test-snippet.rb
178
233
  - test/test-table-cursor.rb
179
234
  - test/test-table-offset-and-limit.rb
235
+ - test/test-table-select-mecab.rb
180
236
  - test/test-table-select-normalize.rb
237
+ - test/test-table-select-weight.rb
181
238
  - test/test-table-select.rb
182
239
  - test/test-table.rb
183
240
  - test/test-type.rb
@@ -200,23 +257,27 @@ require_paths:
200
257
  - lib
201
258
  - ext/groonga
202
259
  required_ruby_version: !ruby/object:Gem::Requirement
260
+ none: false
203
261
  requirements:
204
262
  - - ">="
205
263
  - !ruby/object:Gem::Version
264
+ hash: 3
206
265
  segments:
207
266
  - 0
208
267
  version: "0"
209
268
  required_rubygems_version: !ruby/object:Gem::Requirement
269
+ none: false
210
270
  requirements:
211
271
  - - ">="
212
272
  - !ruby/object:Gem::Version
273
+ hash: 3
213
274
  segments:
214
275
  - 0
215
276
  version: "0"
216
277
  requirements: []
217
278
 
218
279
  rubyforge_project: groonga
219
- rubygems_version: 1.3.6
280
+ rubygems_version: 1.3.7
220
281
  signing_key:
221
282
  specification_version: 3
222
283
  summary: Ruby bindings for groonga that provides full text search and column store features.