xapor 0.1.3 → 0.1.4
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.
- data/VERSION +1 -1
- data/lib/xapor/model_integration.rb +26 -32
- data/xapor.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -12,52 +12,46 @@ module Xapor::XapianFuIntegration
|
|
12
12
|
|
13
13
|
module ClassMethods
|
14
14
|
def xapor
|
15
|
-
|
16
|
-
include XapianFu
|
15
|
+
include XapianFu
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def search(query)
|
18
|
+
xapor_db.search(query)
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
@db = XapianDb.new(@config.xapian_fu_db.merge(:overwrite => true))
|
29
|
-
if block_given?
|
30
|
-
yield @db
|
31
|
-
end
|
21
|
+
def reset_index
|
22
|
+
if @db
|
23
|
+
@db.flush
|
24
|
+
@db.ro.close
|
25
|
+
@db.rw.close
|
32
26
|
end
|
33
|
-
|
34
|
-
|
35
|
-
@
|
27
|
+
@db = XapianDb.new(xapor_config.xapian_fu_db.merge(:overwrite => true))
|
28
|
+
if block_given?
|
29
|
+
yield @db
|
36
30
|
end
|
31
|
+
end
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
reset_index do
|
41
|
-
all.each {|o| o.add_to_index}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
@db ||= XapianDb.new(@config.xapian_fu_db.merge(:create => true))
|
45
|
-
end
|
33
|
+
def xapor_config
|
34
|
+
self.class.instance_variable_get(:@config)
|
46
35
|
end
|
36
|
+
|
37
|
+
def xapor_db
|
38
|
+
@db ||= XapianDb.new(xapor_config.xapian_fu_db.merge(:create => true))
|
39
|
+
end
|
40
|
+
|
47
41
|
@config = Xapor::Config.new
|
48
42
|
if block_given?
|
49
43
|
yield @config
|
50
44
|
end
|
45
|
+
|
51
46
|
@config.search_fields.each do |field|
|
52
47
|
class_eval("def self.search_by_#{field}(query)\nself.search(query)\nend")
|
53
48
|
end
|
49
|
+
|
54
50
|
if defined? ActiveRecord && ancestors.includes(ActiveRecord::Base)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
class_eval("all.each {|o| o.add_to_index}")
|
60
|
-
end
|
51
|
+
after_save :add_to_index
|
52
|
+
after_destroy :remove_from_index
|
53
|
+
#in-memory index, needs to be indexed on startup
|
54
|
+
all.each {|o| o.add_to_index} unless @config.directory_config
|
61
55
|
end
|
62
56
|
end
|
63
57
|
end
|
data/xapor.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xapor}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Workman"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-19}
|
13
13
|
s.description = %q{Rails plugin for Xapian search, built on XapianFu and DelayedJob.}
|
14
14
|
s.email = %q{workmad3@hedtek.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Workman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-19 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|