xapian-fu 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzU5N2ExNTgxZjc3NzlhZjkwMjhiY2UzZDcwMzZhNzQwODk0N2M2ZQ==
4
+ ZWQ0ZTRhYmZlNmM5MWVlMWJmMjg1OTViNjYyNTBjYTc4NGMyYjlkMQ==
5
5
  data.tar.gz: !binary |-
6
- YWE3ZDUwYmMyNTdiZjg2NzdhZGNjNTNkYzJhYjg2NzAzNTkyYjg2OA==
6
+ MGEyZjY2MDcxMTRjNWY4NjQ4ZDllNDAyYjY0Y2MzOTBmODg4ZTRmNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDVmYmQ3YzA4OWUzYTZhNzEzYWU5NmMyMzU0ZDNmOTE2NDUyMDEyMDQwZTZk
10
- YTI0MGMwMzNiN2YwMmY0NmNlYzFmOTlhNjIzNTU5ZGZhZWI0MmMwZmNjNGI1
11
- MWYwYTQxYWZhMDQ3ZWExOWExM2Q5NGMzY2QyYjZkNmViYTJhMWQ=
9
+ OGVhZDMyNzM4YzU3MDVkZDQwZDkwZTQ0NTdjZWM3N2U2YzM4Mjk2ZjExNWU3
10
+ NDA2MjI3N2YyNzEzNGY5NWNhZWYzMjZjYjViYzBjYmJjNTdjZmQ3YTUzOWFj
11
+ ZWFmMDI2OGFmOWVmNTMyYmE5OTI2MzgwMmNkNzM0NmZlMTZjOTM=
12
12
  data.tar.gz: !binary |-
13
- NDE1OTM0NmQ2MThiZmVhYWU3YTYyNjEzZTIxNmE3MTRkZjRjYTI0MDhiNjg1
14
- MGRmZWM5YmNmY2ZmZmQwZDYyNDYwOWU4NjdiMDY2NWRlMDgwOGRjZjdiMGZi
15
- OGM4ZDgyODQ2ZWQxMzc2OTExOWY2ZjNlNWM1M2QyZDQwNTU1NjM=
13
+ MGUxNWFjYzAxMWNiZmU5ZGRkYWI2YTVjOThlYjk5Y2EwMjQ4ZjE4ZTE5MjUw
14
+ ZDFjODA2NDQ3ZGRhMDAyNzg1ZmFmY2EyNTAwMmFmNDk0NjdjNjI5NzI5NTRj
15
+ OGY2MDAxYjUxOTJkNzQ4NTEyMTZhYmEwMDQzMTU0MDQ4ZDdlNGM=
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ === 1.5.2 (25th July 2014)
2
+
3
+ * Added `XapianDb#close` to close both the read and write databases.
4
+
5
+ * Fixed a bug that caused the `:query_builder` to take precedence over
6
+ the given filters.
7
+
1
8
  === 1.5.1 (17th July 2014)
2
9
 
3
10
  * You can now customize the parsed query by passing `:query_builder` to
@@ -1,3 +1,3 @@
1
1
  module XapianFu #:nodoc:
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
@@ -271,12 +271,13 @@ module XapianFu #:nodoc:
271
271
 
272
272
  qp = XapianFu::QueryParser.new({ :database => self }.merge(options))
273
273
  query = qp.parse_query(q.is_a?(Symbol) ? q : q.to_s)
274
- query = filter_query(query, options[:filter]) if options[:filter]
275
274
 
276
275
  if options.include?(:query_builder)
277
276
  query = options[:query_builder].call(query)
278
277
  end
279
278
 
279
+ query = filter_query(query, options[:filter]) if options[:filter]
280
+
280
281
  enquiry = Xapian::Enquire.new(ro)
281
282
  setup_ordering(enquiry, options[:order], options[:reverse])
282
283
  if options[:collapse]
@@ -339,6 +340,17 @@ module XapianFu #:nodoc:
339
340
  ro.reopen
340
341
  end
341
342
 
343
+ # Closes the database.
344
+ def close
345
+ raise ConcurrencyError if @tx_mutex.locked?
346
+
347
+ @rw.close if @rw
348
+ @rw = nil
349
+
350
+ @ro.close if @ro
351
+ @ro = nil
352
+ end
353
+
342
354
  def serialize_value(field, value, type = nil)
343
355
  if sortable_fields.include?(field)
344
356
  Xapian.sortable_serialise(value)
@@ -48,6 +48,34 @@ describe XapianDb do
48
48
  xdb.size.should == 1
49
49
  end
50
50
 
51
+ it "closes" do
52
+ xdb = XapianDb.new(:dir => tmp_dir, :create => true)
53
+
54
+ xdb << "Once upon a time"
55
+ xdb.size.should == 0
56
+
57
+ # Make sure we're not using Database#reopen.
58
+ class << xdb.ro
59
+ def reopen
60
+ raise "Shouldn't use reopen when closing"
61
+ end
62
+ end
63
+
64
+ xdb.close
65
+ xdb.size.should == 1
66
+ end
67
+
68
+ it "fails when trying to close in the middle of a transaction" do
69
+ xdb = XapianDb.new(:dir => tmp_dir, :create => true)
70
+
71
+ lambda {
72
+ xdb.transaction do
73
+ xdb << "Once upon a time"
74
+ xdb.close
75
+ end
76
+ }.should raise_error(XapianFu::ConcurrencyError)
77
+ end
78
+
51
79
  it "should return a nice string when inspect is called" do
52
80
  XapianDb.new.inspect.should =~ /XapianDb/
53
81
  end
@@ -519,6 +547,15 @@ describe XapianDb do
519
547
  end
520
548
 
521
549
  xdb.search("john", :query_builder => builder).map(&:id).should == [1]
550
+
551
+ # The query builder should be called before filtering.
552
+ builder = lambda do |q|
553
+ Xapian::Query.new(Xapian::Query::OP_AND_MAYBE, Xapian::Query.new(""), q)
554
+ end
555
+
556
+ results = xdb.search("john", filter: {age: 10}, query_builder: builder)
557
+
558
+ results.map(&:id).should == [1]
522
559
  end
523
560
  end
524
561
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xapian-fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Leach