xapian_db 0.5.12 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/Rakefile +12 -3
- data/lib/xapian_db/adapters/active_record_adapter.rb +3 -1
- data/lib/xapian_db/adapters/datamapper_adapter.rb +3 -1
- data/lib/xapian_db/database.rb +3 -1
- data/lib/xapian_db/index_writers/beanstalk_worker.rb +5 -3
- data/lib/xapian_db/indexer.rb +3 -5
- data/lib/xapian_db/resultset.rb +3 -3
- data/lib/xapian_db/utilities.rb +12 -0
- data/xapian_source/xapian-bindings-1.2.6.tar.gz +0 -0
- data/xapian_source/xapian-core-1.2.6.tar.gz +0 -0
- metadata +6 -32
- data/xapian_source/xapian-bindings-1.2.5.tar.gz +0 -0
- data/xapian_source/xapian-core-1.2.5.tar.gz +0 -0
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
##0.5.13 (June 20th, 2011)
|
2
|
+
|
3
|
+
Fixes:
|
4
|
+
|
5
|
+
- handle attribute objects that return nil from to_s
|
6
|
+
|
7
|
+
Features:
|
8
|
+
|
9
|
+
- updated the xapian source to 1.2.6
|
10
|
+
- xapian source and build artefacts are removed after successful install
|
11
|
+
- added support for namespaced classes
|
12
|
+
|
1
13
|
##0.5.12 (April 28th, 2011)
|
2
14
|
|
3
15
|
Fixes:
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ def system!(cmd)
|
|
9
9
|
system(cmd) or raise
|
10
10
|
end
|
11
11
|
|
12
|
-
ver = '1.2.
|
12
|
+
ver = '1.2.6'
|
13
13
|
source_dir = 'xapian_source'
|
14
14
|
core = "xapian-core-#{ver}"
|
15
15
|
bindings = "xapian-bindings-#{ver}"
|
@@ -38,6 +38,15 @@ task :default do
|
|
38
38
|
system! "make clean all"
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
system! "cp -r #{bindings}/ruby/.libs/_xapian.* lib"
|
42
|
+
system! "cp #{bindings}/ruby/xapian.rb lib"
|
43
|
+
|
44
|
+
system! "rm lib/*.a"
|
45
|
+
system! "rm lib/*.la"
|
46
|
+
system! "rm lib/*.lai"
|
47
|
+
|
48
|
+
system! "rm -R #{bindings}"
|
49
|
+
system! "rm -R #{core}"
|
50
|
+
system! "rm -R #{source_dir}"
|
51
|
+
|
43
52
|
end
|
@@ -66,6 +66,8 @@ module XapianDb
|
|
66
66
|
def add_doc_helper_methods_to(a_module)
|
67
67
|
a_module.instance_eval do
|
68
68
|
|
69
|
+
include XapianDb::Utilities
|
70
|
+
|
69
71
|
# Implement access to the model id
|
70
72
|
define_method :id do
|
71
73
|
return @id unless @d.nil?
|
@@ -79,7 +81,7 @@ module XapianDb
|
|
79
81
|
return @indexed_object unless @indexed_object.nil?
|
80
82
|
# retrieve the class and id from data
|
81
83
|
klass_name, id = data.split("-")
|
82
|
-
klass =
|
84
|
+
klass = constantize klass_name
|
83
85
|
@indexed_object = klass.find(id.to_i)
|
84
86
|
end
|
85
87
|
|
@@ -65,6 +65,8 @@ module XapianDb
|
|
65
65
|
def add_doc_helper_methods_to(a_module)
|
66
66
|
a_module.instance_eval do
|
67
67
|
|
68
|
+
include XapianDb::Utilities
|
69
|
+
|
68
70
|
# Implement access to the model id
|
69
71
|
define_method :id do
|
70
72
|
return @id unless @d.nil?
|
@@ -78,7 +80,7 @@ module XapianDb
|
|
78
80
|
return @indexed_object unless @indexed_object.nil?
|
79
81
|
# retrieve the class and id from data
|
80
82
|
klass_name, id = data.split("-")
|
81
|
-
klass =
|
83
|
+
klass = constantize klass_name
|
82
84
|
@indexed_object = klass.get(id.to_i)
|
83
85
|
end
|
84
86
|
end
|
data/lib/xapian_db/database.rb
CHANGED
@@ -7,6 +7,8 @@ module XapianDb
|
|
7
7
|
# Base class for a Xapian database
|
8
8
|
class Database
|
9
9
|
|
10
|
+
include XapianDb::Utilities
|
11
|
+
|
10
12
|
# A readable xapian database (see http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html)
|
11
13
|
attr_reader :reader
|
12
14
|
|
@@ -104,7 +106,7 @@ module XapianDb
|
|
104
106
|
class_name = match.document.values[0].value
|
105
107
|
# We must add 1 to the collapse_count since collapse_count means
|
106
108
|
# "how many other matches are there?"
|
107
|
-
facets[
|
109
|
+
facets[constantize class_name] = match.collapse_count + 1
|
108
110
|
end
|
109
111
|
facets
|
110
112
|
end
|
@@ -8,20 +8,22 @@ module XapianDb
|
|
8
8
|
# @author Gernot Kogler
|
9
9
|
class BeanstalkWorker
|
10
10
|
|
11
|
+
include XapianDb::Utilities
|
12
|
+
|
11
13
|
def index_task(options)
|
12
|
-
klass =
|
14
|
+
klass = constantize options[:class]
|
13
15
|
obj = klass.respond_to?(:get) ? klass.get(options[:id].to_i) : klass.find(options[:id].to_i)
|
14
16
|
DirectWriter.index obj
|
15
17
|
end
|
16
18
|
|
17
19
|
def unindex_task(options)
|
18
|
-
klass =
|
20
|
+
klass = constantize options[:class]
|
19
21
|
obj = klass.respond_to?(:get) ? klass.get(options[:id].to_i) : klass.find(options[:id].to_i)
|
20
22
|
DirectWriter.unindex obj
|
21
23
|
end
|
22
24
|
|
23
25
|
def reindex_class_task(options)
|
24
|
-
klass =
|
26
|
+
klass = constantize options[:class]
|
25
27
|
DirectWriter.reindex_class klass, :verbose => false
|
26
28
|
end
|
27
29
|
|
data/lib/xapian_db/indexer.rb
CHANGED
@@ -86,11 +86,8 @@ module XapianDb
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
90
89
|
end
|
91
90
|
|
92
|
-
private
|
93
|
-
|
94
91
|
# Get the values to index from an object
|
95
92
|
def get_values_to_index_from(obj)
|
96
93
|
|
@@ -101,8 +98,9 @@ module XapianDb
|
|
101
98
|
# we use the attributes values (works well for active_record and datamapper objects)
|
102
99
|
return obj.attributes.values if obj.respond_to?(:attributes) && obj.attributes.is_a?(Hash)
|
103
100
|
|
104
|
-
# The object is unkown and will be indexed by its to_s method
|
105
|
-
|
101
|
+
# The object is unkown and will be indexed by its to_s method; if to_s retruns nil, we
|
102
|
+
# will not index it
|
103
|
+
obj.to_s.nil? ? [] : [obj]
|
106
104
|
end
|
107
105
|
|
108
106
|
end
|
data/lib/xapian_db/resultset.rb
CHANGED
@@ -16,6 +16,8 @@ module XapianDb
|
|
16
16
|
# @author Gernot Kogler
|
17
17
|
class Resultset < Array
|
18
18
|
|
19
|
+
include XapianDb::Utilities
|
20
|
+
|
19
21
|
# The number of hits
|
20
22
|
# @return [Integer]
|
21
23
|
attr_reader :hits
|
@@ -88,8 +90,6 @@ module XapianDb
|
|
88
90
|
@current_page < @total_pages ? (@current_page + 1): nil
|
89
91
|
end
|
90
92
|
|
91
|
-
private
|
92
|
-
|
93
93
|
# Build an empty resultset
|
94
94
|
def build_empty_resultset
|
95
95
|
@hits = 0
|
@@ -104,7 +104,7 @@ module XapianDb
|
|
104
104
|
# @return [Xapian::Match] the decorated match
|
105
105
|
def decorate(match)
|
106
106
|
klass_name = match.document.values[0].value
|
107
|
-
blueprint = XapianDb::DocumentBlueprint.blueprint_for(
|
107
|
+
blueprint = XapianDb::DocumentBlueprint.blueprint_for(constantize klass_name)
|
108
108
|
match.document.extend blueprint.accessors_module
|
109
109
|
match.document.instance_variable_set :@score, match.percent
|
110
110
|
match
|
data/lib/xapian_db/utilities.rb
CHANGED
@@ -12,5 +12,17 @@ module XapianDb
|
|
12
12
|
string.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
|
13
13
|
end
|
14
14
|
|
15
|
+
# Taken from Rails
|
16
|
+
def constantize(camel_cased_word)
|
17
|
+
names = camel_cased_word.split('::')
|
18
|
+
names.shift if names.empty? || names.first.empty?
|
19
|
+
|
20
|
+
constant = Object
|
21
|
+
names.each do |name|
|
22
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
23
|
+
end
|
24
|
+
constant
|
25
|
+
end
|
26
|
+
|
15
27
|
end
|
16
28
|
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xapian_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 5
|
8
|
-
- 12
|
9
|
-
version: 0.5.12
|
4
|
+
prerelease:
|
5
|
+
version: 0.5.13
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Gernot Kogler
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-06-20 00:00:00 +02:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
- 10
|
32
24
|
version: 1.0.10
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -40,10 +32,6 @@ dependencies:
|
|
40
32
|
requirements:
|
41
33
|
- - ">="
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 2
|
45
|
-
- 3
|
46
|
-
- 1
|
47
35
|
version: 2.3.1
|
48
36
|
type: :development
|
49
37
|
version_requirements: *id002
|
@@ -55,10 +43,6 @@ dependencies:
|
|
55
43
|
requirements:
|
56
44
|
- - ">="
|
57
45
|
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
- 3
|
61
|
-
- 7
|
62
46
|
version: 0.3.7
|
63
47
|
type: :development
|
64
48
|
version_requirements: *id003
|
@@ -70,10 +54,6 @@ dependencies:
|
|
70
54
|
requirements:
|
71
55
|
- - ">="
|
72
56
|
- !ruby/object:Gem::Version
|
73
|
-
segments:
|
74
|
-
- 1
|
75
|
-
- 1
|
76
|
-
- 0
|
77
57
|
version: 1.1.0
|
78
58
|
type: :development
|
79
59
|
version_requirements: *id004
|
@@ -124,8 +104,8 @@ files:
|
|
124
104
|
- lib/xapian_db/utilities.rb
|
125
105
|
- lib/xapian_db.rb
|
126
106
|
- tasks/beanstalk_worker.rake
|
127
|
-
- xapian_source/xapian-bindings-1.2.
|
128
|
-
- xapian_source/xapian-core-1.2.
|
107
|
+
- xapian_source/xapian-bindings-1.2.6.tar.gz
|
108
|
+
- xapian_source/xapian-core-1.2.6.tar.gz
|
129
109
|
- LICENSE
|
130
110
|
- README.rdoc
|
131
111
|
- CHANGELOG.md
|
@@ -149,23 +129,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
129
|
requirements:
|
150
130
|
- - ">="
|
151
131
|
- !ruby/object:Gem::Version
|
152
|
-
segments:
|
153
|
-
- 0
|
154
132
|
version: "0"
|
155
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
134
|
none: false
|
157
135
|
requirements:
|
158
136
|
- - ">="
|
159
137
|
- !ruby/object:Gem::Version
|
160
|
-
segments:
|
161
|
-
- 1
|
162
|
-
- 3
|
163
|
-
- 6
|
164
138
|
version: 1.3.6
|
165
139
|
requirements: []
|
166
140
|
|
167
141
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.
|
142
|
+
rubygems_version: 1.6.2
|
169
143
|
signing_key:
|
170
144
|
specification_version: 3
|
171
145
|
summary: Ruby library to use a Xapian db as a key/value store with high performance fulltext search
|
Binary file
|
Binary file
|