xapian_db 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/README.rdoc +13 -1
- data/Rakefile +7 -1
- data/lib/type_codec.rb +26 -0
- data/lib/xapian_db/adapters/active_record_adapter.rb +5 -3
- data/lib/xapian_db/document_blueprint.rb +13 -0
- data/tasks/spec.rake +9 -0
- metadata +31 -19
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
##1.2.4 (March 6th, 2012)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- Codec for DateTime objects added
|
6
|
+
- autoindex option for blueprints added
|
7
|
+
|
8
|
+
Fixes:
|
9
|
+
|
10
|
+
- the ActiveRecord after_commit hook must not reindex the object if it is a destroy action
|
11
|
+
|
1
12
|
##1.2.3 (December 12th, 2011)
|
2
13
|
|
3
14
|
Changes:
|
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= XapianDb
|
2
2
|
|
3
|
+
{<img src="https://secure.travis-ci.org/garaio/xapian_db.png" />}[http://travis-ci.org/garaio/xapian_db]
|
4
|
+
|
3
5
|
== Important Information
|
4
6
|
|
5
7
|
If you upgrade from an earlier version of xapian_db to 1.1, you MUST rebuild your entire index (XapianDb.rebuild_xapian_index)!
|
@@ -128,12 +130,13 @@ You may add a filter expression to exclude objects from the index. This is handy
|
|
128
130
|
blueprint.ignore_if {active == false}
|
129
131
|
end
|
130
132
|
|
131
|
-
You can add a type information to an attribute. As of now the special types :string, :date and :number are supported (and required for range queries):
|
133
|
+
You can add a type information to an attribute. As of now the special types :string, :date, :date_time and :number are supported (and required for range queries):
|
132
134
|
|
133
135
|
XapianDb::DocumentBlueprint.setup(:Person) do |blueprint|
|
134
136
|
blueprint.attribute :age, :as => :number
|
135
137
|
blueprint.attribute :date_of_birth, :as => :date
|
136
138
|
blueprint.attribute :name, :as => :string
|
139
|
+
blueprint.attribute :updated_at, :as => :date_time
|
137
140
|
end
|
138
141
|
|
139
142
|
You can override the global adapter configuration in a specific blueprint. Let's say you use ActiveRecord, but you have
|
@@ -164,6 +167,15 @@ are ordered by relevance and - within the same relevance - by the natural sort o
|
|
164
167
|
end
|
165
168
|
end
|
166
169
|
|
170
|
+
If you want to manage the (re)indexing of your objects on your own, turn off autoindexing in your blueprint:
|
171
|
+
|
172
|
+
XapianDb::DocumentBlueprint.setup(:Person) do |blueprint|
|
173
|
+
blueprint.autoindex false
|
174
|
+
end
|
175
|
+
|
176
|
+
This will turn off the auto-reindexing for any object of the configured class. Use XapianDb.reindex(object) to trigger the reindexing logic in your code. Please note that destroying an object will always remove it from the xapian index.
|
177
|
+
|
178
|
+
|
167
179
|
Place these configurations either into the corresponding class or - I prefer to have the index configurations outside
|
168
180
|
the models - into the file config/xapian_blueprints.rb.
|
169
181
|
|
data/Rakefile
CHANGED
data/lib/type_codec.rb
CHANGED
@@ -96,6 +96,32 @@ module XapianDb
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
class DateTimeCodec
|
100
|
+
|
101
|
+
# Encode a datetime to a string in the format 'yyyymmdd h:m:s+l'
|
102
|
+
# @param [DateTime] datetime a datetime object to encode
|
103
|
+
# @return [String] the encoded datetime
|
104
|
+
def self.encode(datetime)
|
105
|
+
return '' unless datetime
|
106
|
+
begin
|
107
|
+
datetime.strftime "%Y%m%d %H:%M:%S+%L"
|
108
|
+
rescue NoMethodError
|
109
|
+
raise ArgumentError.new "#{datetime} was expected to be a datetime"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Decode a string to a datetime
|
114
|
+
# @param [String] datetime_as_string a string representing a datetime
|
115
|
+
# @return [DateTime] the parsed datetime
|
116
|
+
def self.decode(datetime_as_string)
|
117
|
+
begin
|
118
|
+
DateTime.parse datetime_as_string
|
119
|
+
rescue ArgumentError
|
120
|
+
raise ArgumentError.new "'#{datetime_as_string}' cannot be converted to a datetime"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
99
125
|
class NumberCodec
|
100
126
|
|
101
127
|
# Encode a number to a sortable string
|
@@ -46,9 +46,11 @@ module XapianDb
|
|
46
46
|
end
|
47
47
|
|
48
48
|
klass.class_eval do
|
49
|
-
# add the after commit logic
|
50
|
-
|
51
|
-
|
49
|
+
# add the after commit logic, unless the blueprint has autoindexing turned off
|
50
|
+
if XapianDb::DocumentBlueprint.blueprint_for(klass.name).autoindex?
|
51
|
+
after_commit do
|
52
|
+
XapianDb.reindex(self) unless self.destroyed?
|
53
|
+
end
|
52
54
|
end
|
53
55
|
|
54
56
|
# add the after destroy logic
|
@@ -248,6 +248,7 @@ module XapianDb
|
|
248
248
|
@indexed_methods_hash = {}
|
249
249
|
@type_map = {}
|
250
250
|
@_natural_sort_order = :id
|
251
|
+
@autoindex = true
|
251
252
|
end
|
252
253
|
|
253
254
|
# Set the adapter
|
@@ -265,6 +266,18 @@ module XapianDb
|
|
265
266
|
@_adapter || XapianDb::Config.adapter || XapianDb::Adapters::GenericAdapter
|
266
267
|
end
|
267
268
|
|
269
|
+
# Should objects for this blueprint be automatically reindexed?
|
270
|
+
# @param [Boolean] boolean Yes or no?
|
271
|
+
def autoindex(boolean)
|
272
|
+
@autoindex = boolean
|
273
|
+
end
|
274
|
+
|
275
|
+
# Get the autoindex value
|
276
|
+
# @return [Boolean] The autoindex value
|
277
|
+
def autoindex?
|
278
|
+
@autoindex
|
279
|
+
end
|
280
|
+
|
268
281
|
# Add an attribute to the blueprint. Attributes will be stored in the xapian documents an can be
|
269
282
|
# accessed from a search result.
|
270
283
|
# @param [String] name The name of the method that delivers the value for the attribute
|
data/tasks/spec.rake
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xapian_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: daemons
|
16
|
-
requirement: &
|
16
|
+
requirement: &70101802013500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.10
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70101802013500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard
|
27
|
-
requirement: &
|
27
|
+
requirement: &70101802012640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70101802012640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70101802011100 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.3.1
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70101802011100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: simplecov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70101802025080 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.3.7
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70101802025080
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: beanstalk-client
|
60
|
-
requirement: &
|
60
|
+
requirement: &70101802021980 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.1.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70101802021980
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &70101802020280 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70101802020280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: progressbar
|
82
|
-
requirement: &
|
82
|
+
requirement: &70101802019120 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70101802019120
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: resque
|
93
|
-
requirement: &
|
93
|
+
requirement: &70101802032660 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,18 @@ dependencies:
|
|
98
98
|
version: 1.19.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70101802032660
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: xapian-ruby
|
104
|
+
requirement: &70101802028880 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.7.1
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70101802028880
|
102
113
|
description: XapianDb is a ruby gem that combines features of nosql databases and
|
103
114
|
fulltext indexing. It is based on Xapian, an efficient and powerful indexing library
|
104
115
|
email: gernot.kogler (at) garaio (dot) com
|
@@ -148,6 +159,7 @@ files:
|
|
148
159
|
- lib/xapian_db/stopwords/update_stopwords.rb
|
149
160
|
- lib/xapian_db/utilities.rb
|
150
161
|
- lib/xapian_db.rb
|
162
|
+
- tasks/spec.rake
|
151
163
|
- tasks/xapian_rebuild_index.rake
|
152
164
|
- LICENSE
|
153
165
|
- README.rdoc
|
@@ -179,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
191
|
version: 1.3.6
|
180
192
|
requirements: []
|
181
193
|
rubyforge_project:
|
182
|
-
rubygems_version: 1.8.
|
194
|
+
rubygems_version: 1.8.15
|
183
195
|
signing_key:
|
184
196
|
specification_version: 3
|
185
197
|
summary: Ruby library to use a Xapian db as a key/value store with high performance
|