activegroonga 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,16 @@
1
1
  h1. NEWS
2
2
 
3
+ h2(#2-1-3). 2.1.3: 2013-01-06
4
+
5
+ h3. Improvements
6
+
7
+ * [GitHub#8] Supported reference column to key support tables such as
8
+ hash table. [Reported by Kenta Sato]
9
+
10
+ h3. Thanks
11
+
12
+ * Kenta Sato
13
+
3
14
  h2(#2-1-2). 2.1.2: 2013-01-04
4
15
 
5
16
  h3. Improvements
@@ -95,7 +95,7 @@ module ActiveGroonga
95
95
  next if value.nil?
96
96
  if value.is_a?(Base)
97
97
  value.save if value.new_record?
98
- value = value.id
98
+ value = value.record_id
99
99
  end
100
100
  attributes[key] = value
101
101
  end
@@ -17,7 +17,7 @@ module ActiveGroonga
17
17
  module VERSION
18
18
  MAJOR = 2
19
19
  MINOR = 1
20
- TINY = 2
20
+ TINY = 3
21
21
 
22
22
  STRING = [MAJOR, MINOR, TINY].join(".")
23
23
  end
@@ -42,6 +42,7 @@ module ActiveGroongaTestUtils
42
42
  setup_bookmarks_index_tables
43
43
  setup_tasks_table
44
44
  setup_sites_table
45
+ setup_pages_table
45
46
 
46
47
  setup_user_records
47
48
  setup_bookmark_records
@@ -49,7 +50,17 @@ module ActiveGroongaTestUtils
49
50
  end
50
51
 
51
52
  def setup_tmp_directory
52
- @tmp_dir = Pathname(File.dirname(__FILE__)) + "tmp"
53
+ @base_tmp_dir = Pathname(File.dirname(__FILE__)) + "tmp"
54
+ memory_file_system = "/dev/shm"
55
+ if File.exist?(memory_file_system)
56
+ FileUtils.mkdir_p(@base_tmp_dir.parent.to_s)
57
+ FileUtils.rm_f(@base_tmp_dir.to_s)
58
+ FileUtils.ln_s(memory_file_system, @base_tmp_dir.to_s)
59
+ else
60
+ FileUtils.mkdir_p(@base_tmp_dir.to_s)
61
+ end
62
+
63
+ @tmp_dir = @base_tmp_dir + "active-groonga"
53
64
  FileUtils.rm_rf(@tmp_dir.to_s)
54
65
  FileUtils.mkdir_p(@tmp_dir.to_s)
55
66
  end
@@ -192,6 +203,20 @@ module ActiveGroongaTestUtils
192
203
  :path => @score_column_path.to_s)
193
204
  end
194
205
 
206
+ def setup_pages_table
207
+ @pages_path = @tables_dir + "pages"
208
+ @pages = Groonga::Hash.create(:name => "pages",
209
+ :key_type => "ShortText",
210
+ :path => @pages_path.to_s)
211
+
212
+ columns_dir = @tables_dir + "pages.columns"
213
+ columns_dir.mkpath
214
+
215
+ @site_column_path = columns_dir + "site"
216
+ @site_column = @pages.define_column("site", @sites,
217
+ :path => @site_column_path.to_s)
218
+ end
219
+
195
220
  def setup_user_records
196
221
  @user_records = {}
197
222
 
@@ -228,11 +253,13 @@ module ActiveGroongaTestUtils
228
253
  remove_const(:Bookmark) if const_defined?(:Bookmark)
229
254
  remove_const(:Task) if const_defined?(:Task)
230
255
  remove_const(:Site) if const_defined?(:Site)
256
+ remove_const(:Page) if const_defined?(:Page)
231
257
  end
232
258
  load((base_dir + 'user.rb').to_s)
233
259
  load((base_dir + 'bookmark.rb').to_s)
234
260
  load((base_dir + 'task.rb').to_s)
235
261
  load((base_dir + 'site.rb').to_s)
262
+ load((base_dir + 'page.rb').to_s)
236
263
  end
237
264
 
238
265
  def teardown_sand_box
@@ -0,0 +1,2 @@
1
+ class Page < ActiveGroonga::Base
2
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2010-2013 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -30,12 +30,33 @@ class TestPersistence < Test::Unit::TestCase
30
30
  [found_site.key, found_site.title])
31
31
  end
32
32
 
33
- def test_create_hash
34
- groonga = Site.create(:key => "http://groonga.org/",
35
- :title => "groonga")
36
- found_groonga = Site.find("http://groonga.org/")
37
- assert_equal(["http://groonga.org/", "groonga"],
38
- [found_groonga.key, found_groonga.title])
33
+ class TestCreate < self
34
+ def test_hash
35
+ groonga = Site.create(:key => "http://groonga.org/",
36
+ :title => "groonga")
37
+ found_groonga = Site.find("http://groonga.org/")
38
+ assert_equal(["http://groonga.org/", "groonga"],
39
+ [found_groonga.key, found_groonga.title])
40
+ end
41
+
42
+ class TestReference < self
43
+ def test_have_key
44
+ groonga = Site.create(:key => "http://groonga.org/",
45
+ :title => "groonga")
46
+ doc = Page.create(:key => "http://groonga.org/doc/",
47
+ :site => groonga)
48
+ found_doc = Page.find("http://groonga.org/doc/")
49
+ assert_equal(groonga.key, found_doc.site.key)
50
+ end
51
+
52
+ def test_no_key
53
+ daijiro = @user_records[:daijiro]
54
+ groonga = Bookmark.create(:uri => "http://groonga.org/",
55
+ :user => daijiro)
56
+ found_groonga = Bookmark.find(groonga.id)
57
+ assert_equal(daijiro.id, found_groonga.user.id)
58
+ end
59
+ end
39
60
  end
40
61
 
41
62
  def test_update
data/test/test-schema.rb CHANGED
@@ -96,6 +96,12 @@ ActiveGroonga::Schema.define(:version => 0) do |schema|
96
96
  table.short_text("uri")
97
97
  end
98
98
 
99
+ create_table("pages",
100
+ :type => :hash,
101
+ :key_type => "ShortText",
102
+ :force => true) do |table|
103
+ end
104
+
99
105
  create_table("sites",
100
106
  :type => :hash,
101
107
  :key_type => "ShortText",
@@ -125,6 +131,10 @@ ActiveGroonga::Schema.define(:version => 0) do |schema|
125
131
  table.reference("user", "users")
126
132
  end
127
133
 
134
+ change_table("pages") do |table|
135
+ table.reference("site", "sites")
136
+ end
137
+
128
138
  change_table("terms") do |table|
129
139
  table.index("bookmarks", "comment", :name => "bookmarks_comment")
130
140
  table.index("bookmarks", "content", :name => "bookmarks_content")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegroonga
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
12
+ date: 2013-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rroonga
@@ -194,6 +194,7 @@ files:
194
194
  - test/run-test.rb
195
195
  - test/test-schema.rb
196
196
  - test/fixtures/site.rb
197
+ - test/fixtures/page.rb
197
198
  - test/fixtures/user.rb
198
199
  - test/fixtures/bookmark.rb
199
200
  - test/fixtures/task.rb
@@ -233,6 +234,7 @@ test_files:
233
234
  - test/run-test.rb
234
235
  - test/test-schema.rb
235
236
  - test/fixtures/site.rb
237
+ - test/fixtures/page.rb
236
238
  - test/fixtures/user.rb
237
239
  - test/fixtures/bookmark.rb
238
240
  - test/fixtures/task.rb