groonga 0.9.1 → 1.0.0

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 (186) hide show
  1. metadata +38 -227
  2. data/AUTHORS +0 -5
  3. data/NEWS.ja.rdoc +0 -114
  4. data/NEWS.rdoc +0 -116
  5. data/README.ja.rdoc +0 -63
  6. data/README.rdoc +0 -64
  7. data/Rakefile +0 -216
  8. data/benchmark/common.rb +0 -49
  9. data/benchmark/read-write-many-small-items.rb +0 -144
  10. data/benchmark/write-many-small-items.rb +0 -135
  11. data/example/bookmark.rb +0 -161
  12. data/example/index-html.rb +0 -89
  13. data/example/search/config.ru +0 -211
  14. data/example/search/public/css/groonga.css +0 -122
  15. data/ext/.gitignore +0 -2
  16. data/ext/rb-grn-accessor.c +0 -52
  17. data/ext/rb-grn-array-cursor.c +0 -36
  18. data/ext/rb-grn-array.c +0 -210
  19. data/ext/rb-grn-column.c +0 -570
  20. data/ext/rb-grn-context.c +0 -655
  21. data/ext/rb-grn-database.c +0 -415
  22. data/ext/rb-grn-encoding-support.c +0 -64
  23. data/ext/rb-grn-encoding.c +0 -257
  24. data/ext/rb-grn-exception.c +0 -1110
  25. data/ext/rb-grn-expression-builder.c +0 -75
  26. data/ext/rb-grn-expression.c +0 -732
  27. data/ext/rb-grn-fix-size-column.c +0 -166
  28. data/ext/rb-grn-hash-cursor.c +0 -38
  29. data/ext/rb-grn-hash.c +0 -294
  30. data/ext/rb-grn-index-column.c +0 -488
  31. data/ext/rb-grn-logger.c +0 -325
  32. data/ext/rb-grn-object.c +0 -1335
  33. data/ext/rb-grn-operation.c +0 -198
  34. data/ext/rb-grn-patricia-trie-cursor.c +0 -39
  35. data/ext/rb-grn-patricia-trie.c +0 -488
  36. data/ext/rb-grn-procedure.c +0 -52
  37. data/ext/rb-grn-query.c +0 -260
  38. data/ext/rb-grn-record.c +0 -40
  39. data/ext/rb-grn-snippet.c +0 -328
  40. data/ext/rb-grn-table-cursor-key-support.c +0 -69
  41. data/ext/rb-grn-table-cursor.c +0 -246
  42. data/ext/rb-grn-table-key-support.c +0 -731
  43. data/ext/rb-grn-table.c +0 -2038
  44. data/ext/rb-grn-type.c +0 -181
  45. data/ext/rb-grn-utils.c +0 -769
  46. data/ext/rb-grn-variable-size-column.c +0 -36
  47. data/ext/rb-grn-variable.c +0 -108
  48. data/ext/rb-grn.h +0 -684
  49. data/ext/rb-groonga.c +0 -113
  50. data/extconf.rb +0 -216
  51. data/html/bar.svg +0 -153
  52. data/html/developer.html +0 -121
  53. data/html/developer.svg +0 -469
  54. data/html/download.svg +0 -253
  55. data/html/favicon.ico +0 -0
  56. data/html/favicon.xcf +0 -0
  57. data/html/footer.html.erb +0 -28
  58. data/html/head.html.erb +0 -4
  59. data/html/header.html.erb +0 -17
  60. data/html/index.html +0 -147
  61. data/html/install.svg +0 -636
  62. data/html/logo.xcf +0 -0
  63. data/html/ranguba.css +0 -248
  64. data/html/tutorial.svg +0 -559
  65. data/lib/groonga.rb +0 -83
  66. data/lib/groonga/expression-builder.rb +0 -285
  67. data/lib/groonga/patricia-trie.rb +0 -53
  68. data/lib/groonga/record.rb +0 -276
  69. data/lib/groonga/schema.rb +0 -916
  70. data/license/GPL +0 -340
  71. data/license/LGPL +0 -504
  72. data/license/RUBY +0 -59
  73. data/misc/grnop2ruby.rb +0 -49
  74. data/pkg-config.rb +0 -333
  75. data/src/rb-grn-table-cursor.c +0 -296
  76. data/test-unit/Rakefile +0 -40
  77. data/test-unit/TODO +0 -5
  78. data/test-unit/bin/testrb +0 -5
  79. data/test-unit/html/classic.html +0 -15
  80. data/test-unit/html/index.html +0 -25
  81. data/test-unit/html/index.html.ja +0 -27
  82. data/test-unit/lib/test/unit.rb +0 -323
  83. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  84. data/test-unit/lib/test/unit/assertions.rb +0 -1230
  85. data/test-unit/lib/test/unit/attribute.rb +0 -125
  86. data/test-unit/lib/test/unit/autorunner.rb +0 -353
  87. data/test-unit/lib/test/unit/collector.rb +0 -36
  88. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  89. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  90. data/test-unit/lib/test/unit/collector/load.rb +0 -136
  91. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  92. data/test-unit/lib/test/unit/color-scheme.rb +0 -102
  93. data/test-unit/lib/test/unit/color.rb +0 -96
  94. data/test-unit/lib/test/unit/diff.rb +0 -724
  95. data/test-unit/lib/test/unit/error.rb +0 -130
  96. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  97. data/test-unit/lib/test/unit/failure.rb +0 -136
  98. data/test-unit/lib/test/unit/fixture.rb +0 -176
  99. data/test-unit/lib/test/unit/notification.rb +0 -129
  100. data/test-unit/lib/test/unit/omission.rb +0 -191
  101. data/test-unit/lib/test/unit/pending.rb +0 -150
  102. data/test-unit/lib/test/unit/priority.rb +0 -181
  103. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  104. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  105. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  106. data/test-unit/lib/test/unit/testcase.rb +0 -476
  107. data/test-unit/lib/test/unit/testresult.rb +0 -89
  108. data/test-unit/lib/test/unit/testsuite.rb +0 -110
  109. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  110. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -464
  111. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  112. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -92
  113. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -28
  114. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
  115. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  116. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -41
  117. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  118. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  119. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  120. data/test-unit/lib/test/unit/version.rb +0 -7
  121. data/test-unit/sample/adder.rb +0 -13
  122. data/test-unit/sample/subtracter.rb +0 -12
  123. data/test-unit/sample/test_adder.rb +0 -20
  124. data/test-unit/sample/test_subtracter.rb +0 -20
  125. data/test-unit/sample/test_user.rb +0 -23
  126. data/test-unit/test/collector/test-descendant.rb +0 -133
  127. data/test-unit/test/collector/test-load.rb +0 -329
  128. data/test-unit/test/collector/test_dir.rb +0 -406
  129. data/test-unit/test/collector/test_objectspace.rb +0 -100
  130. data/test-unit/test/run-test.rb +0 -15
  131. data/test-unit/test/test-attribute.rb +0 -86
  132. data/test-unit/test/test-color-scheme.rb +0 -67
  133. data/test-unit/test/test-color.rb +0 -47
  134. data/test-unit/test/test-diff.rb +0 -518
  135. data/test-unit/test/test-emacs-runner.rb +0 -60
  136. data/test-unit/test/test-fixture.rb +0 -287
  137. data/test-unit/test/test-notification.rb +0 -33
  138. data/test-unit/test/test-omission.rb +0 -81
  139. data/test-unit/test/test-pending.rb +0 -70
  140. data/test-unit/test/test-priority.rb +0 -119
  141. data/test-unit/test/test-testcase.rb +0 -554
  142. data/test-unit/test/test_assertions.rb +0 -1151
  143. data/test-unit/test/test_error.rb +0 -26
  144. data/test-unit/test/test_failure.rb +0 -33
  145. data/test-unit/test/test_testresult.rb +0 -113
  146. data/test-unit/test/test_testsuite.rb +0 -129
  147. data/test-unit/test/testunit-test-util.rb +0 -14
  148. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  149. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  150. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  151. data/test-unit/test/util/test_observable.rb +0 -102
  152. data/test-unit/test/util/test_procwrapper.rb +0 -36
  153. data/test/.gitignore +0 -1
  154. data/test/groonga-test-utils.rb +0 -106
  155. data/test/run-test.rb +0 -58
  156. data/test/test-array.rb +0 -97
  157. data/test/test-column.rb +0 -298
  158. data/test/test-context.rb +0 -73
  159. data/test/test-database.rb +0 -113
  160. data/test/test-encoding.rb +0 -33
  161. data/test/test-exception.rb +0 -93
  162. data/test/test-expression-builder.rb +0 -156
  163. data/test/test-expression.rb +0 -133
  164. data/test/test-fix-size-column.rb +0 -65
  165. data/test/test-gqtp.rb +0 -70
  166. data/test/test-hash.rb +0 -312
  167. data/test/test-index-column.rb +0 -81
  168. data/test/test-patricia-trie.rb +0 -189
  169. data/test/test-procedure.rb +0 -37
  170. data/test/test-query.rb +0 -22
  171. data/test/test-record.rb +0 -268
  172. data/test/test-remote.rb +0 -53
  173. data/test/test-schema.rb +0 -416
  174. data/test/test-snippet.rb +0 -121
  175. data/test/test-table-cursor.rb +0 -153
  176. data/test/test-table-offset-and-limit.rb +0 -102
  177. data/test/test-table-select-normalize.rb +0 -48
  178. data/test/test-table-select.rb +0 -145
  179. data/test/test-table.rb +0 -642
  180. data/test/test-type.rb +0 -61
  181. data/test/test-variable-size-column.rb +0 -98
  182. data/test/test-variable.rb +0 -28
  183. data/test/test-vector-column.rb +0 -76
  184. data/test/test-version.rb +0 -31
  185. data/text/TUTORIAL.ja.rdoc +0 -392
  186. data/text/expression.rdoc +0 -284
data/license/RUBY DELETED
@@ -1,59 +0,0 @@
1
- Rcairo is copyrighted free software by the persons listed in AUTHORS
2
- distributed under the same conditions as ruby; which follow:
3
-
4
- Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
5
- You can redistribute it and/or modify it under either the terms of the GPL
6
- (see the file GPL), or the conditions below:
7
-
8
- 1. You may make and give away verbatim copies of the source form of the
9
- software without restriction, provided that you duplicate all of the
10
- original copyright notices and associated disclaimers.
11
-
12
- 2. You may modify your copy of the software in any way, provided that
13
- you do at least ONE of the following:
14
-
15
- a) place your modifications in the Public Domain or otherwise
16
- make them Freely Available, such as by posting said
17
- modifications to Usenet or an equivalent medium, or by allowing
18
- the author to include your modifications in the software.
19
-
20
- b) use the modified software only within your corporation or
21
- organization.
22
-
23
- c) give non-standard binaries non-standard names, with
24
- instructions on where to get the original software distribution.
25
-
26
- d) make other distribution arrangements with the author.
27
-
28
- 3. You may distribute the software in object code or binary form,
29
- provided that you do at least ONE of the following:
30
-
31
- a) distribute the binaries and library files of the software,
32
- together with instructions (in the manual page or equivalent)
33
- on where to get the original distribution.
34
-
35
- b) accompany the distribution with the machine-readable source of
36
- the software.
37
-
38
- c) give non-standard binaries non-standard names, with
39
- instructions on where to get the original software distribution.
40
-
41
- d) make other distribution arrangements with the author.
42
-
43
- 4. You may modify and include the part of the software into any other
44
- software (possibly commercial). But some files in the distribution
45
- are not written by the author, so that they are not under these terms.
46
-
47
- For the list of those files and their copying conditions, see the
48
- file LEGAL.
49
-
50
- 5. The scripts and library files supplied as input to or produced as
51
- output from the software do not automatically fall under the
52
- copyright of the software, but belong to whomever generated them,
53
- and may be sold commercially, and may be aggregated with this
54
- software.
55
-
56
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
- PURPOSE.
data/misc/grnop2ruby.rb DELETED
@@ -1,49 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2009 Yuto Hayamizu <y.hayamizu@gmail.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
- # This script expects "groonga.h" as a first argument, extracts the
20
- # 'grn_operator', and write 'rb_define_const's of 'grn_operator' to
21
- # standard outout.
22
- #
23
- # Usage:
24
- # ruby grnop2ruby.rb /path/to/groonga.h
25
- #
26
-
27
- replace_dictionary = {
28
- "VAR" => "VARIABLE",
29
- "EXPR" => "EXPRESSION",
30
- "NOP" => "NO_OPERATION",
31
- "REF" => "REFERENCE",
32
- "OBJ" => "OBJECT",
33
- "INCR" => "INCREMENT",
34
- "DECR" => "DECREMENT",
35
- "MOD" => "MODULO",
36
- "LCP" => "LONGEST_COMMON_PREFIX",
37
- }
38
-
39
- ARGF.each_line do |line|
40
- case line
41
- when /\A\s+(GRN_OP_\w+)/
42
- operator = $1
43
- rb_operator = operator.gsub(/\AGRN_OP_/, "").split("_").map{ |word|
44
- replace_dictionary[word] || word
45
- }.join("_")
46
- puts " rb_define_const(rb_mGrnOperation, \"%s\",
47
- UINT2NUM(%s));" % [rb_operator, operator]
48
- end
49
- end
data/pkg-config.rb DELETED
@@ -1,333 +0,0 @@
1
- # Copyright 2008-2009 Kouhei Sutou <kou@cozmixng.org>
2
- # This file is made available under the same terms as Ruby.
3
-
4
- require "rbconfig"
5
-
6
- require 'mkmf'
7
- require 'shellwords'
8
- require 'English'
9
- require 'pathname'
10
-
11
- class PackageConfig
12
- @@default_prepend_paths = []
13
- @@default_append_paths = []
14
-
15
- class << self
16
- def prepend_default_path(path)
17
- @@default_prepend_paths.unshift(path)
18
- end
19
-
20
- def append_default_path(path)
21
- @@default_append_paths << path
22
- end
23
- end
24
-
25
- attr_accessor :msvc_syntax
26
- def initialize(name, path=nil, msvc_syntax=false)
27
- @name = name
28
- @path = path || ENV["PKG_CONFIG_PATH"]
29
- @path = [@path, guess_default_path].compact.join(separator)
30
- @msvc_syntax = msvc_syntax
31
- @variables = @declarations = nil
32
- override_variables = with_config("override-variables", "")
33
- @override_variables = parse_override_variables(override_variables)
34
- end
35
-
36
- def exist?
37
- not pc.nil?
38
- end
39
-
40
- def requires
41
- parse_requires(declaration("Requires"))
42
- end
43
-
44
- def requires_private
45
- parse_requires(declaration("Requires.private"))
46
- end
47
-
48
- def cflags
49
- path_flags, other_flags = collect_cflags
50
- (other_flags + path_flags).join(" ")
51
- end
52
-
53
- def cflags_only_I
54
- collect_cflags[0].join(" ")
55
- end
56
-
57
- def libs
58
- path_flags, other_flags = collect_libs
59
- (other_flags + path_flags).join(" ")
60
- end
61
-
62
- def libs_only_l
63
- collect_libs[1].find_all do |arg|
64
- if @msvc_syntax
65
- /\.lib\z/ =~ arg
66
- else
67
- /\A-l/ =~ arg
68
- end
69
- end.join(" ")
70
- end
71
-
72
- def version
73
- declaration("Version")
74
- end
75
-
76
- def variable(name)
77
- parse_pc if @variables.nil?
78
- expand_value(@override_variables[name] || @variables[name])
79
- end
80
-
81
- def declaration(name)
82
- parse_pc if @declarations.nil?
83
- expand_value(@declarations[name])
84
- end
85
-
86
- private
87
- def paths
88
- paths = @@default_prepend_paths
89
- paths += @path.split(separator)
90
- paths += @@default_append_paths
91
- paths
92
- end
93
-
94
- def pc
95
- paths.each do |path|
96
- pc_name = File.join(path, "#{@name}.pc")
97
- return pc_name if File.exist?(pc_name)
98
- end
99
- return nil
100
- end
101
-
102
- def separator
103
- File.expand_path(".").index(":") ? ";" : ":"
104
- end
105
-
106
- def collect_cflags
107
- all_cflags = (requires_private + requires.reverse).collect do |package|
108
- self.class.new(package, @path, @msvc_syntax).cflags
109
- end
110
- all_cflags = [declaration("Cflags")] + all_cflags
111
- all_cflags = all_cflags.join(" ").gsub(/-I /, '-I').split.uniq
112
- path_flags, other_flags = all_cflags.partition {|flag| /\A-I/ =~ flag}
113
- path_flags = path_flags.reject do |flag|
114
- flag == "-I/usr/include"
115
- end
116
- if @msvc_syntax
117
- path_flags = path_flags.collect do |flag|
118
- flag.gsub(/\A-I/, "/I")
119
- end
120
- end
121
- [path_flags, other_flags]
122
- end
123
-
124
- def collect_libs
125
- all_libs = requires.collect do |package|
126
- self.class.new(package, @path, @msvc_syntax).libs
127
- end
128
- all_libs = [declaration("Libs")] + all_libs
129
- all_libs = all_libs.join(" ").gsub(/-([Ll]) /, '\1').split.uniq
130
- path_flags, other_flags = all_libs.partition {|flag| /\A-L/ =~ flag}
131
- path_flags = path_flags.reject do |flag|
132
- /\A-L\/usr\/lib(?:64)?\z/ =~ flag
133
- end
134
- if @msvc_syntax
135
- path_flags = path_flags.collect do |flag|
136
- flag.gsub(/\A-L/, "/libpath:")
137
- end
138
- other_flags = other_flags.collect do |flag|
139
- if /\A-l/ =~ flag
140
- "#{$POSTMATCH}.lib"
141
- else
142
- flag
143
- end
144
- end
145
- end
146
- [path_flags, other_flags]
147
- end
148
-
149
- IDENTIFIER_RE = /[\w.]+/
150
- def parse_pc
151
- raise ".pc for #{@name} doesn't exist." unless exist?
152
- @variables = {}
153
- @declarations = {}
154
- File.open(pc) do |input|
155
- input.each_line do |line|
156
- line = line.gsub(/#.*/, '').strip
157
- next if line.empty?
158
- case line
159
- when /^(#{IDENTIFIER_RE})=/
160
- @variables[$1] = $POSTMATCH.strip
161
- when /^(#{IDENTIFIER_RE}):/
162
- @declarations[$1] = $POSTMATCH.strip
163
- end
164
- end
165
- end
166
- end
167
-
168
- def parse_requires(requires)
169
- return [] if requires.nil?
170
- requires_without_version = requires.gsub(/[<>]?=\s*[\d.]+\s*/, '')
171
- requires_without_version.split(/[,\s]+/)
172
- end
173
-
174
- def parse_override_variables(override_variables)
175
- variables = {}
176
- override_variables.split(",").each do |variable|
177
- name, value = variable.split("=", 2)
178
- variables[name] = value
179
- end
180
- variables
181
- end
182
-
183
- def expand_value(value)
184
- return nil if value.nil?
185
- value.gsub(/\$\{(#{IDENTIFIER_RE})\}/) do
186
- variable($1)
187
- end
188
- end
189
-
190
- def search_pkg_config_from_path(pkg_config)
191
- (ENV["PATH"] || "").split(separator).each do |path|
192
- try_pkg_config = Pathname(path) + pkg_config
193
- return try_pkg_config if try_pkg_config.exist?
194
- end
195
- nil
196
- end
197
-
198
- def search_pkg_config_by_dln_find_exe(pkg_config)
199
- begin
200
- require "dl/import"
201
- rescue LoadError
202
- return nil
203
- end
204
- dln = Module.new
205
- dln.module_eval do
206
- if DL.const_defined?(:Importer)
207
- extend DL::Importer
208
- else
209
- extend DL::Importable
210
- end
211
- begin
212
- dlload RbConfig::CONFIG["LIBRUBY"]
213
- rescue RuntimeError
214
- return nil if $!.message == "unknown error"
215
- return nil if /: image not found\z/ =~ $!.message
216
- raise
217
- rescue DL::DLError
218
- return nil
219
- end
220
- extern "const char *dln_find_exe(const char *, const char *)"
221
- end
222
- path = dln.dln_find_exe(pkg_config.to_s, nil)
223
- if path.size.zero?
224
- nil
225
- else
226
- Pathname(path.to_s)
227
- end
228
- end
229
-
230
- def guess_default_path
231
- default_path = ["/usr/local/lib64/pkgconfig",
232
- "/usr/local/lib/pkgconfig",
233
- "/usr/local/libdata/pkgconfig",
234
- "/opt/local/lib/pkgconfig",
235
- "/usr/lib64/pkgconfig",
236
- "/usr/lib/pkgconfig",
237
- "/usr/X11/lib/pkgconfig/",
238
- "/usr/share/pkgconfig"].join(separator)
239
- libdir = ENV["PKG_CONFIG_LIBDIR"]
240
- default_path = [libdir, default_path].join(separator) if libdir
241
-
242
- pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config")
243
- pkg_config = Pathname.new(pkg_config)
244
- unless pkg_config.absolute?
245
- found_pkg_config = search_pkg_config_from_path(pkg_config)
246
- pkg_config = found_pkg_config if found_pkg_config
247
- end
248
- unless pkg_config.absolute?
249
- found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
250
- pkg_config = found_pkg_config if found_pkg_config
251
- end
252
-
253
- return default_path unless pkg_config.absolute?
254
- [(pkg_config.parent.parent + "lib" + "pkgconfig").to_s,
255
- (pkg_config.parent.parent + "libdata" + "pkgconfig").to_s,
256
- default_path].join(separator)
257
- end
258
- end
259
-
260
- module PKGConfig
261
- module_function
262
- def msvc?
263
- /mswin32/.match(RUBY_PLATFORM) and /^cl\b/.match(Config::CONFIG['CC'])
264
- end
265
-
266
- def package_config(package)
267
- PackageConfig.new(package, nil, msvc?)
268
- end
269
-
270
- def exist?(pkg)
271
- package_config(pkg).exist?
272
- end
273
-
274
- def libs(pkg)
275
- package_config(pkg).libs
276
- end
277
-
278
- def libs_only_l(pkg)
279
- package_config(pkg).libs_only_l
280
- end
281
-
282
- def cflags(pkg)
283
- package_config(pkg).cflags
284
- end
285
-
286
- def cflags_only_I(pkg)
287
- package_config(pkg).cflags_only_I
288
- end
289
-
290
- def modversion(pkg)
291
- package_config(pkg).version
292
- end
293
-
294
- def check_version?(pkg, major = 0, minor = 0, micro = 0)
295
- return false unless exist?(pkg)
296
- ver = modversion(pkg).split(".").collect{|item| item.to_i}
297
- (0..2).each {|i| ver[i] = 0 unless ver[i]}
298
-
299
- (ver[0] > major ||
300
- (ver[0] == major && ver[1] > minor) ||
301
- (ver[0] == major && ver[1] == minor &&
302
- ver[2] >= micro))
303
- end
304
-
305
- def have_package(pkg, major = nil, minor = 0, micro = 0)
306
- if major.nil?
307
- STDOUT.print("checking for #{pkg}... ")
308
- else
309
- STDOUT.print("checking for #{pkg} version (>= #{major}.#{minor}.#{micro})... ")
310
- end
311
- major ||= 0
312
- STDOUT.flush
313
- if check_version?(pkg, major, minor, micro)
314
- STDOUT.print "yes\n"
315
- libraries = libs_only_l(pkg)
316
- dldflags = libs(pkg)
317
- dldflags = (Shellwords.shellwords(dldflags) -
318
- Shellwords.shellwords(libraries))
319
- dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
320
- $libs += ' ' + libraries
321
- if /mswin32/ =~ RUBY_PLATFORM
322
- $DLDFLAGS += ' ' + dldflags
323
- else
324
- $LDFLAGS += ' ' + dldflags
325
- end
326
- $CFLAGS += ' ' + cflags(pkg)
327
- true
328
- else
329
- STDOUT.print "no\n"
330
- false
331
- end
332
- end
333
- end
@@ -1,296 +0,0 @@
1
- /* -*- c-file-style: "ruby" -*- */
2
- /*
3
- Copyright (C) 2009 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) (rb_rb_grn_table_cursor_from_ruby_object(object))
22
-
23
- typedef struct _RbGrnTableCursor RbGrnTableCursor;
24
- struct _RbGrnTableCursor
25
- {
26
- grn_ctx *context;
27
- grn_table_cursor *cursor;
28
- rb_grn_boolean owner;
29
- };
30
-
31
- VALUE rb_cGrnTableCursor;
32
-
33
- static RbGrnTableCursor *
34
- rb_rb_grn_table_cursor_from_ruby_object (VALUE object)
35
- {
36
- RbGrnTableCursor *rb_grn_table_cursor;
37
-
38
- if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnTableCursor))) {
39
- rb_raise(rb_eTypeError, "not a groonga table cursor");
40
- }
41
-
42
- Data_Get_Struct(object, RbGrnTableCursor, rb_grn_table_cursor);
43
- if (!rb_grn_table_cursor)
44
- rb_raise(rb_eGrnError, "groonga table cursor is NULL");
45
-
46
- return rb_grn_table_cursor;
47
- }
48
-
49
- grn_table_cursor *
50
- rb_grn_table_cursor_from_ruby_object (VALUE object)
51
- {
52
- if (NIL_P(object))
53
- return NULL;
54
-
55
- return SELF(object)->cursor;
56
- }
57
-
58
- static void
59
- rb_rb_grn_table_cursor_free (void *object)
60
- {
61
- RbGrnTableCursor *rb_grn_table_cursor = object;
62
-
63
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor &&
64
- rb_grn_table_cursor->owner) {
65
- printf("close!\n");
66
- grn_table_cursor_close(rb_grn_table_cursor->context,
67
- rb_grn_table_cursor->cursor);
68
- }
69
- xfree(object);
70
- }
71
-
72
- VALUE
73
- rb_grn_table_cursor_to_ruby_class (grn_obj *object)
74
- {
75
- VALUE klass = Qnil;
76
-
77
- switch (object->header.type) {
78
- case GRN_CURSOR_TABLE_HASH_KEY:
79
- klass = rb_cGrnHashCursor;
80
- break;
81
- case GRN_CURSOR_TABLE_PAT_KEY:
82
- klass = rb_cGrnPatriciaTrieCursor;
83
- break;
84
- case GRN_CURSOR_TABLE_NO_KEY:
85
- klass = rb_cGrnArrayCursor;
86
- break;
87
- default:
88
- rb_raise(rb_eTypeError,
89
- "unsupported groonga object type: %d",
90
- object->header.type);
91
- break;
92
- }
93
-
94
- return klass;
95
- }
96
-
97
- VALUE
98
- rb_grn_table_cursor_to_ruby_object (VALUE klass, grn_ctx *context,
99
- grn_table_cursor *cursor)
100
- {
101
- RbGrnTableCursor *rb_grn_table_cursor;
102
-
103
- if (!cursor)
104
- return Qnil;
105
-
106
- rb_grn_table_cursor = ALLOC(RbGrnTableCursor);
107
- rb_grn_table_cursor->context = context;
108
- rb_grn_table_cursor->cursor = cursor;
109
- rb_grn_table_cursor->owner = RB_GRN_TRUE; /* FIXME */
110
-
111
- if (NIL_P(klass))
112
- klass = GRNTABLECURSOR2RCLASS(cursor);
113
-
114
- return Data_Wrap_Struct(klass, NULL,
115
- rb_rb_grn_table_cursor_free, rb_grn_table_cursor);
116
- }
117
-
118
- static VALUE
119
- rb_grn_table_cursor_alloc (VALUE klass)
120
- {
121
- return Data_Wrap_Struct(klass, NULL, rb_rb_grn_table_cursor_free, NULL);
122
- }
123
-
124
- grn_ctx *
125
- rb_grn_table_cursor_ensure_context (VALUE cursor, VALUE rb_context)
126
- {
127
- if (NIL_P(rb_context)) {
128
- RbGrnTableCursor *rb_grn_table_cursor;
129
-
130
- rb_grn_table_cursor = SELF(cursor);
131
- if (rb_grn_table_cursor && rb_grn_table_cursor->context)
132
- return rb_grn_table_cursor->context;
133
- }
134
-
135
- return rb_grn_context_ensure(rb_context);
136
- }
137
-
138
- VALUE
139
- rb_grn_table_cursor_close (VALUE self)
140
- {
141
- RbGrnTableCursor *rb_grn_table_cursor;
142
-
143
- rb_grn_table_cursor = SELF(self);
144
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor) {
145
- grn_rc rc = GRN_SUCCESS;
146
-
147
- if (rb_grn_table_cursor->owner)
148
- rc = grn_table_cursor_close(rb_grn_table_cursor->context,
149
- rb_grn_table_cursor->cursor);
150
- rb_grn_table_cursor->context = NULL;
151
- rb_grn_table_cursor->cursor = NULL;
152
- rb_grn_table_cursor->owner = RB_GRN_FALSE;
153
- rb_grn_rc_check(rc, self);
154
- }
155
- return Qnil;
156
- }
157
-
158
- static VALUE
159
- rb_grn_table_cursor_closed_p (VALUE self)
160
- {
161
- RbGrnTableCursor *rb_grn_table_cursor;
162
-
163
- rb_grn_table_cursor = SELF(self);
164
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor)
165
- return Qfalse;
166
- else
167
- return Qtrue;
168
- }
169
-
170
- static VALUE
171
- rb_grn_table_cursor_get_value (VALUE self)
172
- {
173
- VALUE rb_value = Qnil;
174
- RbGrnTableCursor *rb_grn_table_cursor;
175
-
176
- rb_grn_table_cursor = SELF(self);
177
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor) {
178
- int n;
179
- void *value;
180
-
181
- n = grn_table_cursor_get_value(rb_grn_table_cursor->context,
182
- rb_grn_table_cursor->cursor,
183
- &value);
184
- rb_value = rb_str_new(value, n);
185
- }
186
-
187
- return rb_value;
188
- }
189
-
190
- static VALUE
191
- rb_grn_table_cursor_set_value (VALUE self, VALUE value)
192
- {
193
- RbGrnTableCursor *rb_grn_table_cursor;
194
-
195
- rb_grn_table_cursor = SELF(self);
196
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor) {
197
- grn_rc rc;
198
-
199
- rc = grn_table_cursor_set_value(rb_grn_table_cursor->context,
200
- rb_grn_table_cursor->cursor,
201
- StringValuePtr(value), GRN_OBJ_SET);
202
- rb_grn_rc_check(rc, self);
203
- }
204
-
205
- return Qnil;
206
- }
207
-
208
- static VALUE
209
- rb_grn_table_cursor_delete (VALUE self)
210
- {
211
- RbGrnTableCursor *rb_grn_table_cursor;
212
-
213
- rb_grn_table_cursor = SELF(self);
214
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor) {
215
- grn_rc rc;
216
-
217
- rc = grn_table_cursor_delete(rb_grn_table_cursor->context,
218
- rb_grn_table_cursor->cursor);
219
- rb_grn_rc_check(rc, self);
220
- }
221
-
222
- return Qnil;
223
- }
224
-
225
- static VALUE
226
- rb_grn_table_cursor_next (VALUE self)
227
- {
228
- VALUE rb_record = Qnil;
229
- RbGrnTableCursor *rb_grn_table_cursor;
230
-
231
- rb_grn_table_cursor = SELF(self);
232
- if (rb_grn_table_cursor->context && rb_grn_table_cursor->cursor) {
233
- grn_id record_id;
234
-
235
- record_id = grn_table_cursor_next(rb_grn_table_cursor->context,
236
- rb_grn_table_cursor->cursor);
237
- if (record_id != GRN_ID_NIL) /* FIXME: use grn_table_cursor_table */
238
- rb_record = rb_grn_record_new(rb_iv_get(self, "@table"), record_id);
239
- }
240
-
241
- return rb_record;
242
- }
243
-
244
- static VALUE
245
- rb_grn_table_cursor_each (VALUE self)
246
- {
247
- grn_id record_id;
248
- RbGrnTableCursor *rb_grn_table_cursor;
249
- grn_ctx *context;
250
- grn_table_cursor *cursor;
251
-
252
- rb_grn_table_cursor = SELF(self);
253
- if (!rb_grn_table_cursor->context)
254
- return Qnil;
255
- if (!rb_grn_table_cursor->cursor)
256
- return Qnil;
257
-
258
- context = rb_grn_table_cursor->context;
259
- cursor = rb_grn_table_cursor->cursor;
260
- while ((record_id = grn_table_cursor_next(context, cursor))) {
261
- rb_yield(rb_grn_record_new(rb_iv_get(self, "@table"), record_id));
262
- }
263
-
264
- return Qnil;
265
- }
266
-
267
- void
268
- rb_grn_init_table_cursor (VALUE mGrn)
269
- {
270
- rb_cGrnTableCursor = rb_define_class_under(mGrn, "TableCurosr", rb_cObject);
271
- rb_define_alloc_func(rb_cGrnTableCursor, rb_grn_table_cursor_alloc);
272
-
273
- rb_include_module(rb_cGrnTableCursor, rb_mEnumerable);
274
-
275
- rb_define_method(rb_cGrnTableCursor, "close",
276
- rb_grn_table_cursor_close, 0);
277
- rb_define_method(rb_cGrnTableCursor, "closed?",
278
- rb_grn_table_cursor_closed_p, 0);
279
-
280
- rb_define_method(rb_cGrnTableCursor, "value",
281
- rb_grn_table_cursor_get_value, 0);
282
- rb_define_method(rb_cGrnTableCursor, "value=",
283
- rb_grn_table_cursor_set_value, 1);
284
- rb_define_method(rb_cGrnTableCursor, "delete",
285
- rb_grn_table_cursor_delete, 0);
286
- rb_define_method(rb_cGrnTableCursor, "next",
287
- rb_grn_table_cursor_next, 0);
288
-
289
- rb_define_method(rb_cGrnTableCursor, "each",
290
- rb_grn_table_cursor_each, 0);
291
-
292
- rb_grn_init_table_cursor_key_support(mGrn);
293
- rb_grn_init_array_cursor(mGrn);
294
- rb_grn_init_hash_cursor(mGrn);
295
- rb_grn_init_patricia_trie_cursor(mGrn);
296
- }