tophold_engine 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/article.rb +2 -0
- data/app/models/article_record.rb +2 -0
- data/app/models/comment.rb +2 -0
- data/app/models/sub_topic.rb +2 -0
- data/app/models/tag.rb +2 -0
- data/app/models/topic.rb +2 -0
- data/app/models/user_document.rb +2 -0
- data/lib/generators/tophold_engine/templates/sunspot_mongoid_patch.rb +40 -0
- data/lib/generators/tophold_engine/tophold_engine_generator.rb +1 -0
- data/lib/tophold_engine/engine.rb +2 -0
- data/lib/tophold_engine/version.rb +1 -1
- data/tophold_engine.gemspec +6 -0
- metadata +50 -1
data/app/models/article.rb
CHANGED
data/app/models/comment.rb
CHANGED
data/app/models/sub_topic.rb
CHANGED
data/app/models/tag.rb
CHANGED
data/app/models/topic.rb
CHANGED
data/app/models/user_document.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
#author: tteng
|
3
|
+
#override Sunspot::Mongoid::DataAccessor::BSON
|
4
|
+
#to fix uninitialized constant Sunspot::Mongoid::DataAccessor::BSON bug
|
5
|
+
#target version: sunspot_mongoid/0.4.1
|
6
|
+
|
7
|
+
module Sunspot
|
8
|
+
|
9
|
+
module Mongoid
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.class_eval do
|
13
|
+
extend Sunspot::Rails::Searchable::ActsAsMethods
|
14
|
+
Sunspot::Adapters::DataAccessor.register(DataAccessor, base)
|
15
|
+
Sunspot::Adapters::InstanceAdapter.register(InstanceAdapter, base)
|
16
|
+
after_save do
|
17
|
+
Sunspot.index! self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class DataAccessor < Sunspot::Adapters::DataAccessor
|
23
|
+
|
24
|
+
def load(id)
|
25
|
+
@clazz.criteria.for_ids(Moped::BSON::ObjectId(id))
|
26
|
+
end
|
27
|
+
|
28
|
+
def load_all(ids)
|
29
|
+
@clazz.criteria.in(:_id => ids.map {|id| Moped::BSON::ObjectId(id)})
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
#fix sunspot_mongoid not auto index bug
|
39
|
+
require 'auto_commit_sunspot'
|
40
|
+
Rails.configuration.mongoid.observers += [:auto_commit_sunspot]
|
@@ -5,6 +5,7 @@ class TopholdEngineGenerator < Rails::Generators::Base
|
|
5
5
|
|
6
6
|
def install_engine_patch
|
7
7
|
template "rails_engine_namespace_patch.rb", "config/initializers/rails_engine_namespace_patch.rb"
|
8
|
+
template "sunspot_mongoid_patch.rb", "config/initializers/sunspot_mongoid_patch.rb"
|
8
9
|
end
|
9
10
|
|
10
11
|
end
|
data/tophold_engine.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tophold_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,54 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sunspot
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sunspot_cell
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: sunspot_mongoid
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
62
110
|
description: tophold models engine
|
63
111
|
email:
|
64
112
|
- tim.rubist@gmail.com
|
@@ -83,6 +131,7 @@ files:
|
|
83
131
|
- config/initializers/basic_configatron_settings.rb
|
84
132
|
- config/initializers/mongoid_extends_patch.rb
|
85
133
|
- lib/generators/tophold_engine/templates/rails_engine_namespace_patch.rb
|
134
|
+
- lib/generators/tophold_engine/templates/sunspot_mongoid_patch.rb
|
86
135
|
- lib/generators/tophold_engine/tophold_engine_generator.rb
|
87
136
|
- lib/serve_gridfs_image.rb
|
88
137
|
- lib/tophold_engine.rb
|