activegroonga 0.0.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/README.ja.rdoc +4 -1
  2. data/README.rdoc +4 -1
  3. data/Rakefile +18 -4
  4. data/lib/active_groonga.rb +25 -52
  5. data/lib/active_groonga/base.rb +164 -1480
  6. data/lib/active_groonga/callbacks.rb +26 -7
  7. data/lib/active_groonga/database.rb +55 -0
  8. data/lib/active_groonga/{dirty.rb → error.rb} +20 -10
  9. data/lib/active_groonga/locale/en.yml +5 -0
  10. data/lib/active_groonga/migration.rb +44 -113
  11. data/lib/active_groonga/migrator.rb +172 -0
  12. data/lib/active_groonga/persistence.rb +172 -0
  13. data/lib/active_groonga/railtie.rb +66 -0
  14. data/lib/active_groonga/railties/configurable.rb +47 -0
  15. data/lib/active_groonga/railties/groonga.rake +167 -0
  16. data/lib/active_groonga/result_set.rb +89 -0
  17. data/lib/active_groonga/schema.rb +54 -188
  18. data/lib/active_groonga/validations.rb +54 -5
  19. data/lib/active_groonga/vector.rb +64 -0
  20. data/lib/active_groonga/version.rb +3 -3
  21. data/lib/{active_groonga/aggregations.rb → rails/generators/active_groonga.rb} +17 -10
  22. data/lib/rails/generators/active_groonga/migration/column.rb +101 -0
  23. data/lib/rails/generators/active_groonga/migration/migration_generator.rb +53 -0
  24. data/lib/rails/generators/active_groonga/migration/templates/migration.rb +29 -0
  25. data/lib/rails/generators/active_groonga/model/model_generator.rb +60 -0
  26. data/lib/rails/generators/active_groonga/model/templates/migration.rb +16 -0
  27. data/lib/rails/generators/active_groonga/model/templates/model.rb +2 -0
  28. data/lib/rails/generators/active_groonga/model/templates/module.rb +5 -0
  29. data/test-unit-notify/COPYING +502 -0
  30. data/test-unit-notify/Rakefile +47 -0
  31. data/test-unit-notify/lib/test/unit/notify.rb +127 -0
  32. data/test-unit/COPYING +56 -0
  33. data/test-unit/GPL +340 -0
  34. data/test-unit/PSFL +271 -0
  35. data/test-unit/Rakefile +18 -5
  36. data/test-unit/html/bar.svg +153 -0
  37. data/test-unit/html/developer.svg +469 -0
  38. data/test-unit/html/favicon.ico +0 -0
  39. data/test-unit/html/favicon.svg +82 -0
  40. data/test-unit/html/heading-mark.svg +393 -0
  41. data/test-unit/html/index.html +235 -13
  42. data/test-unit/html/index.html.ja +258 -15
  43. data/test-unit/html/install.svg +636 -0
  44. data/test-unit/html/logo.svg +483 -0
  45. data/test-unit/html/test-unit.css +339 -0
  46. data/test-unit/html/tutorial.svg +559 -0
  47. data/test-unit/lib/test/unit.rb +29 -43
  48. data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
  49. data/test-unit/lib/test/unit/assertions.rb +202 -20
  50. data/test-unit/lib/test/unit/autorunner.rb +51 -20
  51. data/test-unit/lib/test/unit/collector.rb +1 -8
  52. data/test-unit/lib/test/unit/collector/dir.rb +1 -1
  53. data/test-unit/lib/test/unit/collector/load.rb +16 -9
  54. data/test-unit/lib/test/unit/color-scheme.rb +19 -3
  55. data/test-unit/lib/test/unit/diff.rb +240 -38
  56. data/test-unit/lib/test/unit/error.rb +4 -0
  57. data/test-unit/lib/test/unit/failure.rb +31 -5
  58. data/test-unit/lib/test/unit/notification.rb +8 -4
  59. data/test-unit/lib/test/unit/omission.rb +51 -3
  60. data/test-unit/lib/test/unit/pending.rb +4 -0
  61. data/test-unit/lib/test/unit/priority.rb +2 -3
  62. data/test-unit/lib/test/unit/testcase.rb +65 -7
  63. data/test-unit/lib/test/unit/testresult.rb +34 -2
  64. data/test-unit/lib/test/unit/ui/console/testrunner.rb +197 -45
  65. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
  66. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +2 -12
  67. data/test-unit/lib/test/unit/ui/testrunner.rb +33 -0
  68. data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
  69. data/test-unit/lib/test/unit/util/output.rb +31 -0
  70. data/test-unit/lib/test/unit/version.rb +1 -1
  71. data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
  72. data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
  73. data/test-unit/sample/test_user.rb +1 -0
  74. data/test-unit/test/collector/test-descendant.rb +2 -4
  75. data/test-unit/test/collector/test-load.rb +121 -8
  76. data/test-unit/test/collector/test_objectspace.rb +7 -5
  77. data/test-unit/test/run-test.rb +2 -0
  78. data/test-unit/test/test-color-scheme.rb +11 -2
  79. data/test-unit/test/test-diff.rb +48 -7
  80. data/test-unit/test/test-omission.rb +1 -1
  81. data/test-unit/test/test-testcase.rb +57 -20
  82. data/test-unit/test/test_assertions.rb +128 -13
  83. data/test-unit/test/ui/test_tap.rb +33 -0
  84. data/test-unit/test/util/test-output.rb +11 -0
  85. data/test/active-groonga-test-utils.rb +50 -36
  86. data/test/fixtures/site.rb +2 -0
  87. data/test/run-test.rb +36 -9
  88. data/test/test-associations.rb +5 -2
  89. data/test/test-base.rb +39 -31
  90. data/test/test-callbacks.rb +13 -3
  91. data/test/test-persistence.rb +53 -0
  92. data/{lib/active_groonga/observer.rb → test/test-result-set.rb} +14 -12
  93. data/test/test-schema.rb +85 -22
  94. data/{lib/active_groonga/rails_support.rb → test/test-validations.rb} +15 -13
  95. metadata +85 -52
  96. data/lib/active_groonga/associations.rb +0 -93
  97. data/lib/active_groonga/associations/belongs_to_association.rb +0 -25
  98. data/lib/active_groonga/attribute_methods.rb +0 -36
  99. data/lib/active_groonga/column.rb +0 -137
  100. data/lib/active_groonga/dynamic_record_expression_builder.rb +0 -40
  101. data/lib/active_groonga/reflection.rb +0 -30
  102. data/lib/active_groonga/schema_dumper.rb +0 -163
  103. data/lib/active_groonga/tasks.rb +0 -16
  104. data/lib/active_groonga/tasks/groonga.rake +0 -164
  105. data/lib/active_groonga/timestamp.rb +0 -30
  106. data/rails/README +0 -28
  107. data/rails/init.rb +0 -70
  108. data/rails_generators/index_table_groonga/USAGE +0 -23
  109. data/rails_generators/index_table_groonga/index_table_groonga_generator.rb +0 -44
  110. data/rails_generators/index_table_groonga/templates/migration.rb +0 -12
  111. data/rails_generators/migration_groonga/USAGE +0 -29
  112. data/rails_generators/migration_groonga/migration_groonga_generator.rb +0 -19
  113. data/rails_generators/migration_groonga/templates/migration.rb +0 -11
  114. data/rails_generators/model_groonga/USAGE +0 -28
  115. data/rails_generators/model_groonga/model_groonga_generator.rb +0 -45
  116. data/rails_generators/model_groonga/templates/fixtures.yml +0 -17
  117. data/rails_generators/model_groonga/templates/migration.rb +0 -16
  118. data/rails_generators/model_groonga/templates/model.rb +0 -2
  119. data/rails_generators/model_groonga/templates/unit_test.rb +0 -8
  120. data/test-unit/html/classic.html +0 -15
  121. data/test-unit/sample/ts_examples.rb +0 -7
  122. data/test/test-schema-dumper.rb +0 -48
data/rails/README DELETED
@@ -1,28 +0,0 @@
1
- = ActiveGroonga plugin for Ruby on Rails
2
-
3
- == Setup
4
-
5
- You need to write RAILS_ROOT/config/groonga.yml like the following:
6
-
7
- development:
8
- database: db/development.groonga
9
-
10
- test:
11
- database: db/test.groonga
12
-
13
- production:
14
- database: db/production.groonga
15
-
16
- == Model
17
-
18
- Here is some examples.
19
-
20
- app/model/post.rb:
21
- class Post < ActiveGroonga::Base
22
- belongs_to :users
23
- end
24
-
25
- app/model/user.rb:
26
- class User < ActiveGroonga::Base
27
- has_many :posts
28
- end
data/rails/init.rb DELETED
@@ -1,70 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ActiveGroonga::Base.logger ||= Rails.logger
4
-
5
- case Rails.logger.level
6
- when ActiveSupport::BufferedLogger::DEBUG
7
- log_level = :debug
8
- when ActiveSupport::BufferedLogger::INFO
9
- log_level = :info
10
- when ActiveSupport::BufferedLogger::WARN
11
- log_level = :warning
12
- when ActiveSupport::BufferedLogger::ERROR
13
- log_level = :error
14
- when ActiveSupport::BufferedLogger::FATAL
15
- log_level = :critical
16
- when ActiveSupport::BufferedLogger::UNKNOWN
17
- log_level = :none
18
- else
19
- log_level = :info
20
- end
21
- options = {:level => log_level}
22
- Groonga::Logger.register(options) do |level, time, title, message, location|
23
- logger = ActiveGroonga::Base.logger
24
- method_name = :info
25
- case level
26
- when :debug
27
- method_name = :debug
28
- when :info
29
- method_name = :info
30
- when :warning
31
- method_name = :warn
32
- when :error
33
- method_name = :error
34
- when :critical
35
- method_name = :fatal
36
- when :none
37
- method_name = :unknown
38
- end
39
- message = "[#{title}] #{message}" unless title.blank?
40
- logger.send(method_name, message)
41
- end
42
-
43
- configuration_file = config.groonga_configuration_file
44
- unless File.exist?(configuration_file)
45
- File.open(configuration_file, "w") do |file|
46
- file.puts <<-EOC
47
- development:
48
- database: db/development.groonga
49
-
50
- test:
51
- database: db/test.groonga
52
-
53
- production:
54
- database: db/production.groonga
55
- EOC
56
- end
57
- end
58
- ActiveGroonga::Base.configurations = config.groonga_configuration
59
- ActiveGroonga::Base.setup_database
60
-
61
- # class ::ActionView::Base
62
- # include ActiveGroonga::Helper
63
- # end
64
-
65
- # require 'active_groonga/action_controller/groonga_benchmarking'
66
- # module ::ActionController
67
- # class Base
68
- # include ActiveGroonga::ActionController::GroongaBenchmarking
69
- # end
70
- # end
@@ -1,23 +0,0 @@
1
- Description:
2
- Stubs out a new index table migration. Pass the index table name
3
- and an optional tokenizer as an argument.
4
-
5
- A migration class is generated in db/groonga/migrate prefixed by a timestamp of the current date and time.
6
-
7
- Example:
8
- `./script/generate index_table_groonga terms`
9
-
10
- If the current date is May 14, 2008 and the current time 09:09:12, this creates the CreateTerms migration
11
- db/groonga/migrate/20080514090912_create_terms.rb
12
-
13
- `./script/generate index_table_groonga terms TokenMeCab`
14
-
15
- This will create the CreateTerms in db/groonga/migrate/20080514090912_create_terms.rb with
16
- this in the Up migration:
17
-
18
- create_table :terms, :default_tokenizer => "TokenMeCab" do |t|
19
- end
20
-
21
- And this in the Down migration:
22
-
23
- drop_table :terms
@@ -1,44 +0,0 @@
1
- class IndexTableGroongaGenerator < Rails::Generator::NamedBase
2
- default_options :type => nil, :tokenizer => nil
3
-
4
- def manifest
5
- record do |m|
6
- m.migration_template 'migration.rb', 'db/groonga/migrate', :assigns => {
7
- :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}",
8
- :type => (options[:type] || :patricia_trie).inspect,
9
- :default_tokenizer_name => (options[:tokenizer] || "TokenBigram").inspect,
10
- }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
11
- end
12
- end
13
-
14
- private
15
- def banner
16
- "Usage: #{$0} #{spec.name} index_table_name\n" +
17
- " e.g.: #{$0} #{spec.name} terms"
18
- end
19
-
20
- def add_options!(opt)
21
- opt.separator ''
22
- opt.separator 'Options:'
23
- opt.on("--type=TYPE", %w(array patricia_trie hash),
24
- "Use TYPE as a table type") do |value|
25
- options[:type] = value
26
- end
27
-
28
- opt.on("--tokenizer=TOKENIZER", %w(unigram bigram trigram mecab),
29
- "Use TOKENIZER as a default tokenizer") do |value|
30
- case value
31
- when "unigram"
32
- options[:tokenizer] = "TokenUnigram"
33
- when "bigram"
34
- options[:tokenizer] = "TokenBigram"
35
- when "trigram"
36
- options[:tokenizer] = "TokenTrigram"
37
- when "mecab"
38
- options[:tokenizer] = "TokenMacab"
39
- else
40
- options[:tokenizer] = value
41
- end
42
- end
43
- end
44
- end
@@ -1,12 +0,0 @@
1
- class <%= migration_name %> < ActiveGroonga::Migration
2
- def self.up
3
- create_table :<%= table_name %>,
4
- :type => <%= type %>,
5
- :default_tokenizer => <%= default_tokenizer_name %> do |t|
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :<%= table_name %>
11
- end
12
- end
@@ -1,29 +0,0 @@
1
- Description:
2
- Stubs out a new database migration. Pass the migration name, either
3
- CamelCased or under_scored, and an optional list of attribute pairs as arguments.
4
-
5
- A migration class is generated in db/groonga/migrate prefixed by a timestamp of the current date and time.
6
-
7
- You can name your migration in either of these formats to generate add/remove
8
- column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable
9
-
10
- Example:
11
- `./script/generate migration_groonga AddSslFlag`
12
-
13
- If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration
14
- db/groonga/migrate/20080514090912_add_ssl_flag.rb
15
-
16
- `./script/generate migration_groonga AddTitleBodyToPost title:string body:text published:boolean`
17
-
18
- This will create the AddTitleBodyToPost in db/groonga/migrate/20080514090912_add_title_body_to_post.rb with
19
- this in the Up migration:
20
-
21
- add_column :posts, :title, :string
22
- add_column :posts, :body, :text
23
- add_column :posts, :published, :boolean
24
-
25
- And this in the Down migration:
26
-
27
- remove_column :posts, :published
28
- remove_column :posts, :body
29
- remove_column :posts, :title
@@ -1,19 +0,0 @@
1
- class MigrationGroongaGenerator < Rails::Generator::NamedBase
2
- def manifest
3
- record do |m|
4
- m.migration_template 'migration.rb', 'db/groonga/migrate', :assigns => get_local_assigns
5
- end
6
- end
7
-
8
- private
9
- def get_local_assigns
10
- returning(assigns = {}) do
11
- if class_name.underscore =~ /^(add|remove)_.*_(?:to|from)_(.*)/
12
- assigns[:migration_action] = $1
13
- assigns[:table_name] = $2.pluralize
14
- else
15
- assigns[:attributes] = []
16
- end
17
- end
18
- end
19
- end
@@ -1,11 +0,0 @@
1
- class <%= class_name.underscore.camelize %> < ActiveGroonga::Migration
2
- def self.up<% attributes.each do |attribute| %>
3
- <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%>
4
- <%- end %>
5
- end
6
-
7
- def self.down<% attributes.reverse.each do |attribute| %>
8
- <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%>
9
- <%- end %>
10
- end
11
- end
@@ -1,28 +0,0 @@
1
- Description:
2
- Stubs out a new model. Pass the model name, either CamelCased or
3
- under_scored, and an optional list of attribute pairs as arguments.
4
-
5
- Attribute pairs are column_name:groonga_type arguments specifying the
6
- model's attributes. Timestamps are added by default, so you don't have to
7
- specify them by hand as 'created_at:datetime updated_at:datetime'.
8
-
9
- You don't have to think up every attribute up front, but it helps to
10
- sketch out a few so you can start working with the model immediately.
11
-
12
- This generates a model class in app/models, a unit test in test/unit,
13
- a test fixture in test/fixtures/singular_name.yml, and a migration in
14
- db/migrate.
15
-
16
- Examples:
17
- `./script/generate model_groonga account`
18
-
19
- creates an Account model, test, fixture, and migration:
20
- Model: app/models/account.rb
21
- Test: test/unit/account_test.rb
22
- Fixtures: test/fixtures/accounts.yml
23
- Migration: db/migrate/XXX_add_accounts.rb
24
-
25
- `./script/generate model_groonga Post title:string content:text user:references`
26
-
27
- creates a Post model with a string title, text content, and user who posts.
28
-
@@ -1,45 +0,0 @@
1
- class ModelGroongaGenerator < Rails::Generator::NamedBase
2
- default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false
3
-
4
- def manifest
5
- record do |m|
6
- # Check for class naming collisions.
7
- m.class_collisions class_name, "#{class_name}Test"
8
-
9
- # Model, test, and fixture directories.
10
- m.directory File.join('app/models', class_path)
11
- m.directory File.join('test/unit', class_path)
12
- m.directory File.join('test/fixtures', class_path)
13
-
14
- # Model class, unit test, and fixtures.
15
- m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
16
- m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
17
-
18
- unless options[:skip_fixture]
19
- m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
20
- end
21
-
22
- unless options[:skip_migration]
23
- m.migration_template 'migration.rb', 'db/groonga/migrate', :assigns => {
24
- :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
25
- }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
26
- end
27
- end
28
- end
29
-
30
- private
31
- def banner
32
- "Usage: #{$0} #{spec.name} ModelName [field:type, field:type]"
33
- end
34
-
35
- def add_options!(opt)
36
- opt.separator ''
37
- opt.separator 'Options:'
38
- opt.on("--skip-timestamps",
39
- "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
40
- opt.on("--skip-migration",
41
- "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
42
- opt.on("--skip-fixture",
43
- "Don't generation a fixture file for this model") { |v| options[:skip_fixture] = v}
44
- end
45
- end
@@ -1,17 +0,0 @@
1
- <% unless attributes.empty? -%>
2
- one:
3
- <% for attribute in attributes -%>
4
- <%= attribute.name %>: <%= attribute.default %>
5
- <% end -%>
6
-
7
- two:
8
- <% for attribute in attributes -%>
9
- <%= attribute.name %>: <%= attribute.default %>
10
- <% end -%>
11
- <% else -%>
12
- # one:
13
- # column: value
14
- #
15
- # two:
16
- # column: value
17
- <% end -%>
@@ -1,16 +0,0 @@
1
- class <%= migration_name %> < ActiveGroonga::Migration
2
- def self.up
3
- create_table :<%= table_name %> do |t|
4
- <% for attribute in attributes -%>
5
- t.<%= attribute.type %> :<%= attribute.name %>
6
- <% end -%>
7
- <% unless options[:skip_timestamps] %>
8
- t.timestamps
9
- <% end -%>
10
- end
11
- end
12
-
13
- def self.down
14
- drop_table :<%= table_name %>
15
- end
16
- end
@@ -1,2 +0,0 @@
1
- class <%= class_name %> < ActiveGroonga::Base
2
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= class_name %>Test < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,15 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
- <html>
3
- <head>
4
- <title>Test::Unit (Classic)</title>
5
- </head>
6
- <body bgcolor="red">
7
- <p style="text-align: center">
8
- <img height="161" width="308" src="test-unit-classic.png">
9
- <br>
10
- <br>
11
- <br>
12
- Read the <a href="classic/test-unit/">rdoc</a>
13
- </p>
14
- </body>
15
- </html>
@@ -1,7 +0,0 @@
1
- # Author:: Nathaniel Talbott.
2
- # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
3
- # License:: Ruby license.
4
-
5
- require 'test/unit'
6
- require 'tc_adder'
7
- require 'tc_subtracter'
@@ -1,48 +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 as published by the Free Software Foundation; either
6
- # version 2.1 of the License.
7
- #
8
- # This library is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- # Lesser General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU Lesser General Public
14
- # License along with this library; if not, write to the Free Software
15
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
-
17
- class TestSchemaDumper < Test::Unit::TestCase
18
- include ActiveGroongaTestUtils
19
-
20
- def setup
21
- @output = StringIO.new
22
- end
23
-
24
- def test_dump
25
- ActiveGroonga::SchemaDumper.dump(@output)
26
- assert_equal(<<-EOS, @output.string.gsub(/^\s*(?:#.*)?\n/, ''))
27
- ActiveGroonga::Schema.define(:version => 0) do
28
- create_table "bookmarks", :force => true do |t|
29
- t.string "uri"
30
- t.time "updated_at"
31
- t.time "created_at"
32
- t.text "content"
33
- t.text "comment"
34
- end
35
- create_table "tasks", :force => true do |t|
36
- t.string "name"
37
- end
38
- create_table "terms", :force => true, :type => :patricia_trie, :key_type => "ShortText", :default_tokenizer => "TokenBigram" do |t|
39
- end
40
- create_table "users", :force => true do |t|
41
- t.string "name"
42
- end
43
- add_column "bookmarks", "user", "users"
44
- add_index_column "terms", "bookmarks", "content", :name => "bookmarks/content"
45
- end
46
- EOS
47
- end
48
- end