sunspot_association 0.0.1 → 0.0.2

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/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  log/*.log
3
3
  pkg/
4
4
  tmp/
5
- spec/sunspot_association.sqlite3
5
+ spec/sunspot_association.sqlite3
6
+ coverage/
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 { company.try(: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 { company.try(:name) }
36
+ text :company_name do; company.try(:name) end
37
37
  end
38
38
  end
39
39
 
@@ -1,3 +1,3 @@
1
1
  module SunspotAssociation
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -11,7 +11,12 @@ module SunspotAssociation
11
11
  ## Attributes
12
12
 
13
13
  cattr_accessor :sunspot_association_configuration
14
- cattr_accessor :sunspot_association_callbacks
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
@@ -1,3 +1,8 @@
1
+ ## Test coverage
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
1
6
  require 'active_record'
2
7
  require 'sunspot_association'
3
8
  require 'shoulda/matchers'
@@ -36,7 +36,6 @@ describe SunspotAssociation do
36
36
  model do
37
37
  has_many :orders
38
38
  has_many :users
39
- sunspot_associate :orders
40
39
  end
41
40
  end
42
41
 
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.add_development_dependency "sqlite3"
25
25
  s.add_development_dependency "sunspot_test"
26
+ s.add_development_dependency "coveralls"
26
27
 
27
28
  s.add_dependency "activerecord", "~> 3.0"
28
29
  s.add_dependency "sunspot_solr"
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.1
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-09 00:00:00.000000000 Z
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
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :sunspot_association do
3
- # # Task goes here
4
- # end