xapit 0.2.3 → 0.2.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/CHANGELOG +5 -0
- data/Rakefile +1 -1
- data/lib/xapit/adapters/abstract_adapter.rb +2 -1
- data/lib/xapit/adapters/active_record_adapter.rb +2 -2
- data/lib/xapit/index_blueprint.rb +12 -5
- data/spec/xapit/adapters/active_record_adapter_spec.rb +2 -2
- data/spec/xapit/index_blueprint_spec.rb +18 -6
- data/spec/xapit_member.rb +4 -0
- data/xapit.gemspec +2 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('xapit', '0.2.
|
5
|
+
Echoe.new('xapit', '0.2.4') do |p|
|
6
6
|
p.summary = "Ruby library for interacting with Xapian, a full text search engine."
|
7
7
|
p.description = "Ruby library for interacting with Xapian, a full text search engine."
|
8
8
|
p.url = "http://github.com/ryanb/xapit"
|
@@ -93,17 +93,24 @@ module Xapit
|
|
93
93
|
index + facets.size + sortable_attributes.size
|
94
94
|
end
|
95
95
|
|
96
|
-
# Add a single record to the index
|
96
|
+
# Add a single record to the index if it matches the xapit options.
|
97
97
|
def create_record(member_id)
|
98
|
-
@
|
98
|
+
member = @member_class.xapit_adapter.find_single(member_id, *@args)
|
99
|
+
@indexer.add_member(member) if member
|
99
100
|
end
|
100
101
|
|
101
|
-
# Update a single record in the index
|
102
|
+
# Update a single record in the index. If the record does not match the xapit
|
103
|
+
# conditions then it is removed from the index instead.
|
102
104
|
def update_record(member_id)
|
103
|
-
@
|
105
|
+
member = @member_class.xapit_adapter.find_single(member_id, *@args)
|
106
|
+
if member
|
107
|
+
@indexer.update_member(member)
|
108
|
+
else
|
109
|
+
destroy_record(member_id)
|
110
|
+
end
|
104
111
|
end
|
105
112
|
|
106
|
-
# Remove a single record from the index
|
113
|
+
# Remove a single record from the index.
|
107
114
|
def destroy_record(member_id)
|
108
115
|
Xapit::Config.writable_database.delete_document("Q#{@member_class}-#{member_id}")
|
109
116
|
end
|
@@ -10,9 +10,9 @@ describe Xapit::ActiveRecordAdapter do
|
|
10
10
|
|
11
11
|
it "should pass find_single to find method to target" do
|
12
12
|
target = Object.new
|
13
|
-
mock(target).
|
13
|
+
mock(target).find_by_id(1, :conditions => "foo") { :record }
|
14
14
|
adapter = Xapit::ActiveRecordAdapter.new(target)
|
15
|
-
adapter.find_single(1).should == :record
|
15
|
+
adapter.find_single(1, :conditions => "foo").should == :record
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should pass find_multiple to find method to target" do
|
@@ -81,20 +81,32 @@ describe Xapit::IndexBlueprint do
|
|
81
81
|
XapitMember.search("Bad Record").should == []
|
82
82
|
end
|
83
83
|
|
84
|
-
it "should
|
85
|
-
member = XapitMember.new(:name => "
|
84
|
+
it "should update a record in the index" do
|
85
|
+
member = XapitMember.new(:name => "New Record!")
|
86
86
|
@index.text :name
|
87
87
|
@index.index_all
|
88
|
-
|
89
|
-
|
88
|
+
member.update_attribute(:name, "Changed Record!")
|
89
|
+
@index.update_record(member.id)
|
90
|
+
XapitMember.search("Changed Record").should == [member]
|
90
91
|
end
|
91
92
|
|
92
|
-
it "should
|
93
|
+
it "should not create record index if member isn't found" do
|
94
|
+
Xapit::Config.writable_database # make sure the database is built
|
95
|
+
member = XapitMember.new(:name => "New Record!")
|
96
|
+
stub(XapitMember).find { nil }
|
97
|
+
@index.text :name
|
98
|
+
@index.create_record(member.id)
|
99
|
+
XapitMember.search("New Record").should be_empty
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should remove record from index when updating a member which doesn't exist" do
|
93
103
|
member = XapitMember.new(:name => "New Record!")
|
94
104
|
@index.text :name
|
95
105
|
@index.index_all
|
106
|
+
stub(XapitMember).find { nil }
|
96
107
|
member.update_attribute(:name, "Changed Record!")
|
97
108
|
@index.update_record(member.id)
|
98
|
-
XapitMember.search("
|
109
|
+
XapitMember.search("New Record").should be_empty
|
110
|
+
XapitMember.search("Changed Record").should be_empty
|
99
111
|
end
|
100
112
|
end
|
data/spec/xapit_member.rb
CHANGED
data/xapit.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{xapit}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ryan Bates"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-23}
|
10
10
|
s.description = %q{Ruby library for interacting with Xapian, a full text search engine.}
|
11
11
|
s.email = %q{ryan (at) railscasts (dot) com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/xapit/adapters/abstract_adapter.rb", "lib/xapit/adapters/active_record_adapter.rb", "lib/xapit/adapters/data_mapper_adapter.rb", "lib/xapit/collection.rb", "lib/xapit/config.rb", "lib/xapit/facet.rb", "lib/xapit/facet_blueprint.rb", "lib/xapit/facet_option.rb", "lib/xapit/index_blueprint.rb", "lib/xapit/indexers/abstract_indexer.rb", "lib/xapit/indexers/classic_indexer.rb", "lib/xapit/indexers/simple_indexer.rb", "lib/xapit/membership.rb", "lib/xapit/query.rb", "lib/xapit/query_parsers/abstract_query_parser.rb", "lib/xapit/query_parsers/classic_query_parser.rb", "lib/xapit/query_parsers/simple_query_parser.rb", "lib/xapit/rake_tasks.rb", "lib/xapit.rb", "LICENSE", "README.rdoc", "tasks/spec.rb", "tasks/xapit.rake", "TODO"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xapit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|