rroonga 1.0.1 → 1.0.2

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.
Files changed (135) hide show
  1. data/NEWS.ja.rdoc +46 -0
  2. data/NEWS.rdoc +46 -0
  3. data/README.ja.rdoc +2 -2
  4. data/README.rdoc +2 -3
  5. data/Rakefile +148 -11
  6. data/example/bookmark.rb +94 -91
  7. data/ext/groonga/extconf.rb +25 -25
  8. data/ext/groonga/groonga.def +2 -0
  9. data/ext/groonga/mkmf.log +7 -7
  10. data/ext/groonga/rb-grn-column.c +66 -0
  11. data/ext/groonga/rb-grn-context.c +92 -5
  12. data/ext/groonga/rb-grn-database.c +24 -1
  13. data/ext/groonga/rb-grn-exception.c +15 -0
  14. data/ext/groonga/rb-grn-hash.c +2 -2
  15. data/ext/groonga/rb-grn-index-column.c +8 -4
  16. data/ext/groonga/rb-grn-object.c +4 -2
  17. data/ext/groonga/rb-grn-patricia-trie.c +2 -2
  18. data/ext/groonga/rb-grn-snippet.c +1 -0
  19. data/ext/groonga/rb-grn-table-key-support.c +22 -19
  20. data/ext/groonga/rb-grn-table.c +63 -5
  21. data/ext/groonga/rb-grn.h +1 -1
  22. data/ext/groonga/rb-groonga.c +1 -0
  23. data/extconf.rb +1 -1
  24. data/html/developer.html +8 -2
  25. data/html/favicon.ico +0 -0
  26. data/html/favicon.svg +591 -0
  27. data/html/index.html +71 -8
  28. data/html/logo.svg +612 -0
  29. data/html/ranguba.css +92 -7
  30. data/html/readme.svg +256 -0
  31. data/lib/groonga/expression-builder.rb +8 -4
  32. data/lib/groonga/record.rb +77 -7
  33. data/lib/groonga/schema.rb +429 -100
  34. data/rroonga-build.rb +1 -1
  35. data/test/run-test.rb +1 -1
  36. data/test/test-array.rb +4 -0
  37. data/test/test-context.rb +8 -0
  38. data/test/test-database.rb +8 -1
  39. data/test/test-expression-builder.rb +14 -0
  40. data/test/test-fix-size-column.rb +4 -0
  41. data/test/test-hash.rb +10 -4
  42. data/test/test-index-column.rb +11 -0
  43. data/test/test-patricia-trie.rb +7 -1
  44. data/test/test-record.rb +14 -0
  45. data/test/test-remote.rb +3 -2
  46. data/test/test-schema-create-table.rb +32 -2
  47. data/test/test-schema.rb +108 -11
  48. data/test/test-table-select-normalize.rb +7 -3
  49. data/test/test-table-select.rb +12 -0
  50. data/test/test-table.rb +7 -0
  51. data/test/test-variable-size-column.rb +4 -0
  52. data/test-unit/Rakefile +40 -0
  53. data/test-unit/TODO +5 -0
  54. data/test-unit/bin/testrb +5 -0
  55. data/test-unit/html/classic.html +15 -0
  56. data/test-unit/html/index.html +25 -0
  57. data/test-unit/html/index.html.ja +27 -0
  58. data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
  59. data/test-unit/lib/test/unit/assertions.rb +1230 -0
  60. data/test-unit/lib/test/unit/attribute.rb +125 -0
  61. data/test-unit/lib/test/unit/autorunner.rb +360 -0
  62. data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
  63. data/test-unit/lib/test/unit/collector/dir.rb +108 -0
  64. data/test-unit/lib/test/unit/collector/load.rb +144 -0
  65. data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
  66. data/test-unit/lib/test/unit/collector.rb +36 -0
  67. data/test-unit/lib/test/unit/color-scheme.rb +102 -0
  68. data/test-unit/lib/test/unit/color.rb +96 -0
  69. data/test-unit/lib/test/unit/diff.rb +724 -0
  70. data/test-unit/lib/test/unit/error.rb +130 -0
  71. data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
  72. data/test-unit/lib/test/unit/failure.rb +136 -0
  73. data/test-unit/lib/test/unit/fixture.rb +176 -0
  74. data/test-unit/lib/test/unit/notification.rb +129 -0
  75. data/test-unit/lib/test/unit/omission.rb +191 -0
  76. data/test-unit/lib/test/unit/pending.rb +150 -0
  77. data/test-unit/lib/test/unit/priority.rb +180 -0
  78. data/test-unit/lib/test/unit/runner/console.rb +52 -0
  79. data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
  80. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  81. data/test-unit/lib/test/unit/testcase.rb +476 -0
  82. data/test-unit/lib/test/unit/testresult.rb +89 -0
  83. data/test-unit/lib/test/unit/testsuite.rb +110 -0
  84. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
  85. data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
  86. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
  87. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
  88. data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
  89. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
  90. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  91. data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
  92. data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
  93. data/test-unit/lib/test/unit/util/observable.rb +90 -0
  94. data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
  95. data/test-unit/lib/test/unit/version.rb +7 -0
  96. data/test-unit/lib/test/unit.rb +323 -0
  97. data/test-unit/sample/adder.rb +13 -0
  98. data/test-unit/sample/subtracter.rb +12 -0
  99. data/test-unit/sample/test_adder.rb +20 -0
  100. data/test-unit/sample/test_subtracter.rb +20 -0
  101. data/test-unit/sample/test_user.rb +23 -0
  102. data/test-unit/test/collector/test-descendant.rb +133 -0
  103. data/test-unit/test/collector/test-load.rb +442 -0
  104. data/test-unit/test/collector/test_dir.rb +406 -0
  105. data/test-unit/test/collector/test_objectspace.rb +100 -0
  106. data/test-unit/test/run-test.rb +15 -0
  107. data/test-unit/test/test-attribute.rb +86 -0
  108. data/test-unit/test/test-color-scheme.rb +67 -0
  109. data/test-unit/test/test-color.rb +47 -0
  110. data/test-unit/test/test-diff.rb +518 -0
  111. data/test-unit/test/test-emacs-runner.rb +60 -0
  112. data/test-unit/test/test-fixture.rb +287 -0
  113. data/test-unit/test/test-notification.rb +33 -0
  114. data/test-unit/test/test-omission.rb +81 -0
  115. data/test-unit/test/test-pending.rb +70 -0
  116. data/test-unit/test/test-priority.rb +119 -0
  117. data/test-unit/test/test-testcase.rb +544 -0
  118. data/test-unit/test/test_assertions.rb +1151 -0
  119. data/test-unit/test/test_error.rb +26 -0
  120. data/test-unit/test/test_failure.rb +33 -0
  121. data/test-unit/test/test_testresult.rb +113 -0
  122. data/test-unit/test/test_testsuite.rb +129 -0
  123. data/test-unit/test/testunit-test-util.rb +14 -0
  124. data/test-unit/test/ui/test_testrunmediator.rb +20 -0
  125. data/test-unit/test/util/test-method-owner-finder.rb +38 -0
  126. data/test-unit/test/util/test_backtracefilter.rb +41 -0
  127. data/test-unit/test/util/test_observable.rb +102 -0
  128. data/test-unit/test/util/test_procwrapper.rb +36 -0
  129. data/text/{TUTORIAL.ja.rdoc → tutorial.ja.rdoc} +165 -126
  130. metadata +106 -16
  131. data/html/favicon.xcf +0 -0
  132. data/html/logo.xcf +0 -0
  133. data/license/GPL +0 -340
  134. data/license/RUBY +0 -59
  135. data/pkg-config.rb +0 -333
data/NEWS.ja.rdoc CHANGED
@@ -1,5 +1,51 @@
1
1
  = お知らせ
2
2
 
3
+ == 1.0.2: 2010-11-25
4
+
5
+ === 改良
6
+
7
+ * groonga 1.0.4対応。
8
+ * Groonga::UnsupportedCommandVersionを追加。
9
+ * Groonga::Record#support_sub_records?を追加。
10
+ * Groonga::Record#eql?とGroonga::Record#hashを追加。
11
+ (同じテーブルの同じレコードIDのオブジェクトを同一のHashキーとして扱う。)
12
+ * pkg-config gemを利用するようにした。
13
+ * Groonga::Table#select内でrecord_idメソッドを持っているメソッドはレコード
14
+ として扱うようにした。
15
+ * Groonga::Record#record_idを追加。
16
+ * Groonga::Table#support_key?を追加。
17
+ * Groonga::Record#support_key?を追加。
18
+ * Groonga::Record#support_key?を追加。
19
+ * Groonga::Column#reference_key?を追加。
20
+ * Groonga::Column#index_column?を追加。
21
+ * Groonga::Schema#dumpを追加。
22
+ * Groonga::Schemaが複数のカラムのインデックス作成に対応。
23
+ * Groonga::Schemaで定義したオブジェクトに対応するファイル名に
24
+ わかりやすいファイル名を利用するようにした。
25
+ * Groonga::Schemaで参照カラムを定義時に参照先のテーブル名を省略可能になった。
26
+ * Groonga::Schema.remove_columnを追加。
27
+ * Groonga::Schemaでcreated_atカラムとupdated_atカラムを作るための
28
+ timestamps便利メソッドを追加。
29
+ * Groonga::Context#support_zlib?を追加。
30
+ * Groonga::Context#support_lzo?を追加。
31
+ * Groonga::Database#touchを追加。
32
+ * Groonga::Table#exist?を追加。
33
+ * Groonga::Record#valid?を追加。
34
+
35
+ == 変更
36
+
37
+ * Groonga::PatriciaTrie#open_cursorでは:order_byのデフォルト値として:key
38
+ を使うようにした。
39
+ * 非推奨扱いのGroonga::TableKeySupport#findを削除。
40
+ * Groonga::Hash#createとGroonga::PatriciaTrie#createでキーの型を省略した
41
+ 場合はShortTextを使用するようにした。
42
+ * Groonga::Schema#loadをGroonga::Schema#restoreに改名。
43
+
44
+ === 修正
45
+
46
+ * keyにインデックスを張れない問題を修正。
47
+ * GC時にクラッシュする問題を修正。
48
+
3
49
  == 1.0.1: 2010-09-12
4
50
 
5
51
  === 修正
data/NEWS.rdoc CHANGED
@@ -1,5 +1,51 @@
1
1
  = NEWS
2
2
 
3
+ == 1.0.2: 2010-11-25
4
+
5
+ === Improvements
6
+
7
+ * Supported groonga 1.0.4.
8
+ * Added Groonga::UnsupportedCommandVersion.
9
+ * Added Groonga::Record#support_sub_records?.
10
+ * Added Groonga::Record#eql?とGroonga::Record#hash.
11
+ (treat two the same table and the same record ID object as the same Hash key.)
12
+ * Supported pkg-config gem.
13
+ * Supported generic #record_id object handle for custom record object
14
+ in Groonga::Table#select.
15
+ * Added Groonga::Record#record_id.
16
+ * Added Groonga::Table#support_key?.
17
+ * Added Groonga::Record#support_key?.
18
+ * Added Groonga::Record#support_key?.
19
+ * Added Groonga::Column#reference_key?.
20
+ * Added Groonga::Column#index_column?.
21
+ * Added Groonga::Schema#dump.
22
+ * Supported multi columns index creation in Groonga::Schema.
23
+ * Supported meaningful path in Groonga::Schema.
24
+ * Made reference table omissible when index column definition
25
+ in Groonga::Schema.
26
+ * Added Groonga::Schema.remove_column.
27
+ * Added convenience timestamps methods to define "created_at" and
28
+ "updated_at" columns in Groonga::Schema.
29
+ * Added Groonga::Context#support_zlib?.
30
+ * Added Groonga::Context#support_lzo?.
31
+ * Added Groonga::Database#touch.
32
+ * Added Groonga::Table#exist?.
33
+ * Added Groonga::Record#valid?.
34
+
35
+ == Changes
36
+
37
+ * Used :key as the default value of :order_by of
38
+ Groonga::PatriciaTrie#open_cursor.
39
+ * Removed a deprecated Groonga::TableKeySupport#find.
40
+ * Used ShortText as the default key type of
41
+ Groonga::Hash#create and Groonga::PatriciaTrie#create.
42
+ * Renamed Groonga::Schema#load to Groonga::Schema#restore.
43
+
44
+ === Fixes
45
+
46
+ * Fixed index for key isn't be able to define.
47
+ * Fixed a crash problem on GC.
48
+
3
49
  == 1.0.1: 2010-09-12
4
50
 
5
51
  === Fixes
data/README.ja.rdoc CHANGED
@@ -30,8 +30,8 @@ SHIDARA Yoji:: <tt><dara@shidara.net></tt>
30
30
 
31
31
  LGPL 2.1です。詳しくはlicense/LGPLを見てください。
32
32
 
33
- pkg-config.rbはrcairoに付属しているもので、これはRubyライセ
34
- ンスです。詳しくはlicense/RUBYとlicense/GPLを見てください。
33
+ (コントリビュートされたパッチなども含み、Kouhei Sutouが
34
+ ライセンスを変更する権利を持ちます。)
35
35
 
36
36
  == 依存ソフトウェア
37
37
 
data/README.rdoc CHANGED
@@ -30,9 +30,8 @@ SHIDARA Yoji:: <tt><dara@shidara.net></tt>
30
30
 
31
31
  LGPL 2.1. See license/LGPL for details.
32
32
 
33
- pkg-config.rb is a library that is bundled with rcairo. It's
34
- distributed under Ruby license. See license/RUBY and
35
- license/GPL for details.
33
+ (Kouhei Sutou has a right to change the license
34
+ inclidng contributed patches.)
36
35
 
37
36
  == Dependencies
38
37
 
data/Rakefile CHANGED
@@ -22,7 +22,9 @@ require 'fileutils'
22
22
  require 'pathname'
23
23
  require 'erb'
24
24
  require 'rubygems'
25
- gem 'rdoc'
25
+ if RUBY_VERSION < "1.9"
26
+ gem 'rdoc'
27
+ end
26
28
  require 'hoe'
27
29
  require 'rake/extensiontask'
28
30
 
@@ -39,9 +41,17 @@ $LOAD_PATH.unshift(groonga_ext_dir)
39
41
  $LOAD_PATH.unshift(groonga_lib_dir)
40
42
  ENV["RUBYLIB"] = "#{groonga_lib_dir}:#{groonga_ext_dir}:#{ENV['RUBYLIB']}"
41
43
 
42
- def guess_version
43
- require 'groonga'
44
- Groonga.bindings_version
44
+ def guess_version(groonga_ext_dir)
45
+ version = {}
46
+ File.open(File.join(groonga_ext_dir, "rb-grn.h")) do |rb_grn_h|
47
+ rb_grn_h.each_line do |line|
48
+ case line
49
+ when /\A#define RB_GRN_([A-Z]+)_VERSION (\d+)/
50
+ version[$1.downcase] = $2
51
+ end
52
+ end
53
+ end
54
+ [version["major"], version["minor"], version["micro"]].join(".")
45
55
  end
46
56
 
47
57
  manifest = File.join(base_dir, "Manifest.txt")
@@ -49,13 +59,10 @@ manifest_contents = []
49
59
  base_dir_included_components = %w(AUTHORS Rakefile
50
60
  README.rdoc README.ja.rdoc
51
61
  NEWS.rdoc NEWS.ja.rdoc
52
- rroonga-build.rb extconf.rb pkg-config.rb)
62
+ rroonga-build.rb extconf.rb)
53
63
  excluded_components = %w(.cvsignore .gdb_history CVS depend Makefile doc pkg
54
- .svn .git doc data .test-result tmp)
64
+ .svn .git doc data .test-result tmp vendor)
55
65
  excluded_suffixes = %w(.png .ps .pdf .o .so .a .txt .~)
56
- unless ENV["RUBY_CC_VERSION"]
57
- excluded_components << "vendor"
58
- end
59
66
  Find.find(base_dir) do |target|
60
67
  target = truncate_base_dir[target]
61
68
  components = target.split(File::SEPARATOR)
@@ -84,7 +91,7 @@ def cleanup_white_space(entry)
84
91
  entry.gsub(/(\A\n+|\n+\z)/, '') + "\n"
85
92
  end
86
93
 
87
- ENV["VERSION"] ||= guess_version
94
+ ENV["VERSION"] ||= guess_version(groonga_ext_dir)
88
95
  version = ENV["VERSION"]
89
96
  project = nil
90
97
  Hoe.spec('rroonga') do
@@ -110,6 +117,7 @@ Hoe.spec('rroonga') do
110
117
  :require_paths => ["lib", "ext/groonga"],
111
118
  :extra_rdoc_files => Dir.glob("**/*.rdoc"),
112
119
  }
120
+ project.extra_deps << ['pkg-config', '>= 0']
113
121
  project.readme_file = "README.ja.rdoc"
114
122
 
115
123
  news_of_current_release = File.read("NEWS.rdoc").split(/^==\s.*$/)[1]
@@ -135,9 +143,23 @@ ObjectSpace.each_object(Rake::RDocTask) do |rdoc_task|
135
143
  rdoc_task.rdoc_files += Dir.glob("**/*.rdoc")
136
144
  end
137
145
 
146
+ relative_vendor_dir = "vendor"
147
+ relative_binary_dir = File.join("vendor", "local")
148
+ vendor_dir = File.join(base_dir, relative_vendor_dir)
149
+ binary_dir = File.join(base_dir, relative_binary_dir)
138
150
  Rake::ExtensionTask.new("groonga", project.spec) do |ext|
139
151
  ext.cross_compile = true
140
- ext.cross_platform = 'x86-mingw32'
152
+ ext.cross_compiling do |spec|
153
+ if /mingw|mswin/ =~ spec.platform.to_s
154
+ binary_files = []
155
+ Find.find(relative_binary_dir) do |name|
156
+ next unless File.file?(name)
157
+ next if /\.zip\z/i =~ name
158
+ binary_files << name
159
+ end
160
+ spec.files += binary_files
161
+ end
162
+ end
141
163
  end
142
164
 
143
165
  task :publish_docs => [:prepare_docs_for_publishing]
@@ -207,3 +229,118 @@ project.spec.executables.clear
207
229
  # project.lib_files = project.spec.files.grep(%r|^src/lib/|)
208
230
 
209
231
  task(:release).prerequisites.reject! {|name| name == "clean"}
232
+
233
+ namespace :win32 do
234
+ desc "Build MeCab and groonga and install them into vendor/local/."
235
+ task(:build => :build_groonga)
236
+
237
+ desc "Build MeCab and install it into vendor/local/."
238
+ task(:build_mecab) do
239
+ tmp_dir = "tmp/mecab"
240
+ rm_rf(tmp_dir)
241
+ mkdir_p(tmp_dir)
242
+ require 'open-uri'
243
+ mecab_version = "0.98"
244
+ mecab_base = "mecab-#{mecab_version}"
245
+ mecab_tar_gz = "#{mecab_base}.tar.gz"
246
+ mecab_tar_gz_url = "http://sourceforge.net/projects/mecab/files/mecab/#{mecab_version}/#{mecab_tar_gz}/download"
247
+ Dir.chdir(tmp_dir) do
248
+ open(mecab_tar_gz_url) do |downloaded_tar_gz|
249
+ File.open(mecab_tar_gz, "wb") do |tar_gz|
250
+ tar_gz.print(downloaded_tar_gz.read)
251
+ end
252
+ end
253
+ sh("tar", "xzf", mecab_tar_gz) or exit(false)
254
+ end
255
+ Dir.chdir(File.join(tmp_dir, mecab_base)) do
256
+ sh("./configure",
257
+ "--prefix=#{binary_dir}",
258
+ "--host=amd64-mingw32msvc") or exit(false)
259
+ sh("env", "GREP_OPTIONS=--text", "nice", "make", "-j8") or exit(false)
260
+ sh("env", "GREP_OPTIONS=--text", "make", "install") or exit(false)
261
+
262
+ mecab_files_dir = File.join(vendor_dir, "mecab")
263
+ mkdir_p(mecab_files_dir)
264
+ files = ["AUTHORS", "BSD", "COPYING", "GPL", "LGPL"]
265
+ cp(files, mecab_files_dir)
266
+ end
267
+ end
268
+
269
+ task(:build_mecab_dict => :build_mecab) do
270
+ tmp_dir = "tmp/mecab_dict"
271
+ rm_rf(tmp_dir)
272
+ mkdir_p(tmp_dir)
273
+ require 'open-uri'
274
+ naist_jdic_base = "mecab-naist-jdic-0.6.3-20100801"
275
+ naist_jdic_tar_gz = "#{naist_jdic_base}.tar.gz"
276
+ naist_jdic_tar_gz_url = "http://osdn.dl.sourceforge.jp/naist-jdic/48487/#{naist_jdic_tar_gz}"
277
+ Dir.chdir(tmp_dir) do
278
+ open(naist_jdic_tar_gz_url) do |downloaded_tar_gz|
279
+ File.open(naist_jdic_tar_gz, "wb") do |tar_gz|
280
+ tar_gz.print(downloaded_tar_gz.read)
281
+ end
282
+ end
283
+ sh("tar", "xzf", naist_jdic_tar_gz) or exit(false)
284
+ end
285
+ Dir.chdir(File.join(tmp_dir, naist_jdic_base)) do
286
+ sh("./configure",
287
+ "--with-dicdir=#{binary_dir}/share/mecab/dic/naist-jdic",
288
+ "--with-charset=utf-8") or exit(false)
289
+ sh("make", "-j8") or exit(false)
290
+ sh("make", "install-data") or exit(false)
291
+
292
+ naist_jdic_files_dir = File.join(vendor_dir, "mecab-naist-jdic")
293
+ mkdir_p(naist_jdic_files_dir)
294
+ files = ["AUTHORS", "COPYING"]
295
+ cp(files, naist_jdic_files_dir)
296
+ end
297
+ dictionary_dir = '$(rcpath)\..\share/mecab\dic\naist-jdic'
298
+ mecab_rc_path = File.join(binary_dir, "etc", "mecabrc")
299
+ mecab_rc_content = File.read(mecab_rc_path)
300
+ File.open(mecab_rc_path, "w") do |mecab_rc|
301
+ mecab_rc.print(mecab_rc_content.gsub(/\Adictdir\s*=.+$/,
302
+ "dictdir = #{dictionary_dir}"))
303
+ end
304
+ end
305
+
306
+ desc "Build groonga and install it into vendor/local/."
307
+ task(:build_groonga) do
308
+ tmp_dir = "tmp/groonga"
309
+ rm_rf(tmp_dir)
310
+ mkdir_p(tmp_dir)
311
+ Dir.chdir(tmp_dir) do
312
+ sh("git", "clone", "git://github.com/groonga/groonga.git") or exit(false)
313
+ end
314
+ Dir.chdir(File.join(tmp_dir, "groonga")) do
315
+ sh("./autogen.sh") or exit(false)
316
+ mecab_config = File.join(binary_dir, "bin", "mecab-config")
317
+ args = ["./configure",
318
+ "--prefix=#{binary_dir}",
319
+ "--host=amd64-mingw32msvc",
320
+ "--without-cutter",
321
+ "--disable-benchmark"]
322
+ if File.exist?(mecab_config)
323
+ args << "--with-mecab-config=#{mecab_config}"
324
+ else
325
+ args << "--without-mecab"
326
+ end
327
+ sh(*args) or exit(false)
328
+ sh("env", "GREP_OPTIONS=--text", "nice", "make", "-j8") or exit(false)
329
+ sh("env", "GREP_OPTIONS=--text", "make", "install") or exit(false)
330
+
331
+ groonga_files_dir = File.join(vendor_dir, "groonga")
332
+ mkdir_p(groonga_files_dir)
333
+ files = ["AUTHORS", "COPYING"]
334
+ cp(files, groonga_files_dir)
335
+ end
336
+ end
337
+ end
338
+
339
+ desc "generate rroonga.gemspec"
340
+ task :generate_gemspec do
341
+ spec = project.spec
342
+ spec_name = File.join(base_dir, project.spec.spec_name)
343
+ File.open(spec_name, "w") do |spec_file|
344
+ spec_file.puts(spec.to_ruby)
345
+ end
346
+ end
data/example/bookmark.rb CHANGED
@@ -27,7 +27,7 @@ path = ARGV[0]
27
27
  if path.nil?
28
28
  require 'tmpdir'
29
29
  require 'fileutils'
30
- temporary_directory = File.join(Dir.tmpdir, "ruby-groonga")
30
+ temporary_directory = File.join(Dir.tmpdir, "rroonga")
31
31
  FileUtils.mkdir_p(temporary_directory)
32
32
  at_exit {FileUtils.rm_rf(temporary_directory)}
33
33
  path = File.join(temporary_directory, "db")
@@ -36,126 +36,129 @@ persistent = true
36
36
 
37
37
  p Groonga::Database.create(:path => path)
38
38
 
39
- p(items = Groonga::Hash.create(:name => "Items",
40
- :key_type => "ShortText",
41
- :persistent => persistent))
39
+ p Groonga::Schema.create_table("Items", :type => :hash)
40
+ p(items = Groonga["Items"])
41
+
42
+ p items.size
42
43
 
43
44
  p items.add("http://ja.wikipedia.org/wiki/Ruby")
44
- p items.add("http://www.ruby-lang.org/")
45
+ p items.add("http://www.ruby-lang.org/ja/")
46
+
47
+ p items.size
48
+
49
+ p items["http://ja.wikipedia.org/wiki/Ruby"]
45
50
 
46
- p items.define_column("title", "Text", :persistent => persistent)
51
+ p(Groonga::Schema.change_table("Items") do |table|
52
+ table.text("title")
53
+ end)
54
+ p(title_column = Groonga["Items.title"])
47
55
 
48
- p(terms = Groonga::Hash.create(:name => "Terms",
49
- :key_type => "ShortText",
50
- :persistent => persistent,
56
+ p(Groonga::Schema.create_table("Terms",
57
+ :type => :patricia_trie,
58
+ :key_normalize => true,
51
59
  :default_tokenizer => "TokenBigram"))
52
- p terms.define_index_column("item_title", items,
53
- :persistent => persistent,
54
- :with_weight => true,
55
- :with_section => true,
56
- :with_position => true,
57
- :source => "Items.title")
58
-
59
- p items.find("http://ja.wikipedia.org/wiki/Ruby")["title"] = "Ruby"
60
- p items.find("http://www.ruby-lang.org/")["title"] = "オブジェクト指向スクリプト言語Ruby"
61
-
62
- p(users = Groonga::Hash.create(:name => "Users",
63
- :key_type => "ShortText",
64
- :persistent => persistent))
65
- p users.define_column("name", "Text",
66
- :persistent => persistent)
67
-
68
- p(comments = Groonga::Array.create(:name => "Comments",
69
- :persistent => persistent))
70
- p comments.define_column("item", items)
71
- p comments.define_column("author", users)
72
- p comments.define_column("content", "Text")
73
- p comments.define_column("issued", "Time")
74
-
75
- p terms.define_index_column("comment_content", comments,
76
- :persistent => persistent,
77
- :with_weight => true,
78
- :with_section => true,
79
- :with_position => true,
80
- :source => "Comments.content")
81
-
82
- p users.add("moritan", :name => "モリタン")
83
- p users.add("taporobo", :name => "タポロボ")
84
-
85
-
86
- p items.find("http://d.hatena.ne.jp/brazil/20050829/1125321936")
87
-
88
- p items.add("http://d.hatena.ne.jp/brazil/20050829/1125321936",
89
- :title => "[翻訳]JavaScript: 世界で最も誤解されたプログラミング言語")
90
-
91
- p comments.add(:item => "http://d.hatena.ne.jp/brazil/20050829/1125321936",
60
+ p(Groonga::Schema.change_table("Terms") do |table|
61
+ table.index("Items.title")
62
+ end)
63
+
64
+ p(items["http://ja.wikipedia.org/wiki/Ruby"].title = "Ruby")
65
+ p(items["http://www.ruby-lang.org/ja/"].title = "オブジェクトスクリプト言語Ruby")
66
+
67
+ p(ruby_items = items.select {|record| record.title =~ "Ruby"})
68
+ p(ruby_items.collect {|record| record.key.key})
69
+ p(ruby_items.collect {|record| record["_key"]})
70
+
71
+ p(Groonga::Schema.create_table("Users", :type => :hash) do |table|
72
+ table.text("name")
73
+ end)
74
+ p(Groonga::Schema.create_table("Comments") do |table|
75
+ table.reference("item")
76
+ table.reference("author", "Users")
77
+ table.text("content")
78
+ table.time("issued")
79
+ end)
80
+
81
+ p(Groonga::Schema.change_table("Terms") do |table|
82
+ table.index("Comments.content")
83
+ end)
84
+
85
+ p(users = Groonga["Users"])
86
+ p(users.add("moritan", :name => "モリタン"))
87
+ p(users.add("taporobo", :name => "タポロボ"))
88
+
89
+ p(items.has_key?("http://www.rubyist.net/~matz/"))
90
+ p(items.add("http://www.rubyist.net/~matz/",
91
+ :title => "Matzにっき"))
92
+
93
+ require "time"
94
+
95
+ p(comments = Groonga["Comments"])
96
+ p(comments.add(:item => "http://www.rubyist.net/~matz/",
92
97
  :author => "moritan",
93
- :content => "JavaScript LISP",
94
- :issued => 1187430026)
98
+ :content => "Ruby Matz",
99
+ :issued => Time.parse("2010-11-20T18:01:22+09:00")))
95
100
 
96
- @items = items
97
- @comments = comments
101
+ p(@items = items)
102
+ p(@comments = comments)
98
103
  def add_bookmark(url, title, author, content, issued)
99
- item = @items.find(url) || @items.add(url, :title => title)
104
+ item = @items[url] || @items.add(url, :title => title)
100
105
  @comments.add(:item => item,
101
106
  :author => author,
102
107
  :content => content,
103
108
  :issued => issued)
104
109
  end
105
110
 
106
- p add_bookmark("http://practical-scheme.net/docs/cont-j.html",
107
- "なんでも継続", "moritan", "継続 LISP Scheme", 1187568692)
108
- p add_bookmark("http://d.hatena.ne.jp/higepon/20070815/1187192864",
109
- "末尾再帰", "taporobo", "末尾再帰 Scheme LISP", 1187568793)
110
- p add_bookmark("http://practical-scheme.net/docs/cont-j.html",
111
- "なんでも継続", "taporobo", "トランポリン LISP continuation",
112
- 1187568692.98765)
113
- p add_bookmark("http://jp.rubyist.net/managinze",
114
- "るびま", "moritan", "Ruby ドキュメント",
115
- Time.now)
116
- p add_bookmark("http://jp.rubyist.net/managinze",
117
- "るびま", "taporobo", "Ruby 雑誌",
118
- Time.now)
119
- p add_bookmark("http://groonga.rubyforge.org/",
120
- "ラングバ", "moritan", "Ruby groonga",
121
- Time.parse("2009-07-19"))
122
-
123
-
124
- records = comments.select do |record|
125
- record["content"] =~ "LISP"
126
- end
111
+ p(add_bookmark("http://jp.rubyist.net/magazine/",
112
+ "Rubyist Magazine - るびま", "moritan", "Ruby 記事",
113
+ Time.parse("2010-10-07T14:18:28+09:00")))
114
+ p(add_bookmark("http://groonga.rubyforge.org/",
115
+ "Rubyでgroonga使って全文検索 - ラングバ", "taporobo",
116
+ "Ruby groonga 全文検索",
117
+ Time.parse("2010-11-11T12:39:59+09:00")))
118
+ p(add_bookmark("http://www.rubyist.net/~matz/",
119
+ "Matz日記", "taporobo", "Ruby 日記",
120
+ Time.parse("2010-07-28T20:46:23+09:00")))
121
+
122
+ p(records = comments.select do |record|
123
+ record["content"] =~ "Ruby"
124
+ end)
127
125
 
128
126
  records.each do |record|
129
127
  record = record.key
130
128
  p [record.id,
131
- record[".issued"],
132
- record[".item.title"],
133
- record[".author.name"],
134
- record[".content"]]
129
+ record.issued,
130
+ record.item.title,
131
+ record.author.name,
132
+ record.content]
135
133
  end
136
134
 
137
135
  p records
138
136
 
139
- records.sort([{:key => ".issued", :order => "descending"}]).each do |record|
137
+ records.sort([{:key => "issued", :order => "descending"}]).each do |record|
140
138
  record = record.key
141
139
  p [record.id,
142
- record[".issued"],
143
- record[".item.title"],
144
- record[".author.name"],
145
- record[".content"]]
140
+ record.issued,
141
+ record.item.title,
142
+ record.author.name,
143
+ record.content]
146
144
  end
147
145
 
148
146
  records.group("item").each do |record|
149
147
  item = record.key
150
148
  p [record.n_sub_records,
151
149
  item.key,
152
- item[".title"]]
150
+ item.title]
153
151
  end
154
152
 
155
- p ruby_comments = @comments.select {|record| record["content"] =~ "Ruby"}
156
- p ruby_items = @items.select("*W1:50 title:@Ruby")
157
-
158
- p ruby_items = ruby_comments.group(".item").union!(ruby_items)
159
- ruby_items.sort([{:key => "._score", :order => "descending"}]).each do |record|
160
- p [record["._score"], record[".title"]]
153
+ p(ruby_comments = @comments.select {|record| record.content =~ "Ruby"})
154
+ p(ruby_items = @items.select do |record|
155
+ target = record.match_target do |match_record|
156
+ match_record.title * 10
157
+ end
158
+ target =~ "Ruby"
159
+ end)
160
+
161
+ p(ruby_items = ruby_comments.group("item").union!(ruby_items))
162
+ ruby_items.sort([{:key => "_score", :order => "descending"}]).each do |record|
163
+ p [record.score, record.title]
161
164
  end
@@ -22,29 +22,21 @@ $LOAD_PATH.unshift(base_dir.to_s)
22
22
 
23
23
  require 'English'
24
24
  require 'mkmf'
25
- require 'pkg-config'
26
25
  require 'rroonga-build'
27
26
 
27
+ begin
28
+ require 'pkg-config'
29
+ rescue LoadError
30
+ require 'rubygems'
31
+ require 'pkg-config'
32
+ end
33
+
28
34
  include RroongaBuild
29
35
 
30
36
  package_name = "groonga"
31
37
  module_name = "groonga"
32
38
  major, minor, micro = RequiredGroongaVersion::VERSION
33
39
 
34
- unless PKGConfig.have_package(package_name, major, minor, micro)
35
- have_local_groonga?(package_name, major, minor, micro) or exit 1
36
- add_rpath_for_local_groonga
37
- end
38
-
39
- real_version = PKGConfig.modversion(package_name)
40
- real_major, real_minor, real_micro = real_version.split(/\./)
41
-
42
- $defs << "-DRB_GRN_COMPILATION"
43
-
44
- $defs << "-DGRN_MAJOR_VERSION=#{real_major}"
45
- $defs << "-DGRN_MINOR_VERSION=#{real_minor}"
46
- $defs << "-DGRN_MICRO_VERSION=#{real_micro}"
47
-
48
40
  checking_for(checking_message("GCC")) do
49
41
  if macro_defined?("__GNUC__", "")
50
42
  $CFLAGS += ' -Wall'
@@ -61,20 +53,28 @@ checking_for(checking_message("Win32 OS")) do
61
53
  import_library_name = "libruby-#{module_name}.a"
62
54
  $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
63
55
  $cleanfiles << import_library_name
64
- local_groonga_install_dir = base_dir + "vendor" + "local"
65
- $CFLAGS += " -I#{local_groonga_install_dir}/include"
66
- local_groonga_lib_dir = local_groonga_install_dir + "lib"
67
- ["libgroonga.lib", "libgroonga.dll.a"].each do |libgroonga_base|
68
- libgroonga = local_groonga_lib_dir + libgroonga_base
69
- if libgroonga.exist?
70
- $DLDFLAGS += " -L#{local_groonga_lib_dir}"
71
- break
72
- end
73
- end
56
+ binary_base_dir = base_dir + "vendor" + "local"
57
+ pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
58
+ PKGConfig.add_path(pkg_config_dir.to_s)
59
+ PKGConfig.set_override_variable("prefix", binary_base_dir.to_s)
74
60
  end
75
61
  win32
76
62
  end
77
63
 
64
+ unless PKGConfig.have_package(package_name, major, minor, micro)
65
+ have_local_groonga?(package_name, major, minor, micro) or exit 1
66
+ add_rpath_for_local_groonga
67
+ end
68
+
69
+ real_version = PKGConfig.modversion(package_name)
70
+ real_major, real_minor, real_micro = real_version.split(/\./)
71
+
72
+ $defs << "-DRB_GRN_COMPILATION"
73
+
74
+ $defs << "-DGRN_MAJOR_VERSION=#{real_major}"
75
+ $defs << "-DGRN_MINOR_VERSION=#{real_minor}"
76
+ $defs << "-DGRN_MICRO_VERSION=#{real_micro}"
77
+
78
78
  have_header("ruby/st.h") unless have_macro("HAVE_RUBY_ST_H", "ruby.h")
79
79
  have_func("rb_errinfo", "ruby.h")
80
80
  have_type("enum ruby_value_type", "ruby.h")
@@ -0,0 +1,2 @@
1
+ EXPORTS
2
+ Init_groonga