rroonga 1.2.0 → 1.2.1

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 (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
@@ -0,0 +1,71 @@
1
+ h1. README
2
+
3
+ h2. Name
4
+
5
+ rroonga
6
+
7
+ h2. Description
8
+
9
+ Ruby bindings for groonga that provide full text search and
10
+ column store features.
11
+
12
+ rroonga is an extension library to use groonga's DB-API
13
+ layer. rroonga provides Rubyish readable and writable API
14
+ not C like API. You can use groonga's fast and highly
15
+ functional features from Ruby with Rubyish form.
16
+
17
+ See the following URL about groonga.
18
+
19
+ * "The groonga official site":http://groonga.org/
20
+
21
+ h2. Authors
22
+
23
+ * Kouhei Sutou <kou@clear-code.com>
24
+ * Tasuku SUENAGA <a@razil.jp>
25
+ * Daijiro MORI <morita@razil.jp>
26
+ * Yuto HAYAMIZU <y.hayamizu@gmail.com>
27
+ * SHIDARA Yoji <dara@shidara.net>
28
+
29
+ h2. License
30
+
31
+ LGPL 2.1. See license/LGPL for details.
32
+
33
+ (Kouhei Sutou has a right to change the license including
34
+ contributed patches.)
35
+
36
+ h2. Dependencies
37
+
38
+ * Ruby >= 1.8 (including 1.9.2)
39
+ * groonga >= 1.2.0
40
+
41
+ h2. Install
42
+
43
+ <pre>
44
+ !!!command_line
45
+ % sudo gem install rroonga
46
+ </pre>
47
+
48
+ h2. Documents
49
+
50
+ * "Reference manual in English":http://groonga.rubyforge.org/rroonga/en/
51
+ * "Reference manual in Japanese":http://groonga.rubyforge.org/rroonga/ja/
52
+
53
+ h2. Mailing list
54
+
55
+ * English: "groonga-users-en":http://rubyforge.org/mailman/listinfo/groonga-users-en
56
+ * Japanese: "groonga-dev":http://lists.sourceforge.jp/mailman/listinfo/groonga-dev
57
+
58
+ h2. Thanks
59
+
60
+ * Daijiro MORI: sent patches to support the latest groonga.
61
+ * Tasuku SUENAGA: sent bug reports.
62
+ * niku: sent bug reports.
63
+ * dara:
64
+ ** wrote tests.
65
+ ** fixed bugs.
66
+ * id:mat_aki: sent bug reports.
67
+ * @yune_kotomi: sent a bug report.
68
+ * m_seki: sent bug reports.
69
+ * ono matope: sent bug reports.
70
+ * @kamipo: send a bug report.
71
+ * ongaeshi: sent a patch to build gem on Windows.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8; mode: 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
@@ -22,18 +22,18 @@ require 'fileutils'
22
22
  require 'pathname'
23
23
  require 'erb'
24
24
  require 'rubygems'
25
- if RUBY_VERSION < "1.9"
26
- gem 'rdoc'
27
- end
28
- require 'hoe'
25
+ require 'yard'
26
+ require 'jeweler'
29
27
  require 'rake/extensiontask'
30
28
 
31
- ENV["NODOT"] = "yes"
29
+ if YAML.const_defined?(:ENGINE)
30
+ begin
31
+ YAML::ENGINE.yamler = "psych"
32
+ rescue LoadError
33
+ end
34
+ end
32
35
 
33
36
  base_dir = File.join(File.dirname(__FILE__))
34
- truncate_base_dir = Proc.new do |x|
35
- x.gsub(/^#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
36
- end
37
37
 
38
38
  groonga_ext_dir = File.join(base_dir, "ext", "groonga")
39
39
  groonga_lib_dir = File.join(base_dir, 'lib')
@@ -54,94 +54,76 @@ def guess_version(groonga_ext_dir)
54
54
  [version["major"], version["minor"], version["micro"]].join(".")
55
55
  end
56
56
 
57
- manifest = File.join(base_dir, "Manifest.txt")
58
- manifest_contents = []
59
- base_dir_included_components = %w(AUTHORS Rakefile
60
- README.rdoc README.ja.rdoc
61
- NEWS.rdoc NEWS.ja.rdoc
62
- rroonga-build.rb extconf.rb)
63
- excluded_components = %w(.cvsignore .gdb_history CVS depend Makefile doc pkg
64
- .svn .git doc data .test-result tmp vendor)
65
- excluded_suffixes = %w(.png .ps .pdf .o .so .a .txt .~)
66
- Find.find(base_dir) do |target|
67
- target = truncate_base_dir[target]
68
- components = target.split(File::SEPARATOR)
69
- if components.size == 1 and !File.directory?(target)
70
- next unless base_dir_included_components.include?(components[0])
71
- end
72
- Find.prune if (excluded_components - components) != excluded_components
73
- next if excluded_suffixes.include?(File.extname(target))
74
- manifest_contents << target if File.file?(target)
75
- end
76
-
77
- File.open(manifest, "w") do |f|
78
- f.puts manifest_contents.sort.join("\n")
79
- end
80
-
81
- # For Hoe's no user friendly default behavior. :<
82
- File.open("README.txt", "w") {|file| file << "= Dummy README\n== XXX\n"}
83
- FileUtils.cp("NEWS.rdoc", "History.txt")
84
- at_exit do
85
- FileUtils.rm_f("README.txt")
86
- FileUtils.rm_f("History.txt")
87
- FileUtils.rm_f(manifest)
88
- end
89
-
90
57
  def cleanup_white_space(entry)
91
58
  entry.gsub(/(\A\n+|\n+\z)/, '') + "\n"
92
59
  end
93
60
 
94
61
  ENV["VERSION"] ||= guess_version(groonga_ext_dir)
95
62
  version = ENV["VERSION"]
96
- project = nil
97
- Hoe.spec('rroonga') do
98
- Hoe::Test::SUPPORTED_TEST_FRAMEWORKS[:testunit2] = "test/run-test.rb"
99
- project = self
100
- project.version = version.dup
101
- project.rubyforge_name = 'groonga'
63
+ spec = nil
64
+ Jeweler::Tasks.new do |_spec|
65
+ spec = _spec
66
+ spec.name = "rroonga"
67
+ spec.version = version.dup
68
+ spec.rubyforge_project = "groonga"
69
+ spec.homepage = "http://groonga.rubyforge.org/"
102
70
  authors = File.join(base_dir, "AUTHORS")
103
- project.author = File.readlines(authors).collect do |line|
71
+ spec.authors = File.readlines(authors).collect do |line|
104
72
  if /\s*<[^<>]*>$/ =~ line
105
73
  $PREMATCH
106
74
  else
107
75
  nil
108
76
  end
109
77
  end.compact
110
- project.email = ['groonga-users-en@rubyforge.org',
111
- 'groonga-dev@lists.sourceforge.jp']
112
- project.url = 'http://groonga.rubyforge.org/'
113
- project.testlib = :testunit2
114
- project.test_globs = ["test/run-test.rb"]
115
- project.spec_extras = {
116
- :extensions => ['extconf.rb'],
117
- :require_paths => ["lib", "ext/groonga"],
118
- :extra_rdoc_files => Dir.glob("**/*.rdoc"),
119
- }
120
- project.extra_deps << ['pkg-config', '>= 1.0.7']
121
- project.readme_file = "README.ja.rdoc"
122
-
123
- news_of_current_release = File.read("NEWS.rdoc").split(/^==\s.*$/)[1]
124
- project.changes = cleanup_white_space(news_of_current_release)
125
-
126
- entries = File.read("README.rdoc").split(/^==\s(.*)$/)
78
+ spec.email = [
79
+ 'groonga-users-en@rubyforge.org',
80
+ 'groonga-dev@lists.sourceforge.jp',
81
+ ]
82
+ entries = File.read("README.textile").split(/^h2\.\s(.*)$/)
127
83
  description = cleanup_white_space(entries[entries.index("Description") + 1])
128
- project.summary, project.description, = description.split(/\n\n+/, 3)
129
-
130
- project.remote_rdoc_dir = "rroonga"
84
+ spec.summary, spec.description, = description.split(/\n\n+/, 3)
85
+ spec.license = "LGPLv2"
86
+ spec.files = FileList["{lib,benchmark,misc}/**/*.rb",
87
+ "bin/*",
88
+ "*.rb",
89
+ "example/*.rb",
90
+ "Rakefile",
91
+ "ext/**/*"]
92
+ spec.test_files = FileList["test/**/*.rb"]
131
93
  end
132
94
 
133
- project.spec.dependencies.delete_if {|dependency| dependency.name == "hoe"}
95
+ Jeweler::RubygemsDotOrgTasks.new do
96
+ end
134
97
 
135
- ObjectSpace.each_object(Rake::RDocTask) do |rdoc_task|
136
- options = rdoc_task.options
137
- t_option_index = options.index("--title") || options.index("-t")
138
- rdoc_task.options[t_option_index, 2] = nil
139
- rdoc_task.title = "rroonga - #{version}"
98
+ module YARD
99
+ module CodeObjects
100
+ class Proxy
101
+ alias_method :initialize_original, :initialize
102
+ def initialize(namespace, name)
103
+ name = name.gsub(/\AGrn(.*)\z/) do
104
+ suffix = $1
105
+ case suffix
106
+ when ""
107
+ "Groonga"
108
+ when "TableKeySupport"
109
+ "Groonga::Table::KeySupport"
110
+ else
111
+ "Groonga::#{suffix}"
112
+ end
113
+ end
114
+ initialize_original(namespace, name)
115
+ end
116
+ end
117
+ end
118
+ end
140
119
 
141
- rdoc_task.rdoc_files = ["ext/groonga/rb-groonga.c"]
142
- rdoc_task.rdoc_files += Dir.glob("ext/groonga/rb-grn-*.c")
143
- rdoc_task.rdoc_files += Dir.glob("lib/**/*.rb")
144
- rdoc_task.rdoc_files += Dir.glob("**/*.rdoc")
120
+ YARD::Rake::YardocTask.new do |task|
121
+ task.options += ["--title", "#{spec.name} - #{version}"]
122
+ # task.options += ["--charset", "UTF-8"]
123
+ task.options += ["--readme", "README.textile"]
124
+ task.options += ["--files", "text/tutorial.textile"]
125
+ task.files += FileList["ext/groonga/**/*.c"]
126
+ task.files += FileList["lib/**/*.rb"]
145
127
  end
146
128
 
147
129
  def windows?(platform=nil)
@@ -164,26 +146,32 @@ relative_binary_dir = File.join("vendor", "local")
164
146
  vendor_dir = File.join(base_dir, relative_vendor_dir)
165
147
  binary_dir = File.join(base_dir, relative_binary_dir)
166
148
 
167
- Rake::ExtensionTask.new("groonga", project.spec) do |ext|
149
+ groonga_win32_i386_p = ENV["GROONGA32"] == "yes"
150
+
151
+ Rake::ExtensionTask.new("groonga", spec) do |ext|
152
+ if groonga_win32_i386_p
153
+ ext.cross_platform = ["x86-mingw32", "i386-mswin32"]
154
+ else
155
+ ext.cross_platform = ["x64-mingw32"]
156
+ # ext.cross_platform << "x64-mswin64" # We need to build with VC++ 2010. :<
157
+ end
168
158
  if windows?
169
159
  ext.gem_spec.files += collect_binary_files(relative_binary_dir)
170
160
  else
171
161
  ext.cross_compile = true
172
- ext.cross_compiling do |spec|
173
- if windows?(spec.platform.to_s)
174
- spec.files += collect_binary_files(relative_binary_dir)
162
+ ext.cross_compiling do |_spec|
163
+ if windows?(_spec.platform.to_s)
164
+ _spec.files += collect_binary_files(relative_binary_dir)
175
165
  end
176
166
  end
177
167
  end
178
168
  end
179
169
 
180
- task :publish_docs => [:prepare_docs_for_publishing]
181
-
182
170
  include ERB::Util
183
171
 
184
- def apply_template(file, head, header, footer)
172
+ def apply_template(file, head, header, footer, language)
185
173
  content = File.read(file)
186
- content = content.sub(/lang="en"/, 'lang="ja"')
174
+ content = content.sub(/lang="en"/, 'lang="#{language}"')
187
175
 
188
176
  title = nil
189
177
  content = content.sub(/<title>(.+?)<\/title>/) do
@@ -212,47 +200,146 @@ def erb_template(name)
212
200
  erb
213
201
  end
214
202
 
215
- task :prepare_docs_for_publishing do
216
- head = erb_template("head")
217
- header = erb_template("header")
218
- footer = erb_template("footer")
219
- Find.find("doc") do |file|
220
- if /\.html\z/ =~ file and /_(?:c|rb)\.html\z/ !~ file
221
- apply_template(file, head, header, footer)
203
+ def rsync_to_rubyforge(spec, source, destination, options={})
204
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
205
+ host = "#{config["username"]}@rubyforge.org"
206
+
207
+ rsync_args = "-av --exclude '*.erb' --dry-run"
208
+ rsync_args << " --delete" if options[:delete]
209
+ remote_dir = "/var/www/gforge-projects/#{spec.rubyforge_name}/"
210
+ sh("rsync #{rsync_args} #{source} #{host}:#{remote_dir}#{destination}")
211
+ end
212
+
213
+ namespace :reference do
214
+ translate_languages = [:ja]
215
+ supported_languages = [:en, *translate_languages]
216
+ reference_base_dir = "references"
217
+ html_files = FileList["doc/**/*.html"].to_a
218
+
219
+ directory reference_base_dir
220
+ CLOBBER.include(reference_base_dir)
221
+
222
+ po_dir = "po"
223
+ namespace :pot do
224
+ pot_file = "#{po_dir}/#{spec.name}.pot"
225
+
226
+ directory po_dir
227
+ file pot_file => ["po", *html_files] do |t|
228
+ sh("xml2po", "--keep-entities", "--output", t.name, *html_files)
222
229
  end
230
+
231
+ desc "Generates pot file."
232
+ task :generate => pot_file
223
233
  end
224
- File.open("doc/.htaccess", "w") do |file|
225
- file.puts("Redirect permanent /rroonga/text/TUTORIAL_ja_rdoc.html " +
226
- "http://groonga.rubyforge.org/rroonga/text/tutorial_ja_rdoc.html")
234
+
235
+ namespace :po do
236
+ translate_languages.each do |language|
237
+ namespace language do
238
+ po_file = "#{po_dir}/#{language}.po"
239
+
240
+ file po_file do |t|
241
+ sh("xml2po", "--keep-entities", "--update", t.name, *html_files)
242
+ end
243
+
244
+ desc "Updates po file for #{language}."
245
+ task :update => po_file
246
+ end
247
+ end
227
248
  end
228
- end
229
249
 
230
- desc "Publish HTML to Web site."
231
- task :publish_html do
232
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
233
- host = "#{config["username"]}@rubyforge.org"
250
+ namespace :translate do
251
+ directory reference_base_dir
252
+
253
+ translate_languages.each do |language|
254
+ po_file = "#{po_dir}/#{language}.po"
255
+ translate_doc_dir = "#{reference_base_dir}/#{language}"
256
+
257
+ doc_dir = Pathname("doc")
258
+ desc "Translates documents to #{language}."
259
+ task language => [po_file, reference_base_dir, *html_files] do
260
+ doc_dir.find do |path|
261
+ base_path = path.relative_path_from(doc_dir)
262
+ translated_path = "#{translate_doc_dir}/#{base_path}"
263
+ if path.directory?
264
+ mkdir_p(translated_path)
265
+ next
266
+ end
267
+ case path.extname
268
+ when ".html"
269
+ sh("xml2po --keep-entities " +
270
+ "--po-file #{po_file} --language #{language} " +
271
+ "#{path} > #{translated_path}")
272
+ else
273
+ cp(path.to_s, translated_path, :preserve => true)
274
+ end
275
+ end
276
+ end
277
+ end
278
+ end
279
+
280
+ translate_task_names = translate_languages.collect do |language|
281
+ "reference:translate:#{language}"
282
+ end
283
+ desc "Translates references."
284
+ task :translate => translate_task_names
285
+
286
+ desc "Generates references."
287
+ task :generate => [:yard, :translate] do
288
+ cp_r("doc", "#{reference_base_dir}/en", :preserve => true)
289
+ end
234
290
 
235
- rsync_args = "-av --exclude '*.erb' --exclude '*.svg' --exclude .svn"
236
- remote_dir = "/var/www/gforge-projects/#{project.rubyforge_name}/"
237
- sh "rsync #{rsync_args} html/ #{host}:#{remote_dir}"
291
+ namespace :publication do
292
+ task :prepare do
293
+ head = erb_template("head")
294
+ header = erb_template("header")
295
+ footer = erb_template("footer")
296
+ supported_languages.each do |language|
297
+ doc_dir = "#{reference_base_dir}/#{language}"
298
+ Find.find(doc_dir) do |file|
299
+ if /\.html\z/ =~ file and /_(?:c|rb)\.html\z/ !~ file
300
+ apply_template(file, head, header, footer, language)
301
+ end
302
+ end
303
+ end
304
+ File.open("#{reference_base_dir}/.htaccess", "w") do |file|
305
+ file.puts("Redirect permanent /rroonga/text/TUTORIAL_ja_rdoc.html " +
306
+ "http://groonga.rubyforge.org/rroonga/ja/file.tutorial.html")
307
+ file.puts("Redirect permanent /rroonga/ " +
308
+ "http://groonga.rubyforge.org/rroonga/en/")
309
+ end
310
+ end
311
+ end
312
+
313
+ task :publish => [:generate, "reference:publication:prepare"] do
314
+ rsync_to_rubyforge(spec, "#{reference_base_dir}/", "/#{spec.name}",
315
+ :delete => true)
316
+ end
238
317
  end
239
318
 
319
+ namespace :html do
320
+ desc "Publish HTML to Web site."
321
+ task :publish do
322
+ rsync_to_rubyforge(spec, "html/", "")
323
+ end
324
+ end
325
+ task :publish => ["reference:publish", "html:publish"]
326
+
240
327
  desc "Tag the current revision."
241
328
  task :tag do
242
329
  sh("git tag -a #{version} -m 'release #{version}!!!'")
243
330
  end
244
331
 
245
- # fix Hoe's incorrect guess.
246
- project.spec.executables.clear
247
- # project.lib_files = project.spec.files.grep(%r|^src/lib/|)
248
-
249
- task(:release).prerequisites.reject! {|name| name == "clean"}
250
-
251
332
  namespace :win32 do
252
- if ENV["GROONGA64"] == "yes"
253
- host = "amd64-mingw32msvc"
254
- else
333
+ patches_dir = (Pathname.new(base_dir) + "patches").expand_path
334
+ if groonga_win32_i386_p
255
335
  host = "i586-mingw32msvc"
336
+ mecab_patches = []
337
+ else
338
+ host = "x86_64-w64-mingw32"
339
+ mecab_patches = [
340
+ "mecab-0.98-mingw-w64.diff",
341
+ "mecab-0.98-not-use-locale-on-mingw.diff",
342
+ ]
256
343
  end
257
344
 
258
345
  desc "Build MeCab and groonga and install them into vendor/local/."
@@ -277,12 +364,19 @@ namespace :win32 do
277
364
  sh("tar", "xzf", mecab_tar_gz) or exit(false)
278
365
  end
279
366
  Dir.chdir(File.join(tmp_dir, mecab_base)) do
367
+ mecab_patches.each do |patch|
368
+ sh("patch -p1 < #{patches_dir + patch}")
369
+ end
280
370
  sh("./configure",
281
371
  "--prefix=#{binary_dir}",
282
372
  "--host=#{host}") or exit(false)
283
373
  sh("env", "GREP_OPTIONS=--text", "nice", "make", "-j8") or exit(false)
284
374
  sh("env", "GREP_OPTIONS=--text", "make", "install") or exit(false)
285
375
 
376
+ mecab_rc_path = File.join(binary_dir, "etc", "mecabrc")
377
+ win32_mecab_rc_path = File.join(binary_dir, "bin", "mecabrc")
378
+ mv(mecab_rc_path, win32_mecab_rc_path)
379
+
286
380
  mecab_files_dir = File.join(vendor_dir, "mecab")
287
381
  mkdir_p(mecab_files_dir)
288
382
  files = ["AUTHORS", "BSD", "COPYING", "GPL", "LGPL"]
@@ -290,7 +384,7 @@ namespace :win32 do
290
384
  end
291
385
  end
292
386
 
293
- task(:build_mecab_dict => :build_mecab) do
387
+ task(:build_mecab_dict) do
294
388
  tmp_dir = "tmp/mecab_dict"
295
389
  rm_rf(tmp_dir)
296
390
  mkdir_p(tmp_dir)
@@ -318,12 +412,12 @@ namespace :win32 do
318
412
  files = ["AUTHORS", "COPYING"]
319
413
  cp(files, naist_jdic_files_dir)
320
414
  end
321
- dictionary_dir = '$(rcpath)\..\share/mecab\dic\naist-jdic'
322
- mecab_rc_path = File.join(binary_dir, "etc", "mecabrc")
415
+ dictionary_dir = '$(rcpath)\..\share\mecab\dic\naist-jdic'
416
+ mecab_rc_path = File.join(binary_dir, "bin", "mecabrc")
323
417
  mecab_rc_content = File.read(mecab_rc_path)
324
418
  File.open(mecab_rc_path, "w") do |mecab_rc|
325
- mecab_rc.print(mecab_rc_content.gsub(/\Adictdir\s*=.+$/,
326
- "dictdir = #{dictionary_dir}"))
419
+ mecab_rc.print(mecab_rc_content.gsub(/^dicdir\s*=.+$/,
420
+ "dicdir = #{dictionary_dir}"))
327
421
  end
328
422
  end
329
423
 
@@ -359,12 +453,3 @@ namespace :win32 do
359
453
  end
360
454
  end
361
455
  end
362
-
363
- desc "generate rroonga.gemspec"
364
- task :generate_gemspec do
365
- spec = project.spec
366
- spec_name = File.join(base_dir, project.spec.spec_name)
367
- File.open(spec_name, "w") do |spec_file|
368
- spec_file.puts(spec.to_ruby)
369
- end
370
- end