sunspot_association 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile.lock +15 -0
- data/README.md +3 -3
- data/lib/sunspot_association/version.rb +1 -1
- data/lib/sunspot_association.rb +6 -14
- data/spec/spec_helper.rb +5 -0
- data/spec/sunspot_association_spec.rb +0 -1
- data/sunspot_association.gemspec +1 -0
- metadata +18 -3
- data/lib/tasks/sunspot_association_tasks.rake +0 -4
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -24,6 +24,13 @@ GEM
|
|
24
24
|
mocha (= 0.10.5)
|
25
25
|
builder (3.0.4)
|
26
26
|
coderay (1.0.9)
|
27
|
+
colorize (0.5.8)
|
28
|
+
coveralls (0.6.5)
|
29
|
+
colorize
|
30
|
+
multi_json (~> 1.3)
|
31
|
+
rest-client
|
32
|
+
simplecov (>= 0.7)
|
33
|
+
thor
|
27
34
|
diff-lcs (1.1.3)
|
28
35
|
guard (1.6.2)
|
29
36
|
listen (>= 0.6.0)
|
@@ -39,6 +46,7 @@ GEM
|
|
39
46
|
lumberjack (1.0.2)
|
40
47
|
metaclass (0.0.1)
|
41
48
|
method_source (0.8.1)
|
49
|
+
mime-types (1.22)
|
42
50
|
mocha (0.10.5)
|
43
51
|
metaclass (~> 0.0.1)
|
44
52
|
multi_json (1.7.2)
|
@@ -50,6 +58,8 @@ GEM
|
|
50
58
|
slop (~> 3.4)
|
51
59
|
rake (10.0.4)
|
52
60
|
rb-fsevent (0.9.3)
|
61
|
+
rest-client (1.6.7)
|
62
|
+
mime-types (>= 1.16)
|
53
63
|
rsolr (1.0.8)
|
54
64
|
builder (>= 2.1.2)
|
55
65
|
rspec (2.12.0)
|
@@ -63,6 +73,10 @@ GEM
|
|
63
73
|
shoulda-matchers (1.4.2)
|
64
74
|
activesupport (>= 3.0.0)
|
65
75
|
bourne (~> 1.1.2)
|
76
|
+
simplecov (0.7.1)
|
77
|
+
multi_json (~> 1.0)
|
78
|
+
simplecov-html (~> 0.7.1)
|
79
|
+
simplecov-html (0.7.1)
|
66
80
|
slop (3.4.4)
|
67
81
|
sqlite3 (1.3.7)
|
68
82
|
sunspot (1.3.3)
|
@@ -86,6 +100,7 @@ PLATFORMS
|
|
86
100
|
|
87
101
|
DEPENDENCIES
|
88
102
|
bundler (>= 1.0.0)
|
103
|
+
coveralls
|
89
104
|
guard
|
90
105
|
guard-rspec
|
91
106
|
rake
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# sunspot_association [![Build Status](https://secure.travis-ci.org/Arjeno/sunspot_association.png?branch=master)](http://travis-ci.org/Arjeno/sunspot_association)
|
1
|
+
# sunspot_association [![Gem Version](https://badge.fury.io/rb/sunspot_association.png)](http://badge.fury.io/rb/sunspot_association) [![Build Status](https://secure.travis-ci.org/Arjeno/sunspot_association.png?branch=master)](http://travis-ci.org/Arjeno/sunspot_association) [![Dependency Status](https://gemnasium.com/Arjeno/sunspot_association.png)](https://gemnasium.com/Arjeno/sunspot_association) [![Coverage Status](https://coveralls.io/repos/Arjeno/sunspot_association/badge.png?branch=master)](https://coveralls.io/r/Arjeno/sunspot_association)
|
2
2
|
|
3
3
|
Automatically reindex ActiveRecord associations using Sunspot.
|
4
4
|
|
@@ -25,7 +25,7 @@ class User < ActiveRecord::Base
|
|
25
25
|
belongs_to :company
|
26
26
|
|
27
27
|
searchable do
|
28
|
-
text :company_name
|
28
|
+
text :company_name do; company.try(:name) end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,7 +33,7 @@ class Order < ActiveRecord::Base
|
|
33
33
|
belongs_to :company
|
34
34
|
|
35
35
|
searchable do
|
36
|
-
text :company_name
|
36
|
+
text :company_name do; company.try(:name) end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/lib/sunspot_association.rb
CHANGED
@@ -11,7 +11,12 @@ module SunspotAssociation
|
|
11
11
|
## Attributes
|
12
12
|
|
13
13
|
cattr_accessor :sunspot_association_configuration
|
14
|
-
|
14
|
+
|
15
|
+
## Callbacks
|
16
|
+
|
17
|
+
after_create Proc.new { |o| o.reindex_sunspot_associations!(:create) }
|
18
|
+
after_update Proc.new { |o| o.reindex_sunspot_associations!(:update) }
|
19
|
+
after_destroy Proc.new { |o| o.reindex_sunspot_associations!(:destroy) }
|
15
20
|
|
16
21
|
end
|
17
22
|
|
@@ -55,23 +60,10 @@ module SunspotAssociation
|
|
55
60
|
|
56
61
|
self.sunspot_association_configuration[object] = config
|
57
62
|
end
|
58
|
-
|
59
|
-
sunspot_association_callbacks!
|
60
|
-
end
|
61
|
-
|
62
|
-
def sunspot_association_callbacks!
|
63
|
-
return true if self.sunspot_association_callbacks == true
|
64
|
-
|
65
|
-
after_create Proc.new { |o| o.reindex_sunspot_associations!(:create) }
|
66
|
-
after_update Proc.new { |o| o.reindex_sunspot_associations!(:update) }
|
67
|
-
after_destroy Proc.new { |o| o.reindex_sunspot_associations!(:destroy) }
|
68
|
-
|
69
|
-
self.sunspot_association_callbacks = true
|
70
63
|
end
|
71
64
|
|
72
65
|
def reset_sunspot_associations!
|
73
66
|
self.sunspot_association_configuration = {}
|
74
|
-
self.sunspot_association_callbacks = false
|
75
67
|
end
|
76
68
|
|
77
69
|
end
|
data/spec/spec_helper.rb
CHANGED
data/sunspot_association.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_association
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: coveralls
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: activerecord
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +140,6 @@ files:
|
|
124
140
|
- Rakefile
|
125
141
|
- lib/sunspot_association.rb
|
126
142
|
- lib/sunspot_association/version.rb
|
127
|
-
- lib/tasks/sunspot_association_tasks.rake
|
128
143
|
- spec/spec_helper.rb
|
129
144
|
- spec/sunspot_association_spec.rb
|
130
145
|
- sunspot_association.gemspec
|