sunspot_mongoid 0.2.0 → 0.3.0
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/README.md +21 -25
 - data/Rakefile +1 -0
 - data/VERSION +1 -1
 - data/lib/sunspot/mongoid.rb +31 -18
 - data/lib/sunspot_mongoid.rb +0 -1
 - data/rails/init.rb +1 -1
 - metadata +31 -4
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -3,18 +3,14 @@ sunspot_mongoid 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            A Sunspot wrapper for Mongoid.
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            Example
         
     | 
| 
      
 6 
     | 
    
         
            +
            Install
         
     | 
| 
       9 
7 
     | 
    
         
             
            ----
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                gem install sunspot_mongoid
         
     | 
| 
       12 
10 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
            Examples
         
     | 
| 
      
 12 
     | 
    
         
            +
            ----
         
     | 
| 
       16 
13 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                # model
         
     | 
| 
       18 
14 
     | 
    
         
             
                class Post
         
     | 
| 
       19 
15 
     | 
    
         
             
                  include Mongoid::Document
         
     | 
| 
       20 
16 
     | 
    
         
             
                  field :title
         
     | 
| 
         @@ -25,27 +21,21 @@ Example 
     | 
|
| 
       25 
21 
     | 
    
         
             
                  end
         
     | 
| 
       26 
22 
     | 
    
         
             
                end
         
     | 
| 
       27 
23 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                Post.create(:title => 'foo bar')
         
     | 
| 
       31 
     | 
    
         
            -
                Post.create(:title => 'bar baz')
         
     | 
| 
      
 24 
     | 
    
         
            +
            For Rails3
         
     | 
| 
      
 25 
     | 
    
         
            +
            ----
         
     | 
| 
       32 
26 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                Sunspot.commit
         
     | 
| 
      
 27 
     | 
    
         
            +
            ### as gem:
         
     | 
| 
       35 
28 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                search = Post.search do
         
     | 
| 
       38 
     | 
    
         
            -
                  keywords 'foo'
         
     | 
| 
       39 
     | 
    
         
            -
                end
         
     | 
| 
       40 
     | 
    
         
            -
                search.each_hit_with_result do |hit, post|
         
     | 
| 
       41 
     | 
    
         
            -
                  p post
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
            add a gem to Gemfile as following,
         
     | 
| 
       43 
30 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                 
     | 
| 
       45 
     | 
    
         
            -
                #=> #<Post _id: 4c319556327b3c4b42000002, title: "foo bar">
         
     | 
| 
      
 31 
     | 
    
         
            +
                gem 'sunspot_mongoid'
         
     | 
| 
       46 
32 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
            create config/initializers/sunspot_mongoid.rb,
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                Sunspot.session = Sunspot::Rails.build_session
         
     | 
| 
      
 36 
     | 
    
         
            +
                ActionController::Base.module_eval { include(Sunspot::Rails::RequestLifecycle) }
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            ### as plugin:
         
     | 
| 
       49 
39 
     | 
    
         | 
| 
       50 
40 
     | 
    
         
             
            add gems to Gemfile as following,
         
     | 
| 
       51 
41 
     | 
    
         | 
| 
         @@ -56,6 +46,12 @@ and install sunspot_mongoid as rails plugin, 
     | 
|
| 
       56 
46 
     | 
    
         | 
| 
       57 
47 
     | 
    
         
             
                rails plugin install git://github.com/jugyo/sunspot_mongoid.git
         
     | 
| 
       58 
48 
     | 
    
         | 
| 
      
 49 
     | 
    
         
            +
            Links
         
     | 
| 
      
 50 
     | 
    
         
            +
            ----
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            * [sunspot](http://github.com/outoftime/sunspot)
         
     | 
| 
      
 53 
     | 
    
         
            +
            * [sunspot_rails](http://github.com/outoftime/sunspot/tree/master/sunspot_rails/)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       59 
55 
     | 
    
         
             
            Copyright
         
     | 
| 
       60 
56 
     | 
    
         
             
            ----
         
     | 
| 
       61 
57 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -14,6 +14,7 @@ begin 
     | 
|
| 
       14 
14 
     | 
    
         
             
                gem.add_runtime_dependency "sunspot", ">= 1.1.0"
         
     | 
| 
       15 
15 
     | 
    
         
             
                gem.add_runtime_dependency "sunspot_rails", ">= 1.1.0"
         
     | 
| 
       16 
16 
     | 
    
         
             
                gem.add_development_dependency "shoulda", ">= 0"
         
     | 
| 
      
 17 
     | 
    
         
            +
                gem.add_development_dependency "rr", ">= 0"
         
     | 
| 
       17 
18 
     | 
    
         
             
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
       18 
19 
     | 
    
         
             
              end
         
     | 
| 
       19 
20 
     | 
    
         
             
              Jeweler::GemcutterTasks.new
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.3.0
         
     | 
    
        data/lib/sunspot/mongoid.rb
    CHANGED
    
    | 
         @@ -1,10 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'sunspot'
         
     | 
| 
       1 
2 
     | 
    
         
             
            require 'mongoid'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'sunspot/rails 
     | 
| 
      
 3 
     | 
    
         
            +
            require 'sunspot/rails'
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            #  
     | 
| 
       5 
     | 
    
         
            -
            # 
     | 
| 
      
 5 
     | 
    
         
            +
            # == Examples:
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # class Post
         
     | 
| 
      
 8 
     | 
    
         
            +
            #   include Mongoid::Document
         
     | 
| 
      
 9 
     | 
    
         
            +
            #   field :title
         
     | 
| 
      
 10 
     | 
    
         
            +
            # 
         
     | 
| 
      
 11 
     | 
    
         
            +
            #   include Sunspot::Mongoid
         
     | 
| 
      
 12 
     | 
    
         
            +
            #   searchable do
         
     | 
| 
      
 13 
     | 
    
         
            +
            #     text :title
         
     | 
| 
      
 14 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 15 
     | 
    
         
            +
            # end
         
     | 
| 
       6 
16 
     | 
    
         
             
            #
         
     | 
| 
       7 
     | 
    
         
            -
            # Sunspot::Rails is distributed under the MIT License, copyright © 2009 Mat Brown
         
     | 
| 
       8 
17 
     | 
    
         
             
            module Sunspot
         
     | 
| 
       9 
18 
     | 
    
         
             
              module Mongoid
         
     | 
| 
       10 
19 
     | 
    
         
             
                def self.included(base)
         
     | 
| 
         @@ -15,25 +24,29 @@ module Sunspot 
     | 
|
| 
       15 
24 
     | 
    
         
             
                    extend Sunspot::Rails::Searchable::ClassMethods
         
     | 
| 
       16 
25 
     | 
    
         
             
                    include Sunspot::Rails::Searchable::InstanceMethods
         
     | 
| 
       17 
26 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                     
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
                    extend Sunspot::Mongoid::ClassMethods
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
       20 
30 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
                module ClassMethods
         
     | 
| 
      
 32 
     | 
    
         
            +
                  def searchable(options = {}, &block)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Sunspot.setup(self, &block)
         
     | 
| 
       22 
34 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                        before_save :maybe_mark_for_auto_indexing
         
     | 
| 
       25 
     | 
    
         
            -
                        after_save :maybe_auto_index
         
     | 
| 
       26 
     | 
    
         
            -
                      end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    class_inheritable_hash :sunspot_options
         
     | 
| 
       27 
36 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                      end
         
     | 
| 
       33 
     | 
    
         
            -
                      options[:include] = Sunspot::Util::Array(options[:include])
         
     | 
| 
      
 37 
     | 
    
         
            +
                    unless options[:auto_index] == false
         
     | 
| 
      
 38 
     | 
    
         
            +
                      before_save :maybe_mark_for_auto_indexing
         
     | 
| 
      
 39 
     | 
    
         
            +
                      after_save :maybe_auto_index
         
     | 
| 
      
 40 
     | 
    
         
            +
                    end
         
     | 
| 
       34 
41 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
                    unless options[:auto_remove] == false
         
     | 
| 
      
 43 
     | 
    
         
            +
                      after_destroy do |searchable|
         
     | 
| 
      
 44 
     | 
    
         
            +
                        searchable.remove_from_index
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
       36 
46 
     | 
    
         
             
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                    options[:include] = Sunspot::Util::Array(options[:include])
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    self.sunspot_options = options
         
     | 
| 
       37 
50 
     | 
    
         
             
                  end
         
     | 
| 
       38 
51 
     | 
    
         
             
                end
         
     | 
| 
       39 
52 
     | 
    
         | 
    
        data/lib/sunspot_mongoid.rb
    CHANGED
    
    
    
        data/rails/init.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,12 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sunspot_mongoid
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 19
         
     | 
| 
       4 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       5 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
     | 
    
         
            -
              -  
     | 
| 
      
 8 
     | 
    
         
            +
              - 3
         
     | 
| 
       8 
9 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
       10 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
13 
     | 
    
         
             
            - jugyo
         
     | 
| 
         @@ -14,16 +15,18 @@ autorequire: 
     | 
|
| 
       14 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-07- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2010-07-06 00:00:00 +09:00
         
     | 
| 
       18 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       21 
22 
     | 
    
         
             
              name: mongoid
         
     | 
| 
       22 
23 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       23 
24 
     | 
    
         
             
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
       24 
26 
     | 
    
         
             
                requirements: 
         
     | 
| 
       25 
27 
     | 
    
         
             
                - - ">="
         
     | 
| 
       26 
28 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 29 
     | 
    
         
            +
                    hash: 3
         
     | 
| 
       27 
30 
     | 
    
         
             
                    segments: 
         
     | 
| 
       28 
31 
     | 
    
         
             
                    - 0
         
     | 
| 
       29 
32 
     | 
    
         
             
                    version: "0"
         
     | 
| 
         @@ -33,9 +36,11 @@ dependencies: 
     | 
|
| 
       33 
36 
     | 
    
         
             
              name: sunspot
         
     | 
| 
       34 
37 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       35 
38 
     | 
    
         
             
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 39 
     | 
    
         
            +
                none: false
         
     | 
| 
       36 
40 
     | 
    
         
             
                requirements: 
         
     | 
| 
       37 
41 
     | 
    
         
             
                - - ">="
         
     | 
| 
       38 
42 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 43 
     | 
    
         
            +
                    hash: 19
         
     | 
| 
       39 
44 
     | 
    
         
             
                    segments: 
         
     | 
| 
       40 
45 
     | 
    
         
             
                    - 1
         
     | 
| 
       41 
46 
     | 
    
         
             
                    - 1
         
     | 
| 
         @@ -47,9 +52,11 @@ dependencies: 
     | 
|
| 
       47 
52 
     | 
    
         
             
              name: sunspot_rails
         
     | 
| 
       48 
53 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       49 
54 
     | 
    
         
             
              requirement: &id003 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 55 
     | 
    
         
            +
                none: false
         
     | 
| 
       50 
56 
     | 
    
         
             
                requirements: 
         
     | 
| 
       51 
57 
     | 
    
         
             
                - - ">="
         
     | 
| 
       52 
58 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 59 
     | 
    
         
            +
                    hash: 19
         
     | 
| 
       53 
60 
     | 
    
         
             
                    segments: 
         
     | 
| 
       54 
61 
     | 
    
         
             
                    - 1
         
     | 
| 
       55 
62 
     | 
    
         
             
                    - 1
         
     | 
| 
         @@ -61,14 +68,30 @@ dependencies: 
     | 
|
| 
       61 
68 
     | 
    
         
             
              name: shoulda
         
     | 
| 
       62 
69 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       63 
70 
     | 
    
         
             
              requirement: &id004 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 71 
     | 
    
         
            +
                none: false
         
     | 
| 
       64 
72 
     | 
    
         
             
                requirements: 
         
     | 
| 
       65 
73 
     | 
    
         
             
                - - ">="
         
     | 
| 
       66 
74 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 75 
     | 
    
         
            +
                    hash: 3
         
     | 
| 
       67 
76 
     | 
    
         
             
                    segments: 
         
     | 
| 
       68 
77 
     | 
    
         
             
                    - 0
         
     | 
| 
       69 
78 
     | 
    
         
             
                    version: "0"
         
     | 
| 
       70 
79 
     | 
    
         
             
              type: :development
         
     | 
| 
       71 
80 
     | 
    
         
             
              version_requirements: *id004
         
     | 
| 
      
 81 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 82 
     | 
    
         
            +
              name: rr
         
     | 
| 
      
 83 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 84 
     | 
    
         
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 85 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 86 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 87 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 88 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 89 
     | 
    
         
            +
                    hash: 3
         
     | 
| 
      
 90 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 91 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 92 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 93 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 94 
     | 
    
         
            +
              version_requirements: *id005
         
     | 
| 
       72 
95 
     | 
    
         
             
            description: A Sunspot wrapper for Mongoid that is like sunspot_rails.
         
     | 
| 
       73 
96 
     | 
    
         
             
            email: jugyo.org@gmail.com
         
     | 
| 
       74 
97 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -101,23 +124,27 @@ rdoc_options: 
     | 
|
| 
       101 
124 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       102 
125 
     | 
    
         
             
            - lib
         
     | 
| 
       103 
126 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 127 
     | 
    
         
            +
              none: false
         
     | 
| 
       104 
128 
     | 
    
         
             
              requirements: 
         
     | 
| 
       105 
129 
     | 
    
         
             
              - - ">="
         
     | 
| 
       106 
130 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 131 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
       107 
132 
     | 
    
         
             
                  segments: 
         
     | 
| 
       108 
133 
     | 
    
         
             
                  - 0
         
     | 
| 
       109 
134 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       110 
135 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 136 
     | 
    
         
            +
              none: false
         
     | 
| 
       111 
137 
     | 
    
         
             
              requirements: 
         
     | 
| 
       112 
138 
     | 
    
         
             
              - - ">="
         
     | 
| 
       113 
139 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 140 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
       114 
141 
     | 
    
         
             
                  segments: 
         
     | 
| 
       115 
142 
     | 
    
         
             
                  - 0
         
     | 
| 
       116 
143 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       117 
144 
     | 
    
         
             
            requirements: []
         
     | 
| 
       118 
145 
     | 
    
         | 
| 
       119 
146 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       120 
     | 
    
         
            -
            rubygems_version: 1.3. 
     | 
| 
      
 147 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
       121 
148 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       122 
149 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       123 
150 
     | 
    
         
             
            summary: A Sunspot wrapper for Mongoid.
         
     |