Permalink
Browse files

adding reopen command

  • Loading branch information...
1 parent 8eec09e commit ecec0cb44e1c465428a67e4d055a8159fd35309e @ryanb committed Dec 14, 2011
Showing with 11 additions and 2 deletions.
  1. +6 −2 lib/xapit/server/database.rb
  2. +5 −0 spec/xapit/server/database_spec.rb
@@ -1,7 +1,7 @@
module Xapit
module Server
class Database
- COMMANDS = %w[query add_document remove_document update_document spelling_suggestion]
+ COMMANDS = %w[query add_document remove_document update_document spelling_suggestion reopen]
def initialize(path)
@path = path
@@ -32,7 +32,11 @@ def spelling_suggestion(data)
Xapit.query_class.new(data).spelling_suggestion
end
- private
+ def reopen(data = nil)
+ xapian_database.reopen
+ end
+
+ private
def load_database
if @path
@@ -34,4 +34,9 @@
@database.update_document(:attributes => {:greeting => {:value => "aloha", :text => {}}}, :id => 123, :class => "Greeting")
@database.query([{:search => "aloha"}])[:records].should eq([{:class => "Greeting", :id => "123", :relevance => 100}])
end
+
+ it "reopens the database" do
+ @database.xapian_database.should_receive(:reopen)
+ @database.reopen
+ end
end

0 comments on commit ecec0cb

Please sign in to comment.