rroonga 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/README.textile +71 -0
  2. data/Rakefile +213 -128
  3. data/TODO +0 -0
  4. data/example/bookmark.rb +12 -12
  5. data/ext/groonga/Makefile +233 -0
  6. data/ext/groonga/extconf.rb +1 -1
  7. data/ext/groonga/rb-grn-column.c +5 -5
  8. data/ext/groonga/rb-grn-index-column.c +31 -0
  9. data/ext/groonga/rb-grn-index-cursor.c +106 -0
  10. data/ext/groonga/rb-grn-logger.c +5 -5
  11. data/ext/groonga/rb-grn-object.c +48 -0
  12. data/ext/groonga/rb-grn-patricia-trie.c +1 -1
  13. data/ext/groonga/rb-grn-plugin.c +32 -0
  14. data/ext/groonga/rb-grn-posting.c +51 -0
  15. data/ext/groonga/rb-grn-table-cursor.c +6 -1
  16. data/ext/groonga/rb-grn-table.c +31 -13
  17. data/ext/groonga/rb-grn.h +21 -3
  18. data/ext/groonga/rb-groonga.c +3 -1
  19. data/lib/groonga.rb +1 -0
  20. data/lib/groonga/dumper.rb +25 -5
  21. data/lib/groonga/expression-builder.rb +2 -2
  22. data/lib/groonga/pagination.rb +99 -7
  23. data/lib/groonga/posting.rb +87 -0
  24. data/lib/groonga/record.rb +118 -11
  25. data/lib/groonga/schema.rb +18 -1
  26. data/test/groonga-test-utils.rb +1 -6
  27. data/test/run-test.rb +13 -28
  28. data/test/test-column.rb +4 -0
  29. data/test/test-database-dumper.rb +53 -10
  30. data/test/test-hash.rb +6 -6
  31. data/test/test-index-cursor.rb +93 -0
  32. data/test/test-plugin.rb +6 -0
  33. data/test/test-record.rb +162 -1
  34. data/test/test-schema-type.rb +6 -0
  35. data/test/test-schema.rb +17 -0
  36. data/test/test-table.rb +7 -2
  37. data/test/test-type.rb +9 -1
  38. metadata +135 -245
  39. data/AUTHORS +0 -5
  40. data/NEWS.ja.rdoc +0 -344
  41. data/NEWS.rdoc +0 -346
  42. data/README.ja.rdoc +0 -68
  43. data/README.rdoc +0 -68
  44. data/example/search/config.ru +0 -230
  45. data/example/search/public/css/groonga.css +0 -122
  46. data/ext/.gitignore +0 -2
  47. data/html/bar.svg +0 -153
  48. data/html/developer.html +0 -151
  49. data/html/developer.svg +0 -469
  50. data/html/download.svg +0 -253
  51. data/html/favicon.ico +0 -0
  52. data/html/favicon.svg +0 -591
  53. data/html/footer.html.erb +0 -33
  54. data/html/head.html.erb +0 -4
  55. data/html/header.html.erb +0 -17
  56. data/html/heading-mark.svg +0 -393
  57. data/html/index.html +0 -243
  58. data/html/install.svg +0 -636
  59. data/html/logo.svg +0 -612
  60. data/html/ranguba.css +0 -342
  61. data/html/readme.svg +0 -256
  62. data/html/tutorial.svg +0 -559
  63. data/license/LGPL +0 -504
  64. data/test-unit-notify/Rakefile +0 -47
  65. data/test-unit-notify/lib/test/unit/notify.rb +0 -104
  66. data/test-unit/COPYING +0 -56
  67. data/test-unit/GPL +0 -340
  68. data/test-unit/PSFL +0 -271
  69. data/test-unit/Rakefile +0 -53
  70. data/test-unit/TODO +0 -5
  71. data/test-unit/bin/testrb +0 -5
  72. data/test-unit/html/bar.svg +0 -153
  73. data/test-unit/html/developer.svg +0 -469
  74. data/test-unit/html/favicon.ico +0 -0
  75. data/test-unit/html/favicon.svg +0 -82
  76. data/test-unit/html/heading-mark.svg +0 -393
  77. data/test-unit/html/index.html +0 -247
  78. data/test-unit/html/index.html.ja +0 -270
  79. data/test-unit/html/install.svg +0 -636
  80. data/test-unit/html/logo.svg +0 -483
  81. data/test-unit/html/test-unit.css +0 -339
  82. data/test-unit/html/tutorial.svg +0 -559
  83. data/test-unit/lib/test/unit.rb +0 -328
  84. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  85. data/test-unit/lib/test/unit/assertions.rb +0 -1334
  86. data/test-unit/lib/test/unit/attribute.rb +0 -125
  87. data/test-unit/lib/test/unit/autorunner.rb +0 -363
  88. data/test-unit/lib/test/unit/collector.rb +0 -36
  89. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  90. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  91. data/test-unit/lib/test/unit/collector/load.rb +0 -144
  92. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  93. data/test-unit/lib/test/unit/color-scheme.rb +0 -106
  94. data/test-unit/lib/test/unit/color.rb +0 -96
  95. data/test-unit/lib/test/unit/diff.rb +0 -740
  96. data/test-unit/lib/test/unit/error.rb +0 -130
  97. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  98. data/test-unit/lib/test/unit/failure.rb +0 -136
  99. data/test-unit/lib/test/unit/fixture.rb +0 -176
  100. data/test-unit/lib/test/unit/notification.rb +0 -129
  101. data/test-unit/lib/test/unit/omission.rb +0 -191
  102. data/test-unit/lib/test/unit/pending.rb +0 -150
  103. data/test-unit/lib/test/unit/priority.rb +0 -180
  104. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  105. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  106. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  107. data/test-unit/lib/test/unit/testcase.rb +0 -483
  108. data/test-unit/lib/test/unit/testresult.rb +0 -121
  109. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  110. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  111. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -430
  112. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  113. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -82
  114. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -53
  115. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  116. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  117. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -42
  118. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  119. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  120. data/test-unit/lib/test/unit/util/output.rb +0 -31
  121. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  122. data/test-unit/lib/test/unit/version.rb +0 -7
  123. data/test-unit/sample/adder.rb +0 -13
  124. data/test-unit/sample/subtracter.rb +0 -12
  125. data/test-unit/sample/test_adder.rb +0 -20
  126. data/test-unit/sample/test_subtracter.rb +0 -20
  127. data/test-unit/sample/test_user.rb +0 -23
  128. data/test-unit/test/collector/test-descendant.rb +0 -133
  129. data/test-unit/test/collector/test-load.rb +0 -442
  130. data/test-unit/test/collector/test_dir.rb +0 -406
  131. data/test-unit/test/collector/test_objectspace.rb +0 -100
  132. data/test-unit/test/run-test.rb +0 -15
  133. data/test-unit/test/test-attribute.rb +0 -86
  134. data/test-unit/test/test-color-scheme.rb +0 -69
  135. data/test-unit/test/test-color.rb +0 -47
  136. data/test-unit/test/test-diff.rb +0 -518
  137. data/test-unit/test/test-emacs-runner.rb +0 -60
  138. data/test-unit/test/test-fixture.rb +0 -287
  139. data/test-unit/test/test-notification.rb +0 -33
  140. data/test-unit/test/test-omission.rb +0 -81
  141. data/test-unit/test/test-pending.rb +0 -70
  142. data/test-unit/test/test-priority.rb +0 -119
  143. data/test-unit/test/test-testcase.rb +0 -544
  144. data/test-unit/test/test_assertions.rb +0 -1197
  145. data/test-unit/test/test_error.rb +0 -26
  146. data/test-unit/test/test_failure.rb +0 -33
  147. data/test-unit/test/test_testresult.rb +0 -113
  148. data/test-unit/test/test_testsuite.rb +0 -129
  149. data/test-unit/test/testunit-test-util.rb +0 -14
  150. data/test-unit/test/ui/test_tap.rb +0 -33
  151. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  152. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  153. data/test-unit/test/util/test-output.rb +0 -11
  154. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  155. data/test-unit/test/util/test_observable.rb +0 -102
  156. data/test-unit/test/util/test_procwrapper.rb +0 -36
  157. data/test/.gitignore +0 -1
  158. data/text/expression.rdoc +0 -285
  159. data/text/tutorial.ja.rdoc +0 -433
@@ -1,68 +0,0 @@
1
- = はじめに
2
-
3
- == 名前
4
-
5
- rroonga
6
-
7
- == 説明
8
-
9
- 全文検索機能とカラムストア機能を提供するgroongaのRubyバイン
10
- ディングです。
11
-
12
- groongaのいわゆるDB-API層をRubyから使うための拡張ライブラリで
13
- す。groongaのAPIをそのままRubyレベルに提供するのではなく、
14
- Rubyらしく読み書きしやすいAPIとして提供します。高速・高機能な
15
- groongaをRubyらしい書き方で利用できます。
16
-
17
- groongaに関する情報は以下を参照して下さい。
18
-
19
- * groonga: http://groonga.org/
20
-
21
- == 作者
22
-
23
- Kouhei Sutou:: <tt><kou@clear-code.com></tt>
24
- Tasuku SUENAGA:: <tt><a@razil.jp></tt>
25
- daijiro:: <tt><morita@razil.jp></tt>
26
- Yuto HAYAMIZU:: <tt><y.hayamizu@gmail.com></tt>
27
- SHIDARA Yoji:: <tt><dara@shidara.net></tt>
28
-
29
- == ライセンス
30
-
31
- LGPL 2.1です。詳しくはlicense/LGPLを見てください。
32
-
33
- (コントリビュートされたパッチなども含み、Kouhei Sutouが
34
- ライセンスを変更する権利を持ちます。)
35
-
36
- == 依存ソフトウェア
37
-
38
- * Ruby >= 1.8 (1.9.2対応)
39
- * groonga >= 1.1.0
40
-
41
- == インストール
42
-
43
- % sudo gem install rroonga
44
-
45
- == ドキュメント
46
-
47
- http://groonga.rubyforge.org/rroonga/
48
-
49
- == メーリングリスト
50
-
51
- 質問、要望、バグ報告などはgroongaのMLにお願いします。
52
-
53
- http://lists.sourceforge.jp/mailman/listinfo/groonga-dev
54
-
55
- == 感謝
56
-
57
- * 森さん: 最新groonga対応パッチをくれました。
58
- * グニャラくん: バグレポートしてくれました。
59
- * にくさん: バグレポートしてくれました。
60
- * daraさん:
61
- * テストを書いてくれました。
62
- * バグを直してくれました。
63
- * id:mat_akiさん: チュートリアルのバグを教えてくれました。
64
- * @yune_kotomiさん: バグレポートしてくれました。
65
- * 咳さん: バグレポートしてくれました。
66
- * 小野マトペさん: バグレポートしてくれました。
67
- * @kamipoさん: バグレポートしてくれました。
68
- * ongaeshiさん: Windows上でgemをビルドするためのパッチをくれました。
@@ -1,68 +0,0 @@
1
- = README
2
-
3
- == Name
4
-
5
- rroonga
6
-
7
- == Description
8
-
9
- Ruby bindings for groonga that provides full text search and
10
- column store features.
11
-
12
- rroonga is a extension library to use groonga's DB-API
13
- layer. rroonga provides Rubyish readable and writable
14
- API. You can use groonga's first and highly functional
15
- features from Ruby.
16
-
17
- See the following URL about groonga.
18
-
19
- * groonga: http://groonga.org/
20
-
21
- == Authors
22
-
23
- Kouhei Sutou:: <tt><kou@clear-code.com></tt>
24
- Tasuku SUENAGA:: <tt><a@razil.jp></tt>
25
- daijiro:: <tt><morita@razil.jp></tt>
26
- Yuto HAYAMIZU:: <tt><y.hayamizu@gmail.com></tt>
27
- SHIDARA Yoji:: <tt><dara@shidara.net></tt>
28
-
29
- == License
30
-
31
- LGPL 2.1. See license/LGPL for details.
32
-
33
- (Kouhei Sutou has a right to change the license
34
- inclidng contributed patches.)
35
-
36
- == Dependencies
37
-
38
- * Ruby >= 1.8 (including 1.9.2)
39
- * groonga >= 1.1.0
40
-
41
- == Install
42
-
43
- % sudo gem install rroonga
44
-
45
- == Documents
46
-
47
- Japanese only. Sorry.
48
-
49
- http://groonga.rubyforge.org/rroonga/
50
-
51
- == Mailing list
52
-
53
- http://rubyforge.org/mailman/listinfo/groonga-users-en
54
-
55
- == Thanks
56
-
57
- * mori: sent patches to support the latest groonga.
58
- * Tasuku SUENAGA: sent bug reports.
59
- * niku: sent bug reports.
60
- * dara:
61
- * wrote tests.
62
- * fixed bugs.
63
- * id:mat_aki: sent bug reports.
64
- * @yune_kotomi: sent a bug report.
65
- * m_seki: sent bug reports.
66
- * ono matope: sent bug reports.
67
- * @kamipo: send a bug report.
68
- * ongaeshi: sent a patch to build gem on Windows.
@@ -1,230 +0,0 @@
1
- # -*- mode: ruby; coding: utf-8 -*-
2
-
3
- base_dir = File.join(File.dirname(__FILE__), "..", "..")
4
- $LOAD_PATH.unshift(File.join(base_dir, "ext"))
5
- $LOAD_PATH.unshift(File.join(base_dir, "lib"))
6
-
7
- require 'rubygems'
8
- require 'rack'
9
- require 'groonga'
10
-
11
- use Rack::CommonLogger
12
- use Rack::Runtime
13
- use Rack::Static, :urls => ["/css", "/images"], :root => "public"
14
- use Rack::ContentLength
15
-
16
- Groonga::Database.new("data/database")
17
-
18
- class Searcher
19
- include Rack::Utils
20
-
21
- def initialize
22
- @documents = Groonga::Context.default["documents"]
23
- end
24
-
25
- def call(env)
26
- request = Rack::Request.new(env)
27
- response = Rack::Response.new
28
- response["Content-Type"] = "text/html; charset=UTF-8"
29
-
30
- if request.post? or request['query']
31
- query = request['query'] || ''
32
- if query.empty?
33
- request.path_info = "/"
34
- else
35
- request.path_info = "/#{escape(query)}/"
36
- end
37
- response.redirect(request.url.split(/\?/, 2)[0])
38
- return response.to_a
39
- end
40
-
41
- search(request, response)
42
- end
43
-
44
- private
45
- def search(request, response)
46
- response.write(<<-EOH)
47
- <?xml version="1.0" encoding="utf-8"?>
48
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
49
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
50
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
51
- <head>
52
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
53
- <meta name="robot" content="noindex,nofollow" />
54
- <title>groongaで全文検索</title>
55
- <link rel="stylesheet" href="#{path(request, 'css/groonga.css')}"
56
- type="text/css" media="all" />
57
- </head>
58
- <body>
59
- <div class="header">
60
- <h1>groongaで全文検索</h1>
61
- </div>
62
-
63
- <div class="content">
64
- EOH
65
-
66
- render_search_box(request, response)
67
- render_search_result(request, response)
68
-
69
- response.write(<<-EOF)
70
- </div>
71
-
72
- <div class="footer">
73
- <p class="powered-by-groonga">
74
- <a href="http://groonga.org/">groonga</a>
75
- #{Groonga::VERSION.join('.')}を使っています。
76
- </p>
77
- <p class="powered-by-ruby-groonga">
78
- <a href="http://groonga.rubyforge.org/">Ruby/groonga</a>
79
- #{Groonga::BINDINGS_VERSION.join('.')}を使っています。
80
- </p>
81
- </div>
82
-
83
- </body>
84
- </html>
85
- EOF
86
- response.to_a
87
- end
88
-
89
- def query(request)
90
- unescape(request.path_info.gsub(/\A\/|\/\z/, ''))
91
- end
92
-
93
- def page(request)
94
- (request['page'] || 0).to_i
95
- end
96
-
97
- def path(request, component='')
98
- escape_html("#{request.script_name}/#{component}")
99
- end
100
-
101
- def render_search_box(request, response)
102
- response.write(<<-EOF)
103
- <form method="post" action="#{path(request, '')}">
104
- <p>
105
- <a href="#{path(request, '')}">
106
- <img src="#{path(request, 'images/mini-groonga.png')}" alt="groonga" />
107
- </a>
108
- <input name="query" type="text" value="#{escape_html(query(request))}" />
109
- <input type="submit" value="検索" />
110
- </p>
111
- </form>
112
- EOF
113
- end
114
-
115
- def render_search_result(request, response)
116
- _query = query(request)
117
- _page = page(request)
118
- limit = 20
119
- if _query.empty?
120
- records = []
121
- response.write(<<-EOS)
122
- <div class='search-summary'>
123
- <p>Rubyでgroonga使って全文検索</p>
124
- </div>
125
- EOS
126
- else
127
- options = {}
128
- before = Time.now
129
- records = @documents.select do |record|
130
- record["content"].match(_query)
131
- end
132
- total_records = records.size
133
- records = records.sort([["_score", "descending"],
134
- ["last-modified", "descending"]],
135
- :offset => _page * limit,
136
- :limit => limit)
137
- elapsed = Time.now - before
138
-
139
- response.write(<<-EOS)
140
- <div class='search-summary'>
141
- <p>
142
- <span class="keyword">#{escape_html(query(request))}</span>の検索結果:
143
- <span class="total-entries">#{total_records}</span>件中
144
- <span class="display-range">
145
- #{total_records.zero? ? 0 : (_page * limit) + 1}
146
- -
147
- #{(_page * limit) + records.size}
148
- </span>
149
- 件(#{elapsed}秒)
150
- </p>
151
- </div>
152
- EOS
153
- end
154
-
155
- response.write(" <div class='records'>\n")
156
- records.each do |record|
157
- render_record(request, response, record)
158
- end
159
- response.write(" </div>\n")
160
-
161
- render_pagination(request, response, _page, limit, total_records)
162
- end
163
-
164
- def render_record(request, response, record)
165
- response.write(" <div class='record'>\n")
166
- href = escape_html(record['.path'])
167
- title = escape_html(record['.title'])
168
- last_modified = escape_html(record['.last-modified'].iso8601)
169
- score = record.score
170
- response.write(" <h2><a href='#{href}'>#{title}</a>(#{score})</h2>\n")
171
- render_snippet(request, response, record)
172
- response.write(<<-EOM)
173
- <p class="metadata">
174
- <span class="url">#{unescape(href)}</span>
175
- -
176
- <span class="last-modified">#{last_modified}</span>
177
- </p>
178
- EOM
179
- response.write(" </div>\n")
180
- end
181
-
182
- def render_snippet(request, response, record)
183
- expression = record.table.expression
184
- snippet = expression.snippet([["<span class=\"keyword\">", "</span>"]],
185
- :width => 100,
186
- :html_escape => true,
187
- :normalize => true)
188
- separator = "\n<span class='separator'>...</span>\n"
189
- response.write(<<-EOS)
190
- <p class="snippet">
191
- #{snippet.execute(record[".content"]).join(separator)}
192
- </p>
193
- EOS
194
- end
195
-
196
- def render_pagination(request, response, page, limit, total_records)
197
- _query = query(request)
198
- return if _query.empty?
199
-
200
- return if total_records < limit
201
-
202
- last_page = (total_records / limit.to_f).ceil
203
- response.write("<div class='pagination'>\n")
204
- if page > 0
205
- render_pagination_link(request, response, _query, page - 1, "<<")
206
- end
207
- last_page.times do |i|
208
- if i == page
209
- response.write(pagination_span(escape_html(i)))
210
- else
211
- render_pagination_link(request, response, _query, i, i)
212
- end
213
- end
214
- if page < (last_page - 1)
215
- render_pagination_link(request, response, _query, page + 1, ">>")
216
- end
217
- response.write("</div>\n")
218
- end
219
-
220
- def render_pagination_link(request, response, query, page, label)
221
- href = "./?page=#{escape_html(page)}"
222
- response.write(pagination_span("<a href='#{href}'>#{label}</a>"))
223
- end
224
-
225
- def pagination_span(content)
226
- "<span class='pagination-link'>#{content}</span>\n"
227
- end
228
- end
229
-
230
- run Searcher.new
@@ -1,122 +0,0 @@
1
- body
2
- {
3
- background-color: #fff;
4
- color: #000;
5
- }
6
-
7
- div.header
8
- {
9
- display: none;
10
- }
11
-
12
- div.search-box
13
- {
14
- width: 100%;
15
- text-align: center;
16
- }
17
-
18
- div.re-search
19
- {
20
- }
21
-
22
- div.search-summary
23
- {
24
- font-size: small;
25
- border-top: 1px solid #fc3;
26
- background-color: #ffd;
27
- }
28
-
29
- div.search-summary p
30
- {
31
- padding: 3px;
32
- margin: 0;
33
- }
34
-
35
- div.records
36
- {
37
- font-size: smaller;
38
- padding-top: 10px;
39
- padding-left: 30px;
40
- margin-right: 20%;
41
- margin-bottom: 30px;
42
- }
43
-
44
- div.records h2
45
- {
46
- padding: 0;
47
- margin-bottom: 5px;
48
- }
49
-
50
- div.records p
51
- {
52
- }
53
-
54
- p.snippet
55
- {
56
- padding: 0;
57
- margin: 0;
58
- }
59
-
60
- p.snippet span.separator
61
- {
62
- font-weight: bold;
63
- }
64
-
65
- span.keyword,
66
- span.total-entries,
67
- span.display-range
68
- {
69
- font-weight: bold;
70
- }
71
-
72
- div.pagination
73
- {
74
- text-align: center;
75
- margin-bottom: 20px;
76
- }
77
-
78
- p.metadata
79
- {
80
- padding: 0;
81
- margin: 0;
82
- margin-top: 5px;
83
- }
84
-
85
- span.url
86
- {
87
- color: green;
88
- }
89
-
90
- pre
91
- {
92
- overflow: auto;
93
- margin: 20px 30px;
94
- padding: 10px;
95
- border-top: 1px solid #fc3;
96
- background-color: #ffd;
97
- }
98
-
99
- a img
100
- {
101
- border-style: none;
102
- }
103
-
104
- ul.sources li
105
- {
106
- display: inline;
107
- }
108
-
109
- div.footer
110
- {
111
- border-top: 1px solid #fc3;
112
- background-color: #ffd;
113
- margin-top: 5px;
114
- text-align: right;
115
- }
116
-
117
- div.footer p
118
- {
119
- font-size: small;
120
- padding: 0;
121
- margin: 0;
122
- }