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.
@@ -3,6 +3,8 @@ class Article
3
3
 
4
4
  include Mongoid::Document
5
5
 
6
+ include Mongoid::Timestamps
7
+
6
8
  field :title, type: String
7
9
 
8
10
  field :content, type: String
@@ -2,6 +2,8 @@ class ArticleRecord
2
2
 
3
3
  include Mongoid::Document
4
4
 
5
+ include Mongoid::Timestamps
6
+
5
7
  belongs_to :user_document
6
8
 
7
9
  belongs_to :article
@@ -3,6 +3,8 @@ class Comment
3
3
 
4
4
  include Mongoid::Document
5
5
 
6
+ include Mongoid::Timestamps
7
+
6
8
  embedded_in :article, polymorphic: true
7
9
 
8
10
  embedded_in :sub_topic, polymorphic: true
@@ -2,6 +2,8 @@ class SubTopic
2
2
 
3
3
  include Mongoid::Document
4
4
 
5
+ include Mongoid::Timestamps
6
+
5
7
  field :title, type: String
6
8
 
7
9
  field :content, type: String
data/app/models/tag.rb CHANGED
@@ -3,6 +3,8 @@ class Tag
3
3
 
4
4
  include Mongoid::Document
5
5
 
6
+ include Mongoid::Timestamps
7
+
6
8
  field :title, type: String
7
9
 
8
10
  recursively_embeds_many
data/app/models/topic.rb CHANGED
@@ -3,6 +3,8 @@ class Topic
3
3
 
4
4
  include Mongoid::Document
5
5
 
6
+ include Mongoid::Timestamps
7
+
6
8
  field :title, type: String
7
9
 
8
10
  field :content, type: String
@@ -3,6 +3,8 @@ class UserDocument
3
3
 
4
4
  include Mongoid::Document
5
5
 
6
+ include Mongoid::Timestamps
7
+
6
8
  has_many :article_scores
7
9
 
8
10
  belongs_to :user, class_name: "User"
@@ -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
@@ -1,3 +1,5 @@
1
+ require 'mongoid'
2
+
1
3
  module TopholdEngine
2
4
 
3
5
  class Engine < Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module TopholdEngine
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -23,4 +23,10 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.add_dependency "mongoid"
25
25
 
26
+ gem.add_dependency "sunspot"
27
+
28
+ gem.add_dependency "sunspot_cell"
29
+
30
+ gem.add_dependency "sunspot_mongoid"
31
+
26
32
  end
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.5
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