public
Description: StrokeDB is an embeddable distributed document database written in Ruby
Homepage: http://strokedb.com/
Clone URL: git://github.com/yrashk/strokedb.git
Minor spec_helper improvement
yrashk (author)
Sat May 24 13:29:20 -0700 2008
commit  2c3a8d36ec7157a7c92e096bcaaf0269f96d1519
tree    abb1f1361d4ff202867edcd62e7bb843da5d56c2
parent  f1c717512dd43956ca4bfca09b8d3da905ca1013
...
7
8
9
10
11
12
13
14
15
 
 
 
 
 
 
16
17
18
19
20
21
 
 
 
 
 
22
23
24
25
 
 
 
26
27
28
29
30
31
32
 
 
 
 
33
34
35
36
37
38
39
40
41
42
 
 
 
 
 
 
 
43
44
45
46
47
 
 
48
49
 
 
 
 
 
 
50
51
 
52
53
54
55
 
56
57
...
7
8
9
 
 
 
 
 
 
10
11
12
13
14
15
16
 
 
 
 
 
17
18
19
20
21
22
 
 
 
23
24
25
26
27
28
 
 
 
 
29
30
31
32
33
34
35
 
 
 
 
 
 
 
36
37
38
39
40
41
42
43
44
45
 
 
46
47
48
 
49
50
51
52
53
54
55
 
56
57
58
59
 
60
61
62
0
@@ -7,50 +7,55 @@ TEMP_DIR = SPEC_ROOT + '/temp'
0
 TEMP_STORAGES = TEMP_DIR + '/storages'
0
 
0
 def setup_default_store(store=nil)
0
-if store
0
-  StrokeDB.stub!(:default_store).and_return(store)
0
-  return store
0
-end
0
-@path = TEMP_STORAGES
0
-FileUtils.rm_rf @path
0
+  if store
0
+    StrokeDB.stub!(:default_store).and_return(store)
0
+    return store
0
+  end
0
+  @path = TEMP_STORAGES
0
+  FileUtils.rm_rf @path
0
 
0
-@storage = if ENV['STORAGE'].to_s.downcase == 'file'
0
-  StrokeDB::FileStorage.new(:path => @path + '/file_storage')
0
-else
0
-  StrokeDB::MemoryStorage.new
0
-end
0
+  @storage = if ENV['STORAGE'].to_s.downcase == 'file'
0
+    StrokeDB::FileStorage.new(:path => @path + '/file_storage')
0
+  else
0
+    StrokeDB::MemoryStorage.new
0
+  end
0
 
0
-$store = StrokeDB::Store.new(:storage => @storage,:index => @index, :path => @path)
0
-StrokeDB.stub!(:default_store).and_return($store)
0
-StrokeDB.default_store
0
+  $store = StrokeDB::Store.new(:storage => @storage,:index => @index, :path => @path)
0
+  StrokeDB.stub!(:default_store).and_return($store)
0
+  StrokeDB.default_store
0
 end
0
 
0
 def stub_meta_in_store(store=nil)
0
-store ||= StrokeDB.default_store
0
-meta = store.find(NIL_UUID)
0
-store.should_receive(:find).with(NIL_UUID).any_number_of_times.and_return(meta)
0
-store.should_receive(:include?).with(NIL_UUID).any_number_of_times.and_return(true)
0
+  store ||= StrokeDB.default_store
0
+  meta = store.find(NIL_UUID)
0
+  store.should_receive(:find).with(NIL_UUID).any_number_of_times.and_return(meta)
0
+  store.should_receive(:include?).with(NIL_UUID).any_number_of_times.and_return(true)
0
 end
0
 
0
 def setup_index(store=nil)
0
-store ||= StrokeDB.default_store
0
-index_storage = StrokeDB::InvertedListFileStorage.new(:path => TEMP_STORAGES + '/inverted_list_storage')
0
-index_storage.clear!
0
-@index = StrokeDB::InvertedListIndex.new(index_storage)
0
-@index.document_store = store
0
-store.index_store = @index
0
-@index
0
+  store ||= StrokeDB.default_store
0
+  index_storage = StrokeDB::InvertedListFileStorage.new(:path => TEMP_STORAGES + '/inverted_list_storage')
0
+  index_storage.clear!
0
+  @index = StrokeDB::InvertedListIndex.new(index_storage)
0
+  @index.document_store = store
0
+  store.index_store = @index
0
+  @index
0
 end
0
 
0
 Spec::Runner.configure do |config|
0
-config.after(:all) do
0
-  
0
+  config.after(:all) do
0
+
0
     ObjectSpace.each_object do |obj|
0
-      obj.stop_autosync! if obj.is_a?(Store) rescue nil
0
+      if obj.is_a?(Store) 
0
+        begin
0
+          obj.stop_autosync! 
0
+        rescue Exception
0
+        end
0
+      end
0
     end
0
-    
0
+
0
     ObjectSpace.each_object do |obj|
0
       obj.close if obj.is_a?(::File) rescue nil
0
     end
0
-end
0
+  end
0
 end
0
\ No newline at end of file

Comments