xapian-fu 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +7 -0
- data/lib/xapian_fu/version.rb +1 -1
- data/lib/xapian_fu/xapian_db.rb +13 -1
- data/spec/xapian_db_spec.rb +37 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWQ0ZTRhYmZlNmM5MWVlMWJmMjg1OTViNjYyNTBjYTc4NGMyYjlkMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGEyZjY2MDcxMTRjNWY4NjQ4ZDllNDAyYjY0Y2MzOTBmODg4ZTRmNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGVhZDMyNzM4YzU3MDVkZDQwZDkwZTQ0NTdjZWM3N2U2YzM4Mjk2ZjExNWU3
|
10
|
+
NDA2MjI3N2YyNzEzNGY5NWNhZWYzMjZjYjViYzBjYmJjNTdjZmQ3YTUzOWFj
|
11
|
+
ZWFmMDI2OGFmOWVmNTMyYmE5OTI2MzgwMmNkNzM0NmZlMTZjOTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
data/lib/xapian_fu/version.rb
CHANGED
data/lib/xapian_fu/xapian_db.rb
CHANGED
@@ -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)
|
data/spec/xapian_db_spec.rb
CHANGED
@@ -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
|
|