rroonga 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,12 @@
1
1
  = お知らせ
2
2
 
3
+ == 1.1.0: 2011-02-09
4
+
5
+ === 改良
6
+
7
+ * groonga 1.1.0対応。
8
+ * Groonga::Plugin.registerを追加。
9
+
3
10
  == 1.0.9: 2011-01-29
4
11
 
5
12
  === 改良
data/NEWS.rdoc CHANGED
@@ -1,5 +1,12 @@
1
1
  = NEWS
2
2
 
3
+ == 1.1.0: 2011-02-09
4
+
5
+ === Improvements
6
+
7
+ * Supported groonga 1.1.0.
8
+ * Added Groonga::Plugin.register.
9
+
3
10
  == 1.0.9: 2011-01-29
4
11
 
5
12
  === Improvements
@@ -35,8 +35,8 @@ LGPL 2.1です。詳しくはlicense/LGPLを見てください。
35
35
 
36
36
  == 依存ソフトウェア
37
37
 
38
- * Ruby >= 1.8 (1.9.1, 1.9.2対応)
39
- * groonga >= 1.0.4
38
+ * Ruby >= 1.8 (1.9.2対応)
39
+ * groonga >= 1.1.0
40
40
 
41
41
  == インストール
42
42
 
@@ -35,8 +35,8 @@ inclidng contributed patches.)
35
35
 
36
36
  == Dependencies
37
37
 
38
- * Ruby >= 1.8 (including 1.9.1 and 1.9.2)
39
- * groonga >= 1.0.4
38
+ * Ruby >= 1.8 (including 1.9.2)
39
+ * groonga >= 1.1.0
40
40
 
41
41
  == Install
42
42
 
@@ -63,7 +63,7 @@ checked program was:
63
63
  "gcc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/home/kou/work/ruby/rroonga.18/ext/groonga -fno-strict-aliasing -g -g -O2 -fPIC -Wall -I/tmp/local/include/groonga conftest.c -L. -L/usr/lib -L. -rdynamic -Wl,-export-dynamic -L/tmp/local/lib -lgroonga -lruby1.8-static -lgroonga -lpthread -lrt -ldl -lcrypt -lm -lc"
64
64
  conftest.c: In function ‘t’:
65
65
  conftest.c:5: warning: implicit declaration of function ‘rb_errinfo’
66
- /tmp/ccjMtfaX.o: In function `t':
66
+ /tmp/cclVRR3N.o: In function `t':
67
67
  /home/kou/work/ruby/rroonga.18/ext/groonga/conftest.c:5: undefined reference to `rb_errinfo'
68
68
  collect2: ld returned 1 exit status
69
69
  checked program was:
@@ -569,16 +569,22 @@ static VALUE
569
569
  rb_grn_context_receive (VALUE self)
570
570
  {
571
571
  grn_ctx *context;
572
- char *string;
573
- unsigned string_size;
572
+ char *result = NULL;
573
+ unsigned result_size;
574
+ VALUE rb_result;
574
575
  int flags = 0;
575
576
  unsigned int query_id;
576
577
 
577
578
  context = SELF(self);
578
- query_id = grn_ctx_recv(context, &string, &string_size, &flags);
579
+ query_id = grn_ctx_recv(context, &result, &result_size, &flags);
580
+ if (result) {
581
+ rb_result = rb_str_new(result, result_size);
582
+ } else {
583
+ rb_result = Qnil;
584
+ }
579
585
  rb_grn_context_check(context, self);
580
586
 
581
- return rb_ary_new3(2, UINT2NUM(query_id), rb_str_new(string, string_size));
587
+ return rb_ary_new3(2, UINT2NUM(query_id), rb_result);
582
588
  }
583
589
 
584
590
  static const char *
@@ -0,0 +1,134 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ Copyright (C) 2011 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
+
19
+ #include "rb-grn.h"
20
+
21
+ #define SELF(object) (RVAL2GRNCONTEXT(object))
22
+
23
+ static VALUE cGrnPlugin;
24
+
25
+ /*
26
+ * Document-class: Groonga::Plugin
27
+ *
28
+ * プラグイン。現在のところ、Rubyでgroongaのプラグインを作成
29
+ * することはできず、Cで作成された既存のプラグインを登録する
30
+ * ことができるだけです。
31
+ */
32
+
33
+ grn_id
34
+ rb_grn_plugin_from_ruby_object (VALUE object)
35
+ {
36
+ RbGrnPlugin *rb_grn_plugin;
37
+
38
+ if (!RVAL2CBOOL(rb_obj_is_kind_of(object, cGrnPlugin))) {
39
+ rb_raise(rb_eTypeError, "not a groonga plugin");
40
+ }
41
+
42
+ Data_Get_Struct(object, RbGrnPlugin, rb_grn_plugin);
43
+ if (!rb_grn_plugin)
44
+ rb_raise(rb_eGrnError, "groonga plugin is NULL");
45
+ return rb_grn_plugin->id;
46
+ }
47
+
48
+ void
49
+ rb_grn_plugin_fin (grn_id id)
50
+ {
51
+ }
52
+
53
+ static void
54
+ rb_grn_plugin_free (void *pointer)
55
+ {
56
+ RbGrnPlugin *rb_grn_plugin = pointer;
57
+
58
+ xfree(rb_grn_plugin);
59
+ }
60
+
61
+ static VALUE
62
+ rb_grn_plugin_alloc (VALUE klass)
63
+ {
64
+ return Data_Wrap_Struct(klass, NULL, rb_grn_plugin_free, NULL);
65
+ }
66
+
67
+ /*
68
+ * call-seq:
69
+ * Groonga::Plugin.register(name, options=nil)
70
+ * Groonga::Plugin.register({:path => path, :context => nil})
71
+ *
72
+ * 既存のプラグインをデータベースに登録する。
73
+ *
74
+ * _name_を指定した場合はその名前のプラグインを登録する。
75
+ *
76
+ * _path_を指定した場合はそのパスのプラグインを登録する。
77
+ *
78
+ * _options_にはハッシュでオプションを指定する。指定できるオ
79
+ * プションは以下の通り。
80
+ *
81
+ * [+:context+]
82
+ * データベースを結びつけるコンテキスト。省略すると
83
+ * Groonga::Context.defaultを利用する。
84
+ */
85
+ static VALUE
86
+ rb_grn_plugin_s_register (int argc, VALUE *argv, VALUE klass)
87
+ {
88
+ const char *name = NULL, *path = NULL;
89
+ VALUE rb_options, rb_name = Qnil, rb_path, rb_context;
90
+ grn_ctx *context;
91
+
92
+ if (argc >= 1) {
93
+ rb_name = rb_check_string_type(argv[0]);
94
+ }
95
+
96
+ if (NIL_P(rb_name)) {
97
+ rb_scan_args(argc, argv, "01", &rb_options);
98
+ rb_grn_scan_options(rb_options,
99
+ "path", &rb_path,
100
+ "context", &rb_context,
101
+ NULL);
102
+ path = StringValueCStr(rb_path);
103
+ } else {
104
+ rb_scan_args(argc, argv, "11", &rb_name, &rb_options);
105
+ rb_grn_scan_options(rb_options,
106
+ "context", &rb_context,
107
+ NULL);
108
+ name = StringValueCStr(rb_name);
109
+ }
110
+
111
+ if (NIL_P(rb_context)) {
112
+ rb_context = rb_grn_context_get_default();
113
+ }
114
+ context = RVAL2GRNCONTEXT(rb_context);
115
+
116
+ if (name) {
117
+ grn_plugin_register(context, name);
118
+ } else {
119
+ grn_plugin_register_by_path(context, path);
120
+ }
121
+
122
+ rb_grn_context_check(context, rb_ary_new4(argc, argv));
123
+ return Qnil;
124
+ }
125
+
126
+ void
127
+ rb_grn_init_plugin (VALUE mGrn)
128
+ {
129
+ cGrnPlugin = rb_define_class_under(mGrn, "Plugin", rb_cObject);
130
+ rb_define_alloc_func(cGrnPlugin, rb_grn_plugin_alloc);
131
+
132
+ rb_define_singleton_method(cGrnPlugin, "register",
133
+ rb_grn_plugin_s_register, -1);
134
+ }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby" -*- */
2
2
  /*
3
- Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
4
 
5
5
  This library is free software; you can redistribute it and/or
6
6
  modify it under the terms of the GNU Lesser General Public
@@ -68,8 +68,8 @@ RB_GRN_BEGIN_DECLS
68
68
  #endif
69
69
 
70
70
  #define RB_GRN_MAJOR_VERSION 1
71
- #define RB_GRN_MINOR_VERSION 0
72
- #define RB_GRN_MICRO_VERSION 9
71
+ #define RB_GRN_MINOR_VERSION 1
72
+ #define RB_GRN_MICRO_VERSION 0
73
73
 
74
74
  #define RB_GRN_QUERY_DEFAULT_MAX_EXPRESSIONS 32
75
75
 
@@ -174,6 +174,14 @@ struct _RbGrnExpression
174
174
  grn_obj *value;
175
175
  };
176
176
 
177
+ typedef struct _RbGrnPlugin RbGrnPlugin;
178
+ struct _RbGrnPlugin
179
+ {
180
+ VALUE self;
181
+ grn_ctx *context;
182
+ grn_id id;
183
+ };
184
+
177
185
  RB_GRN_VAR grn_bool rb_grn_exited;
178
186
 
179
187
  RB_GRN_VAR VALUE rb_eGrnError;
@@ -213,6 +221,7 @@ RB_GRN_VAR VALUE rb_cGrnOperator;
213
221
  RB_GRN_VAR VALUE rb_cGrnExpression;
214
222
  RB_GRN_VAR VALUE rb_cGrnRecordExpressionBuilder;
215
223
  RB_GRN_VAR VALUE rb_cGrnColumnExpressionBuilder;
224
+ RB_GRN_VAR VALUE rb_cGrnPlugin;
216
225
 
217
226
  void rb_grn_init_utils (VALUE mGrn);
218
227
  void rb_grn_init_exception (VALUE mGrn);
@@ -250,6 +259,7 @@ void rb_grn_init_expression (VALUE mGrn);
250
259
  void rb_grn_init_expression_builder (VALUE mGrn);
251
260
  void rb_grn_init_logger (VALUE mGrn);
252
261
  void rb_grn_init_snippet (VALUE mGrn);
262
+ void rb_grn_init_plugin (VALUE mGrn);
253
263
 
254
264
  VALUE rb_grn_rc_to_exception (grn_rc rc);
255
265
  const char *rb_grn_rc_to_message (grn_rc rc);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby" -*- */
2
2
  /*
3
- Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
3
+ Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
4
 
5
5
  This library is free software; you can redistribute it and/or
6
6
  modify it under the terms of the GNU Lesser General Public
@@ -143,4 +143,5 @@ Init_groonga (void)
143
143
  rb_grn_init_expression_builder(mGrn);
144
144
  rb_grn_init_logger(mGrn);
145
145
  rb_grn_init_snippet(mGrn);
146
+ rb_grn_init_plugin(mGrn);
146
147
  }
@@ -49,7 +49,7 @@
49
49
 
50
50
  <h3>rroongaの最新リリース</h3>
51
51
  <p>
52
- 2011-01-29にリリースされた1.0.9が最新です。
52
+ 2011-02-09にリリースされた1.1.0が最新です。
53
53
  </p>
54
54
 
55
55
  <h3 id="install-rroonga">rroongaのインストール</h3>
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2010-2011 Kouhei Sutou <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -51,6 +51,23 @@ module Groonga
51
51
  Database.create(options)
52
52
  end
53
53
 
54
+ # call-seq:
55
+ # context.register_plugin(name)
56
+ # context.register_plugin({:path => path})
57
+ #
58
+ # groongaのプラグインディレクトリにあるプラグイン_name_
59
+ # を登録する。_path_を指定するとプラグインディレクトリ以
60
+ # 外にあるプラグインを登録することができる。
61
+ def register_plugin(name_or_options)
62
+ options = {:context => self}
63
+ if name_or_options.is_a?(String)
64
+ name = name_or_options
65
+ Plugin.register(name, options)
66
+ else
67
+ Plugin.register(name_or_options.merge(options))
68
+ end
69
+ end
70
+
54
71
  # call-seq:
55
72
  # context.select(table, options={}) -> SelectResult
56
73
  #
@@ -18,8 +18,8 @@
18
18
  module RroongaBuild
19
19
  module RequiredGroongaVersion
20
20
  MAJOR = 1
21
- MINOR = 0
22
- MICRO = 7
21
+ MINOR = 1
22
+ MICRO = 0
23
23
  VERSION = [MAJOR, MINOR, MICRO]
24
24
  end
25
25
 
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2011 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 version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ class PluginTest < Test::Unit::TestCase
17
+ include GroongaTestUtils
18
+
19
+ setup :setup_sandbox
20
+ setup :setup_database
21
+ teardown :teardown_sandbox
22
+
23
+ def test_register
24
+ context = Groonga::Context.default
25
+ assert_nil(context["suggest"])
26
+ context.register_plugin("suggest/suggest")
27
+ assert_not_nil(context["suggest"])
28
+ end
29
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rroonga
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 1.0.9
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kouhei Sutou
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2011-01-28 00:00:00 +09:00
22
+ date: 2011-02-08 00:00:00 +09:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -98,6 +98,7 @@ files:
98
98
  - ext/groonga/rb-grn-operator.c
99
99
  - ext/groonga/rb-grn-patricia-trie-cursor.c
100
100
  - ext/groonga/rb-grn-patricia-trie.c
101
+ - ext/groonga/rb-grn-plugin.c
101
102
  - ext/groonga/rb-grn-procedure.c
102
103
  - ext/groonga/rb-grn-query.c
103
104
  - ext/groonga/rb-grn-record.c
@@ -240,6 +241,7 @@ files:
240
241
  - test/test-logger.rb
241
242
  - test/test-pagination.rb
242
243
  - test/test-patricia-trie.rb
244
+ - test/test-plugin.rb
243
245
  - test/test-procedure.rb
244
246
  - test/test-query.rb
245
247
  - test/test-record.rb