activegroonga 0.0.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.ja.rdoc +4 -1
- data/README.rdoc +4 -1
- data/Rakefile +18 -4
- data/lib/active_groonga.rb +25 -52
- data/lib/active_groonga/base.rb +164 -1480
- data/lib/active_groonga/callbacks.rb +26 -7
- data/lib/active_groonga/database.rb +55 -0
- data/lib/active_groonga/{dirty.rb → error.rb} +20 -10
- data/lib/active_groonga/locale/en.yml +5 -0
- data/lib/active_groonga/migration.rb +44 -113
- data/lib/active_groonga/migrator.rb +172 -0
- data/lib/active_groonga/persistence.rb +172 -0
- data/lib/active_groonga/railtie.rb +66 -0
- data/lib/active_groonga/railties/configurable.rb +47 -0
- data/lib/active_groonga/railties/groonga.rake +167 -0
- data/lib/active_groonga/result_set.rb +89 -0
- data/lib/active_groonga/schema.rb +54 -188
- data/lib/active_groonga/validations.rb +54 -5
- data/lib/active_groonga/vector.rb +64 -0
- data/lib/active_groonga/version.rb +3 -3
- data/lib/{active_groonga/aggregations.rb → rails/generators/active_groonga.rb} +17 -10
- data/lib/rails/generators/active_groonga/migration/column.rb +101 -0
- data/lib/rails/generators/active_groonga/migration/migration_generator.rb +53 -0
- data/lib/rails/generators/active_groonga/migration/templates/migration.rb +29 -0
- data/lib/rails/generators/active_groonga/model/model_generator.rb +60 -0
- data/lib/rails/generators/active_groonga/model/templates/migration.rb +16 -0
- data/lib/rails/generators/active_groonga/model/templates/model.rb +2 -0
- data/lib/rails/generators/active_groonga/model/templates/module.rb +5 -0
- data/test-unit-notify/COPYING +502 -0
- data/test-unit-notify/Rakefile +47 -0
- data/test-unit-notify/lib/test/unit/notify.rb +127 -0
- data/test-unit/COPYING +56 -0
- data/test-unit/GPL +340 -0
- data/test-unit/PSFL +271 -0
- data/test-unit/Rakefile +18 -5
- data/test-unit/html/bar.svg +153 -0
- data/test-unit/html/developer.svg +469 -0
- data/test-unit/html/favicon.ico +0 -0
- data/test-unit/html/favicon.svg +82 -0
- data/test-unit/html/heading-mark.svg +393 -0
- data/test-unit/html/index.html +235 -13
- data/test-unit/html/index.html.ja +258 -15
- data/test-unit/html/install.svg +636 -0
- data/test-unit/html/logo.svg +483 -0
- data/test-unit/html/test-unit.css +339 -0
- data/test-unit/html/tutorial.svg +559 -0
- data/test-unit/lib/test/unit.rb +29 -43
- data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
- data/test-unit/lib/test/unit/assertions.rb +202 -20
- data/test-unit/lib/test/unit/autorunner.rb +51 -20
- data/test-unit/lib/test/unit/collector.rb +1 -8
- data/test-unit/lib/test/unit/collector/dir.rb +1 -1
- data/test-unit/lib/test/unit/collector/load.rb +16 -9
- data/test-unit/lib/test/unit/color-scheme.rb +19 -3
- data/test-unit/lib/test/unit/diff.rb +240 -38
- data/test-unit/lib/test/unit/error.rb +4 -0
- data/test-unit/lib/test/unit/failure.rb +31 -5
- data/test-unit/lib/test/unit/notification.rb +8 -4
- data/test-unit/lib/test/unit/omission.rb +51 -3
- data/test-unit/lib/test/unit/pending.rb +4 -0
- data/test-unit/lib/test/unit/priority.rb +2 -3
- data/test-unit/lib/test/unit/testcase.rb +65 -7
- data/test-unit/lib/test/unit/testresult.rb +34 -2
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +197 -45
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +2 -12
- data/test-unit/lib/test/unit/ui/testrunner.rb +33 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
- data/test-unit/lib/test/unit/util/output.rb +31 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
- data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
- data/test-unit/sample/test_user.rb +1 -0
- data/test-unit/test/collector/test-descendant.rb +2 -4
- data/test-unit/test/collector/test-load.rb +121 -8
- data/test-unit/test/collector/test_objectspace.rb +7 -5
- data/test-unit/test/run-test.rb +2 -0
- data/test-unit/test/test-color-scheme.rb +11 -2
- data/test-unit/test/test-diff.rb +48 -7
- data/test-unit/test/test-omission.rb +1 -1
- data/test-unit/test/test-testcase.rb +57 -20
- data/test-unit/test/test_assertions.rb +128 -13
- data/test-unit/test/ui/test_tap.rb +33 -0
- data/test-unit/test/util/test-output.rb +11 -0
- data/test/active-groonga-test-utils.rb +50 -36
- data/test/fixtures/site.rb +2 -0
- data/test/run-test.rb +36 -9
- data/test/test-associations.rb +5 -2
- data/test/test-base.rb +39 -31
- data/test/test-callbacks.rb +13 -3
- data/test/test-persistence.rb +53 -0
- data/{lib/active_groonga/observer.rb → test/test-result-set.rb} +14 -12
- data/test/test-schema.rb +85 -22
- data/{lib/active_groonga/rails_support.rb → test/test-validations.rb} +15 -13
- metadata +85 -52
- data/lib/active_groonga/associations.rb +0 -93
- data/lib/active_groonga/associations/belongs_to_association.rb +0 -25
- data/lib/active_groonga/attribute_methods.rb +0 -36
- data/lib/active_groonga/column.rb +0 -137
- data/lib/active_groonga/dynamic_record_expression_builder.rb +0 -40
- data/lib/active_groonga/reflection.rb +0 -30
- data/lib/active_groonga/schema_dumper.rb +0 -163
- data/lib/active_groonga/tasks.rb +0 -16
- data/lib/active_groonga/tasks/groonga.rake +0 -164
- data/lib/active_groonga/timestamp.rb +0 -30
- data/rails/README +0 -28
- data/rails/init.rb +0 -70
- data/rails_generators/index_table_groonga/USAGE +0 -23
- data/rails_generators/index_table_groonga/index_table_groonga_generator.rb +0 -44
- data/rails_generators/index_table_groonga/templates/migration.rb +0 -12
- data/rails_generators/migration_groonga/USAGE +0 -29
- data/rails_generators/migration_groonga/migration_groonga_generator.rb +0 -19
- data/rails_generators/migration_groonga/templates/migration.rb +0 -11
- data/rails_generators/model_groonga/USAGE +0 -28
- data/rails_generators/model_groonga/model_groonga_generator.rb +0 -45
- data/rails_generators/model_groonga/templates/fixtures.yml +0 -17
- data/rails_generators/model_groonga/templates/migration.rb +0 -16
- data/rails_generators/model_groonga/templates/model.rb +0 -2
- data/rails_generators/model_groonga/templates/unit_test.rb +0 -8
- data/test-unit/html/classic.html +0 -15
- data/test-unit/sample/ts_examples.rb +0 -7
- data/test/test-schema-dumper.rb +0 -48
@@ -1,40 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009 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
|
-
module ActiveGroonga
|
17
|
-
class DynamicRecordExpressionBuilder
|
18
|
-
# Instantiates a new dynamic record expression builder.
|
19
|
-
#
|
20
|
-
# +record+ is a Groonga::RecordExpressionBuilder.
|
21
|
-
def initialize(record)
|
22
|
-
@record = record
|
23
|
-
define_column_readers
|
24
|
-
end
|
25
|
-
|
26
|
-
def [](name)
|
27
|
-
@record[name]
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
def define_column_readers
|
32
|
-
singleton_class = class << self; self; end
|
33
|
-
@record.table.columns.each do |column|
|
34
|
-
singleton_class.send(:define_method, column.local_name) do ||
|
35
|
-
self[column.local_name]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009 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
|
-
module ActiveGroonga
|
17
|
-
module Reflection
|
18
|
-
class << self
|
19
|
-
def included(base)
|
20
|
-
base.class_eval do
|
21
|
-
include(ActiveRecord::Reflection)
|
22
|
-
extend(ClassMethods)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module ClassMethods
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,163 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009 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
|
-
module ActiveGroonga
|
17
|
-
class SchemaDumper < ActiveRecord::SchemaDumper
|
18
|
-
class << self
|
19
|
-
def dump(stream=STDOUT)
|
20
|
-
new.dump(StreamWrapper.new(stream))
|
21
|
-
stream
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize
|
26
|
-
@version = Migrator.current_version
|
27
|
-
end
|
28
|
-
|
29
|
-
def dump(stream)
|
30
|
-
@references = []
|
31
|
-
@indexes = []
|
32
|
-
header(stream)
|
33
|
-
dump_tables(stream)
|
34
|
-
dump_references(stream)
|
35
|
-
dump_indexes(stream)
|
36
|
-
trailer(stream)
|
37
|
-
stream
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def dump_tables(stream)
|
42
|
-
tables.sort.each do |name|
|
43
|
-
next if ignore_tables.any? {|ignored| ignored === name}
|
44
|
-
dump_table(name, stream)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def tables
|
49
|
-
Dir[File.join(Base.tables_directory, "*.groonga")].collect do |path|
|
50
|
-
File.basename(path, ".groonga")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def dump_table(name, stream)
|
55
|
-
begin
|
56
|
-
table_schema = StringIO.new
|
57
|
-
|
58
|
-
table_name = Base.groonga_table_name(name)
|
59
|
-
table = Base.context[table_name]
|
60
|
-
options = [":force => true"]
|
61
|
-
case table
|
62
|
-
when Groonga::Hash
|
63
|
-
options << ":type => :hash"
|
64
|
-
when Groonga::PatriciaTrie
|
65
|
-
options << ":type => :patricia_trie"
|
66
|
-
end
|
67
|
-
if table.domain
|
68
|
-
options << ":key_type => #{table.domain.name.inspect}"
|
69
|
-
end
|
70
|
-
if table.respond_to?(:default_tokenizer) and table.default_tokenizer
|
71
|
-
options << ":default_tokenizer => #{table.default_tokenizer.name.inspect}"
|
72
|
-
end
|
73
|
-
|
74
|
-
table_schema.puts " create_table #{name.inspect}, #{options.join(', ')} do |t|"
|
75
|
-
column_specs = []
|
76
|
-
columns(name).each do |column|
|
77
|
-
next if column.id?
|
78
|
-
if column.reference_type?
|
79
|
-
@references << [name, column]
|
80
|
-
next
|
81
|
-
end
|
82
|
-
if column.index?
|
83
|
-
@indexes << [name, column]
|
84
|
-
next
|
85
|
-
end
|
86
|
-
|
87
|
-
spec = {}
|
88
|
-
spec[:type] = column.type.to_s
|
89
|
-
spec[:name] = column.name.inspect
|
90
|
-
column_specs << spec
|
91
|
-
end
|
92
|
-
|
93
|
-
column_specs.each do |spec|
|
94
|
-
table_schema.print(" t.#{spec[:type]} #{spec[:name]}")
|
95
|
-
table_schema.puts
|
96
|
-
end
|
97
|
-
|
98
|
-
table_schema.puts " end"
|
99
|
-
table_schema.puts
|
100
|
-
|
101
|
-
stream.print table_schema.string
|
102
|
-
rescue => e
|
103
|
-
stream.puts "# Could not dump table #{name.inspect} because of following #{e.class}"
|
104
|
-
stream.puts "# #{e.message}"
|
105
|
-
e.backtrace.each do |trace|
|
106
|
-
stream.puts "# #{trace}"
|
107
|
-
end
|
108
|
-
stream.puts
|
109
|
-
end
|
110
|
-
|
111
|
-
stream
|
112
|
-
end
|
113
|
-
|
114
|
-
def dump_references(stream)
|
115
|
-
@references.sort_by do |name, column|
|
116
|
-
[name, column.name]
|
117
|
-
end.each do |name, column|
|
118
|
-
statement = " add_column #{name.inspect}, "
|
119
|
-
statement << "#{column.name.inspect}, "
|
120
|
-
statement << "#{column.reference_object_name.inspect}"
|
121
|
-
stream.puts(statement)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def dump_indexes(stream)
|
126
|
-
@indexes.sort_by do |name, column|
|
127
|
-
[name, column.name]
|
128
|
-
end.each do |name, column|
|
129
|
-
column.index_sources.each do |source|
|
130
|
-
statement = " add_index_column #{name.inspect}, "
|
131
|
-
statement << "#{source.table.name.inspect}, "
|
132
|
-
statement << "#{source.local_name.inspect}, "
|
133
|
-
statement << ":name => #{column.name.inspect}"
|
134
|
-
stream.puts(statement)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def columns(table_name)
|
140
|
-
table_name = Base.groonga_table_name(table_name)
|
141
|
-
Base.context[table_name].columns.collect {|column| Column.new(column)}
|
142
|
-
end
|
143
|
-
|
144
|
-
class StreamWrapper
|
145
|
-
def initialize(stream)
|
146
|
-
@stream = stream
|
147
|
-
end
|
148
|
-
|
149
|
-
def method_missing(name, *args, &block)
|
150
|
-
@stream.send(name, *args.collect {|arg| normalize_string(arg)}, &block)
|
151
|
-
end
|
152
|
-
|
153
|
-
private
|
154
|
-
def normalize_string(string)
|
155
|
-
if string.is_a?(String)
|
156
|
-
string.gsub(/Active ?Record/, "ActiveGroonga")
|
157
|
-
else
|
158
|
-
string
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
data/lib/active_groonga/tasks.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009 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
|
-
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].each {|task| load(task)}
|
@@ -1,164 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009 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
|
-
# This library includes ActiveRecord based codes temporary.
|
17
|
-
# Here is their copyright and license:
|
18
|
-
#
|
19
|
-
# Copyright (c) 2004-2009 David Heinemeier Hansson
|
20
|
-
#
|
21
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
22
|
-
# a copy of this software and associated documentation files (the
|
23
|
-
# "Software"), to deal in the Software without restriction, including
|
24
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
25
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
26
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
27
|
-
# the following conditions:
|
28
|
-
#
|
29
|
-
# The above copyright notice and this permission notice shall be
|
30
|
-
# included in all copies or substantial portions of the Software.
|
31
|
-
#
|
32
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
33
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
34
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
35
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
36
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
37
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
38
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
39
|
-
|
40
|
-
namespace :groonga do
|
41
|
-
task :load_config => :rails_env do
|
42
|
-
require 'active_groonga'
|
43
|
-
ActiveGroonga::Base.configurations = Rails::Configuration.new.groonga_configuration
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "Migrate the database through scripts in db/groonga/migrate and update db/groonga/schema.rb by invoking groonga:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
47
|
-
task :migrate => :environment do
|
48
|
-
ActiveGroonga::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
49
|
-
ActiveGroonga::Migrator.migrate("db/groonga/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
50
|
-
Rake::Task["groonga:schema:dump"].invoke
|
51
|
-
end
|
52
|
-
|
53
|
-
namespace :migrate do
|
54
|
-
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
|
55
|
-
task :redo => :environment do
|
56
|
-
if ENV["VERSION"]
|
57
|
-
Rake::Task["groonga:migrate:down"].invoke
|
58
|
-
Rake::Task["groonga:migrate:up"].invoke
|
59
|
-
else
|
60
|
-
Rake::Task["groonga:rollback"].invoke
|
61
|
-
Rake::Task["groonga:migrate"].invoke
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc 'Resets your database using your migrations for the current environment'
|
66
|
-
task :reset => ["groonga:drop", "groonga:create", "groonga:migrate"]
|
67
|
-
|
68
|
-
desc 'Runs the "up" for a given migration VERSION.'
|
69
|
-
task :up => :environment do
|
70
|
-
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
71
|
-
raise "VERSION is required" unless version
|
72
|
-
ActiveGroonga::Migrator.run(:up, "db/groonga/migrate/", version)
|
73
|
-
Rake::Task["groonga:schema:dump"].invoke
|
74
|
-
end
|
75
|
-
|
76
|
-
desc 'Runs the "down" for a given migration VERSION.'
|
77
|
-
task :down => :environment do
|
78
|
-
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
79
|
-
raise "VERSION is required" unless version
|
80
|
-
ActiveGroonga::Migrator.run(:down, "db/groonga/migrate/", version)
|
81
|
-
Rake::Task["db:schema:dump"].invoke
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
|
86
|
-
task :rollback => :environment do
|
87
|
-
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
88
|
-
ActiveGroonga::Migrator.rollback('db/groonga/migrate/', step)
|
89
|
-
Rake::Task["groonga:schema:dump"].invoke
|
90
|
-
end
|
91
|
-
|
92
|
-
desc 'Drops and recreates the database from db/groonga/schema.rb for the current environment.'
|
93
|
-
task :reset => ['groonga:drop', 'groonga:create', 'groonga:schema:load']
|
94
|
-
|
95
|
-
desc "Retrieves the current schema version number"
|
96
|
-
task :version => :environment do
|
97
|
-
puts "Current version: #{ActiveRecord::Migrator.current_version}"
|
98
|
-
end
|
99
|
-
|
100
|
-
desc "Raises an error if there are pending migrations"
|
101
|
-
task :abort_if_pending_migrations => :environment do
|
102
|
-
if defined? ActiveGroonga
|
103
|
-
pending_migrations = ActiveGroonga::Migrator.new(:up, 'db/groonga/migrate').pending_migrations
|
104
|
-
|
105
|
-
if pending_migrations.any?
|
106
|
-
puts "You have #{pending_migrations.size} pending migrations:"
|
107
|
-
pending_migrations.each do |pending_migration|
|
108
|
-
puts ' %4d %s' % [pending_migration.version, pending_migration.name]
|
109
|
-
end
|
110
|
-
abort %{Run "rake groonga:migrate" to update your database then try again.}
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
namespace :schema do
|
116
|
-
desc "Create a db/groonga/schema.rb file"
|
117
|
-
task :dump => :environment do
|
118
|
-
require 'active_groonga/schema_dumper'
|
119
|
-
File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/groonga/schema.rb", "w") do |file|
|
120
|
-
ActiveGroonga::SchemaDumper.dump(file)
|
121
|
-
end
|
122
|
-
Rake::Task["groonga:schema:dump"].reenable
|
123
|
-
end
|
124
|
-
|
125
|
-
desc "Load a schema.rb file into the database"
|
126
|
-
task :load => :environment do
|
127
|
-
file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/groonga/schema.rb"
|
128
|
-
load(file)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
namespace :test do
|
133
|
-
desc "Recreate the test database from the current schema.rb"
|
134
|
-
task :load => 'groonga:test:purge' do
|
135
|
-
ActiveGroonga::Base.setup_database(:test)
|
136
|
-
ActiveGroonga::Migration.verbose = false
|
137
|
-
Rake::Task["groonga:schema:load"].invoke
|
138
|
-
end
|
139
|
-
|
140
|
-
desc "Recreate the test database from the current environment's database schema"
|
141
|
-
task :clone => %w(groonga:schema:dump groonga:test:load)
|
142
|
-
|
143
|
-
desc "Recreate the test databases from the development structure"
|
144
|
-
task :clone_structure => ["groonga:schema:dump", "groonga:test:purge"] do
|
145
|
-
RAILS_ENV.replace("test")
|
146
|
-
Rake::Task["groonga:schema:load"].invoke
|
147
|
-
end
|
148
|
-
|
149
|
-
desc "Empty the test database"
|
150
|
-
task :purge => :environment do
|
151
|
-
ActiveGroonga::Base.setup_database(:test)
|
152
|
-
ActiveGroonga::Base.database.remove
|
153
|
-
rm_rf(ActiveGroonga::Base.database_directory)
|
154
|
-
# FIXME: groonga isn't fully implemented remove for database.
|
155
|
-
end
|
156
|
-
|
157
|
-
desc 'Check for pending migrations and load the test schema'
|
158
|
-
task :prepare => 'groonga:abort_if_pending_migrations' do
|
159
|
-
if defined?(ActiveGroonga) && !ActiveGroonga::Base.configurations.blank?
|
160
|
-
Rake::Task["groonga:test:load"].invoke
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009 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
|
-
module ActiveGroonga
|
17
|
-
module Timestamp
|
18
|
-
class << self
|
19
|
-
def included(base)
|
20
|
-
base.class_eval do
|
21
|
-
include(ActiveRecord::Timestamp)
|
22
|
-
extend(ClassMethods)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module ClassMethods
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|