sunspot_submodel_index 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/MIT_LICENSE +20 -0
- data/README.rdoc +68 -0
- data/Rakefile +9 -0
- data/lib/sunspot_submodel_index/submodel_index.rb +110 -0
- data/lib/sunspot_submodel_index/version.rb +3 -0
- data/lib/sunspot_submodel_index.rb +9 -0
- data/spec/lib/sunspot_submodel_test_model.rb +21 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/submodel_index_spec.rb +210 -0
- data/sunspot_submodel_index.gemspec +26 -0
- metadata +139 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT_LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Finetooth Enterprises, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
= Sunspot Submodel Index
|
2
|
+
|
3
|
+
This gem ties into the Rails model lifecycle to add support for calling Sunspot index on another model when data it relies on for its index is from an associated model.
|
4
|
+
|
5
|
+
== Example
|
6
|
+
Lets say you have two ActiveRecord models. A Person model and a Company model. As part of your Sunspot indexing for a Person you include the Company name associated with that Person. When the Company name changes you need to be able to automatically reindex the Person model. Or if the Company is destroyed you need to be able to reindex the Person with a blank Company name. This can be easily done with the sunspot_submodel_index declaration in Company to tell it to notify the Person model.
|
7
|
+
|
8
|
+
class Person < ActiveRecord::Base
|
9
|
+
belongs_to :company
|
10
|
+
|
11
|
+
searchable do
|
12
|
+
textgen :contact_name, :using => :name, :stored => true
|
13
|
+
textgen(:contact_company_name, :stored => true) { self.company_id ? company.name : '' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Company < ActiveRecord::Base
|
18
|
+
has_many :people
|
19
|
+
sunspot_submodel_index :parent => :people, :included_attributes => [:name]
|
20
|
+
end
|
21
|
+
|
22
|
+
Notice that in this example people is a has_many association. That means all people associated with the company will be reindexed.
|
23
|
+
|
24
|
+
== Usage
|
25
|
+
|
26
|
+
This gem ties into the Rails ActiveRecord lifecycle and ties into save and destroy events. You add the sunspot_submodel_index declaration to the model that needs to notify another model when it is saved or destroyed. The simplest declaration is:
|
27
|
+
|
28
|
+
sunspot_submodel_index :parent => :some_parent
|
29
|
+
|
30
|
+
In this example the class instance must respond to some_parent. The parent object will then need to respond to solr_index.
|
31
|
+
|
32
|
+
=== Enumerable parents
|
33
|
+
|
34
|
+
If the parent is an Enumerable type then it will be iterated over and each member will be reindexed.
|
35
|
+
|
36
|
+
=== Included and Ignored Attributes
|
37
|
+
|
38
|
+
You often will only need to notify the parent model if some subset of the attributes on the object have changed. You can declare attributes to include or ignore. For included attributes if any attribute in the include set has changed on the object the parent will get indexed. For ignored attributes the parent will only get indexed if attributes other then those in the ignore set were changed. If you declare both included and ignored attribute options only the included option is used.
|
39
|
+
|
40
|
+
Examples
|
41
|
+
|
42
|
+
sunspot_submodel_index :parent => :people, :included_attributes => [:name]
|
43
|
+
|
44
|
+
sunspot_submodel_index :parent => :people, :ignore_attributes => [:industry, :address]
|
45
|
+
|
46
|
+
=== If Option
|
47
|
+
|
48
|
+
There is also the option to call a Proc before parent is indexed. The Proc is passed the instance of the object. If the Proc returns false the parent is not indexed.
|
49
|
+
|
50
|
+
Example
|
51
|
+
|
52
|
+
sunspot_submodel_index :parent => :people, :if => Proc.new {|obj| !obj.subsidiary? }
|
53
|
+
|
54
|
+
=== Force association reload
|
55
|
+
|
56
|
+
Sometimes you will want to force a reload on the association of the parent model before you call it to reindex. You can set this option with force_association_reload. If this option is set parent will be called with the parameter true before solr_index is called.
|
57
|
+
|
58
|
+
Example
|
59
|
+
|
60
|
+
sunspot_submodel_index :parent => :people, :force_association_reload => true
|
61
|
+
|
62
|
+
== Dependencies
|
63
|
+
1. Sunspot
|
64
|
+
2. ActiveRecord 2+
|
65
|
+
|
66
|
+
== License
|
67
|
+
|
68
|
+
Sunspot Submodel Index is distributed under the MIT License, copyright (c) 2011 Finetooth Enterprises, Inc.
|
data/Rakefile
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
module Sunspot
|
2
|
+
module SubmodelIndex
|
3
|
+
|
4
|
+
def self.included(klass)
|
5
|
+
klass.class_eval do
|
6
|
+
|
7
|
+
# Solr Index a parent model when this model is saved or destroyed.
|
8
|
+
#
|
9
|
+
# ==== Options (+options+)
|
10
|
+
#
|
11
|
+
# :parent<Symbol>::
|
12
|
+
# Method to call to access the parent to Solr index.
|
13
|
+
# :if<Proc>::
|
14
|
+
# A Proc that is called before the parent index and is passed an instance of the object.
|
15
|
+
# Will block Solr index of the parent if false is returned.
|
16
|
+
# :force_association_reload<Boolean>::
|
17
|
+
# Force a reload on the parent association for Solr index is called on the parent.
|
18
|
+
# :include_attributes<Array>::
|
19
|
+
# Define only those attributes whose change should trigger a reindex of the parent.
|
20
|
+
# :ignore_attributes<Array>::
|
21
|
+
# Define attributes, that should not trigger a reindex of the parent.
|
22
|
+
#
|
23
|
+
# ==== Example
|
24
|
+
#
|
25
|
+
# class Company < ActiveRecord::Base
|
26
|
+
# has_many :people
|
27
|
+
# sunspot_submodel_index :parent => :people, :included_attributes => [:name]
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
def self.sunspot_submodel_index(options = {})
|
31
|
+
include Sunspot::SubmodelIndex::InstanceMethods
|
32
|
+
extend Sunspot::SubmodelIndex::ClassMethods
|
33
|
+
class_inheritable_hash :_sunspot_submodel_options
|
34
|
+
|
35
|
+
options[:parent] = options[:parent].to_sym
|
36
|
+
options[:included_attributes] = false if options[:included_attributes].blank? #set to false if empty sent
|
37
|
+
options[:ignored_attributes] = false if options[:ignored_attributes].blank? #set to false if empty sent
|
38
|
+
options[:force_association_reload] = false if options[:force_association_reload].blank? #set to false if empty sent
|
39
|
+
|
40
|
+
self._sunspot_submodel_options = options
|
41
|
+
|
42
|
+
#add call backs
|
43
|
+
before_save :mark_for_parent_solr_index
|
44
|
+
after_save :parent_solr_index
|
45
|
+
after_destroy :parent_solr_index_on_destroy
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module InstanceMethods
|
53
|
+
|
54
|
+
def call_parent_solr_index
|
55
|
+
if self.respond_to?(self._sunspot_submodel_options[:parent]) && !self.send(self._sunspot_submodel_options[:parent]).nil?
|
56
|
+
self.send(self._sunspot_submodel_options[:parent],true) if self._sunspot_submodel_options[:force_association_reload]
|
57
|
+
if self.send(self._sunspot_submodel_options[:parent]).is_a?(Enumerable)
|
58
|
+
self.send(self._sunspot_submodel_options[:parent]).each {|item| item.solr_index }
|
59
|
+
else
|
60
|
+
self.send(self._sunspot_submodel_options[:parent]).solr_index
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def check_parent_solr_if_statement
|
66
|
+
if self._sunspot_submodel_options[:if] && self._sunspot_submodel_options[:if].instance_of?(Proc)
|
67
|
+
self._sunspot_submodel_options[:if].call(self)
|
68
|
+
else
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
#to run before a save to see if this is a new record, or if fields I care about changed.
|
74
|
+
def mark_for_parent_solr_index
|
75
|
+
#only mark for index if the record is new, or if fields changed that I care about
|
76
|
+
#check the if proc first
|
77
|
+
return unless check_parent_solr_if_statement
|
78
|
+
if self._sunspot_submodel_options[:included_attributes]
|
79
|
+
fields_changed = !(self.changed.map {|k| k.to_sym} & self._sunspot_submodel_options[:included_attributes]).empty?
|
80
|
+
elsif self._sunspot_submodel_options[:ignored_attributes]
|
81
|
+
fields_changed = !(self.changed.map {|k| k.to_sym} - self._sunspot_submodel_options[:ignored_attributes]).empty?
|
82
|
+
else
|
83
|
+
fields_changed = true
|
84
|
+
end
|
85
|
+
if new_record? || fields_changed
|
86
|
+
@marked_for_parent_solr_indexing = true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
#call reindex if I need too
|
91
|
+
def parent_solr_index
|
92
|
+
if @marked_for_parent_solr_indexing
|
93
|
+
call_parent_solr_index
|
94
|
+
remove_instance_variable(:@marked_for_parent_solr_indexing)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
#always call reindex on destroy
|
99
|
+
def parent_solr_index_on_destroy
|
100
|
+
call_parent_solr_index
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
module ClassMethods
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class SunspotSubmodelTestModel < ActiveRecord::Base
|
2
|
+
|
3
|
+
sunspot_submodel_index :parent => :parent_model
|
4
|
+
|
5
|
+
def self.create_table
|
6
|
+
connection.create_table :sunspot_submodel_test_models do |t|
|
7
|
+
t.integer :parent_id
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def title
|
12
|
+
"Fake AR"
|
13
|
+
end
|
14
|
+
|
15
|
+
def parent_model
|
16
|
+
return nil
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# require 'uri'
|
4
|
+
# require 'fileutils'
|
5
|
+
# require 'net/http'
|
6
|
+
require 'active_record'
|
7
|
+
|
8
|
+
require File.expand_path('../../lib/sunspot_submodel_index', __FILE__)
|
9
|
+
|
10
|
+
#include the submodel to test
|
11
|
+
require File.expand_path('../lib/sunspot_submodel_test_model', __FILE__)
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :mocha
|
15
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
def stub_object_no_index(new_record = false)
|
4
|
+
obj = SunspotSubmodelTestModel.new
|
5
|
+
obj.class._sunspot_submodel_options[:included_attributes] = false
|
6
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = false
|
7
|
+
obj.stubs(:new_record?).returns(new_record)
|
8
|
+
parent_mock = mock()
|
9
|
+
parent_mock.expects(:solr_index).never
|
10
|
+
obj.stubs(:parent_model).returns(parent_mock)
|
11
|
+
obj
|
12
|
+
end
|
13
|
+
|
14
|
+
def stub_object_array_parents(number_of_parents = 2, new_record = false, should_index = true)
|
15
|
+
obj = SunspotSubmodelTestModel.new
|
16
|
+
obj.class._sunspot_submodel_options[:included_attributes] = false
|
17
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = false
|
18
|
+
obj.stubs(:new_record?).returns(new_record)
|
19
|
+
parents = []
|
20
|
+
number_of_parents.times do |i|
|
21
|
+
parent_mock = mock()
|
22
|
+
should_index ? parent_mock.expects(:solr_index) : parent_mock.expects(:solr_index).never
|
23
|
+
parents << parent_mock
|
24
|
+
end
|
25
|
+
obj.stubs(:parent_model).returns(parents)
|
26
|
+
obj
|
27
|
+
end
|
28
|
+
|
29
|
+
def stub_object_will_index(new_record = false)
|
30
|
+
obj = SunspotSubmodelTestModel.new
|
31
|
+
obj.class._sunspot_submodel_options[:included_attributes] = false
|
32
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = false
|
33
|
+
obj.stubs(:new_record?).returns(new_record)
|
34
|
+
parent_mock = mock()
|
35
|
+
parent_mock.expects(:solr_index)
|
36
|
+
obj.stubs(:parent_model).returns(parent_mock)
|
37
|
+
obj
|
38
|
+
end
|
39
|
+
|
40
|
+
describe Sunspot::SubmodelIndex do
|
41
|
+
|
42
|
+
before :all do
|
43
|
+
ActiveRecord::Base.establish_connection("adapter" => "sqlite3", "database" => ":memory:")
|
44
|
+
SunspotSubmodelTestModel.create_table
|
45
|
+
end
|
46
|
+
|
47
|
+
after :all do
|
48
|
+
ActiveRecord::Base.connection.disconnect!
|
49
|
+
end
|
50
|
+
|
51
|
+
context "new record" do
|
52
|
+
it "should call solr_index on parent_model on save" do
|
53
|
+
obj = stub_object_will_index(true)
|
54
|
+
obj.save
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
context "for existing records" do
|
60
|
+
it "should reindex if no attributes options are set on save if no attributes are included or excluded" do
|
61
|
+
obj = stub_object_will_index
|
62
|
+
obj.save
|
63
|
+
end
|
64
|
+
context "when something changes and an if option is set" do
|
65
|
+
it "should not reindex if the if proc returns false" do
|
66
|
+
obj = stub_object_no_index
|
67
|
+
obj.expects(:check_parent_solr_if_statement).returns false
|
68
|
+
obj.save
|
69
|
+
end
|
70
|
+
it "should reindex if the if proc returns true" do
|
71
|
+
obj = stub_object_will_index
|
72
|
+
obj.expects(:check_parent_solr_if_statement).returns true
|
73
|
+
obj.save
|
74
|
+
end
|
75
|
+
end
|
76
|
+
context "included_attributes" do
|
77
|
+
it "should not index if no included attribute is changed" do
|
78
|
+
obj = stub_object_no_index
|
79
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test, :test2]
|
80
|
+
obj.stubs(:changed).returns ["test3"]
|
81
|
+
obj.save
|
82
|
+
end
|
83
|
+
it "should index if any included attribute is changed" do
|
84
|
+
obj = stub_object_will_index
|
85
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test, :test2]
|
86
|
+
obj.stubs(:changed).returns ["test2"]
|
87
|
+
obj.save
|
88
|
+
end
|
89
|
+
it "should not index if no changes are made" do
|
90
|
+
obj = stub_object_no_index
|
91
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test, :test2]
|
92
|
+
obj.stubs(:changed).returns []
|
93
|
+
obj.save
|
94
|
+
end
|
95
|
+
end
|
96
|
+
context "ignored attributes" do
|
97
|
+
it "should not index if only ignored attributes are changed" do
|
98
|
+
obj = stub_object_no_index
|
99
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = [:test, :test2]
|
100
|
+
obj.stubs(:changed).returns ["test2","test"]
|
101
|
+
obj.save
|
102
|
+
end
|
103
|
+
it "should not index if no attributes are changed" do
|
104
|
+
obj = stub_object_no_index
|
105
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = [:test, :test2]
|
106
|
+
obj.stubs(:changed).returns []
|
107
|
+
obj.save
|
108
|
+
end
|
109
|
+
it "should index if a non ignored attribute is changed" do
|
110
|
+
obj = stub_object_will_index
|
111
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = [:test, :test2]
|
112
|
+
obj.stubs(:changed).returns ["test3"]
|
113
|
+
obj.save
|
114
|
+
end
|
115
|
+
it "should use included attributes if both are set" do
|
116
|
+
obj = stub_object_will_index
|
117
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test]
|
118
|
+
obj.class._sunspot_submodel_options[:ignored_attributes] = [:test, :test2]
|
119
|
+
obj.stubs(:changed).returns ["test"]
|
120
|
+
obj.save
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "parents that are multiple objects" do
|
126
|
+
#Example is a has_many or has_and_belongs_to_many
|
127
|
+
it "should index several parents if they are an array" do
|
128
|
+
obj = stub_object_array_parents(2,false,true)
|
129
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test]
|
130
|
+
obj.stubs(:changed).returns ["test"]
|
131
|
+
obj.save
|
132
|
+
end
|
133
|
+
it "should not fail if the array is empty" do
|
134
|
+
obj = stub_object_array_parents(0,false,true)
|
135
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test]
|
136
|
+
obj.stubs(:changed).returns ["test"]
|
137
|
+
obj.save
|
138
|
+
end
|
139
|
+
it "should respect the if statement even if the parents are an array" do
|
140
|
+
obj = stub_object_array_parents(2,false,false)
|
141
|
+
obj.class._sunspot_submodel_options[:included_attributes] = [:test]
|
142
|
+
obj.stubs(:changed).returns ["test"]
|
143
|
+
obj.class._sunspot_submodel_options[:if] = Proc.new {|t| false }
|
144
|
+
obj.save
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
context "on destroy" do
|
150
|
+
it "should call parents index" do
|
151
|
+
obj = stub_object_will_index
|
152
|
+
obj.destroy
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
context "force association reload" do
|
158
|
+
it "should call parent with true with option is set" do
|
159
|
+
obj = SunspotSubmodelTestModel.new
|
160
|
+
obj.class._sunspot_submodel_options[:force_association_reload] = true
|
161
|
+
parent_mock = mock()
|
162
|
+
parent_mock.expects(:solr_index)
|
163
|
+
obj.expects(:parent_model).with().returns(parent_mock)
|
164
|
+
obj.expects(:parent_model).with(true).returns(parent_mock)
|
165
|
+
obj.expects(:parent_model).with().returns(parent_mock)
|
166
|
+
obj.expects(:parent_model).with().returns(parent_mock)
|
167
|
+
obj.call_parent_solr_index
|
168
|
+
end
|
169
|
+
it "should not call parent with true if option is not set" do
|
170
|
+
obj = SunspotSubmodelTestModel.new
|
171
|
+
obj.class._sunspot_submodel_options[:force_association_reload] = false
|
172
|
+
parent_mock = mock()
|
173
|
+
parent_mock.expects(:solr_index)
|
174
|
+
obj.expects(:parent_model).with().returns(parent_mock).times(3)
|
175
|
+
obj.call_parent_solr_index
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
context "check_parent_solr_if_statement" do
|
181
|
+
before do
|
182
|
+
@obj = SunspotSubmodelTestModel.new
|
183
|
+
@obj.class._sunspot_submodel_options[:if] = nil
|
184
|
+
end
|
185
|
+
after do
|
186
|
+
@obj.class._sunspot_submodel_options[:if] = nil
|
187
|
+
end
|
188
|
+
it "should return true if no option is set" do
|
189
|
+
@obj.send(:check_parent_solr_if_statement).should == true
|
190
|
+
end
|
191
|
+
it "should return true if the if option is not a proc" do
|
192
|
+
@obj.class._sunspot_submodel_options[:if] = "not a proc"
|
193
|
+
@obj.send(:check_parent_solr_if_statement).should == true
|
194
|
+
end
|
195
|
+
it "should return true if the if proc returns true" do
|
196
|
+
@obj.class._sunspot_submodel_options[:if] = Proc.new {|t| true }
|
197
|
+
@obj.send(:check_parent_solr_if_statement).should == true
|
198
|
+
end
|
199
|
+
it "should return false if the if proc returns false" do
|
200
|
+
@obj.class._sunspot_submodel_options[:if] = Proc.new {|t| false }
|
201
|
+
@obj.send(:check_parent_solr_if_statement).should == false
|
202
|
+
end
|
203
|
+
it "should pass in the instance of the model" do
|
204
|
+
@obj.class._sunspot_submodel_options[:if] = Proc.new {|t| t.proc_test }
|
205
|
+
@obj.stubs(:proc_test).returns(false)
|
206
|
+
@obj.send(:check_parent_solr_if_statement).should == false
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sunspot_submodel_index/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sunspot_submodel_index"
|
7
|
+
s.version = SunspotSubmodelIndex::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Scott Diedrick"]
|
10
|
+
s.email = ["swalterd@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/mumboe/sunspot_submodel_index"
|
12
|
+
s.summary = %q{Support for Sunspot indexing of Rails models when an associated model is updated or deleted.}
|
13
|
+
s.description = %q{This gem ties into the Rails model lifecycle to add support for calling Sunspot index on another model when data it relies on for its index is from an associated model.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "sunspot_submodel_index"
|
16
|
+
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency("sqlite3", [">= 0"])
|
19
|
+
s.add_development_dependency("activerecord", [">= 2.2"])
|
20
|
+
s.add_development_dependency("mocha", [">= 0.9.5"])
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sunspot_submodel_index
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Scott Diedrick
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-16 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sqlite3
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: activerecord
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 7
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 2
|
61
|
+
version: "2.2"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: mocha
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 49
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
- 9
|
76
|
+
- 5
|
77
|
+
version: 0.9.5
|
78
|
+
type: :development
|
79
|
+
version_requirements: *id004
|
80
|
+
description: This gem ties into the Rails model lifecycle to add support for calling Sunspot index on another model when data it relies on for its index is from an associated model.
|
81
|
+
email:
|
82
|
+
- swalterd@gmail.com
|
83
|
+
executables: []
|
84
|
+
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files: []
|
88
|
+
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- MIT_LICENSE
|
93
|
+
- README.rdoc
|
94
|
+
- Rakefile
|
95
|
+
- lib/sunspot_submodel_index.rb
|
96
|
+
- lib/sunspot_submodel_index/submodel_index.rb
|
97
|
+
- lib/sunspot_submodel_index/version.rb
|
98
|
+
- spec/lib/sunspot_submodel_test_model.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/submodel_index_spec.rb
|
101
|
+
- sunspot_submodel_index.gemspec
|
102
|
+
has_rdoc: true
|
103
|
+
homepage: http://github.com/mumboe/sunspot_submodel_index
|
104
|
+
licenses: []
|
105
|
+
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
requirements: []
|
130
|
+
|
131
|
+
rubyforge_project: sunspot_submodel_index
|
132
|
+
rubygems_version: 1.6.2
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: Support for Sunspot indexing of Rails models when an associated model is updated or deleted.
|
136
|
+
test_files:
|
137
|
+
- spec/lib/sunspot_submodel_test_model.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
- spec/submodel_index_spec.rb
|