acts_as_ferret 0.5 → 0.5.1
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.
| @@ -9,7 +9,7 @@ class Stats < ActiveRecord::Base | |
| 9 9 | 
             
                  where kind=? group by time;
         | 
| 10 10 | 
             
              END
         | 
| 11 11 | 
             
                result = connection.execute sanitize_sql([sql, start_date, start_date, kind.to_s])
         | 
| 12 | 
            -
                 | 
| 12 | 
            +
                [].tap do |res|
         | 
| 13 13 | 
             
                  while row = result.fetch_row
         | 
| 14 14 | 
             
                    data = row.last.split(',').map{|t|t.to_i}
         | 
| 15 15 | 
             
                    median = data.size.odd? ? data[data.size/2] : ((data[data.size/2-1]+data[data.size/2]) / 2.0)
         | 
    
        data/lib/acts_as_ferret.rb
    CHANGED
    
    | @@ -493,14 +493,13 @@ module ActsAsFerret | |
| 493 493 |  | 
| 494 494 | 
             
              # combine our conditions with those given by user, if any
         | 
| 495 495 | 
             
              def self.combine_conditions(conditions, additional_conditions = [])
         | 
| 496 | 
            -
                 | 
| 497 | 
            -
                   | 
| 498 | 
            -
             | 
| 499 | 
            -
             | 
| 500 | 
            -
             | 
| 501 | 
            -
                    conditions.concat(cust_opts)
         | 
| 502 | 
            -
                  end
         | 
| 496 | 
            +
                if additional_conditions && additional_conditions.any?
         | 
| 497 | 
            +
                  cust_opts = (Array === additional_conditions) ? additional_conditions.dup : [ additional_conditions ]
         | 
| 498 | 
            +
                  logger.debug "cust_opts: #{cust_opts.inspect}"
         | 
| 499 | 
            +
                  conditions.first << " and " << cust_opts.shift
         | 
| 500 | 
            +
                  conditions.concat(cust_opts)
         | 
| 503 501 | 
             
                end
         | 
| 502 | 
            +
                return conditions
         | 
| 504 503 | 
             
              end
         | 
| 505 504 |  | 
| 506 505 | 
             
              def self.build_field_config(fields)
         | 
| @@ -125,7 +125,7 @@ module ActsAsFerret #:nodoc: | |
| 125 125 | 
             
                # fieldname => value pairs)
         | 
| 126 126 | 
             
                def to_doc
         | 
| 127 127 | 
             
                  logger.debug "creating doc for class: #{self.ferret_key}"
         | 
| 128 | 
            -
                   | 
| 128 | 
            +
                  Ferret::Document.new.tap do |doc|
         | 
| 129 129 | 
             
                    # store the id and class name of each item, and the unique key used for identifying the record
         | 
| 130 130 | 
             
                    # even in multi-class indexes.
         | 
| 131 131 | 
             
                    doc[:key] = self.ferret_key
         | 
| @@ -16,9 +16,9 @@ module ActsAsFerret | |
| 16 16 | 
             
                # The 'real' Ferret Index instance
         | 
| 17 17 | 
             
                def ferret_index
         | 
| 18 18 | 
             
                  ensure_index_exists
         | 
| 19 | 
            -
                   | 
| 20 | 
            -
                     | 
| 21 | 
            -
                     | 
| 19 | 
            +
                  (@ferret_index ||= Ferret::Index::Index.new(index_definition[:ferret])).tap do |idx|
         | 
| 20 | 
            +
                    idx.batch_size = index_definition[:reindex_batch_size]
         | 
| 21 | 
            +
                    idx.logger = logger
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| @@ -151,7 +151,7 @@ module ActsAsFerret | |
| 151 151 | 
             
                  return Ferret::Search::TermQuery.new(:key, key.to_s)
         | 
| 152 152 | 
             
                  # if shared?
         | 
| 153 153 | 
             
                  #   raise InvalidArgumentError.new("shared index needs class_name argument") if class_name.nil?
         | 
| 154 | 
            -
                  #    | 
| 154 | 
            +
                  #   Ferret::Search::BooleanQuery.new.tap do |bq|
         | 
| 155 155 | 
             
                  #     bq.add_query(Ferret::Search::TermQuery.new(:id,         id.to_s),    :must)
         | 
| 156 156 | 
             
                  #     bq.add_query(Ferret::Search::TermQuery.new(:class_name, class_name), :must)
         | 
| 157 157 | 
             
                  #   end
         | 
| @@ -182,7 +182,7 @@ module ActsAsFerret | |
| 182 182 | 
             
                                        :create      => true,
         | 
| 183 183 | 
             
                                        :field_infos => ActsAsFerret::field_infos(index_definition),
         | 
| 184 184 | 
             
                                        :path        => File.join(index_definition[:index_base_dir], 'rebuild')
         | 
| 185 | 
            -
                       | 
| 185 | 
            +
                      Ferret::Index::Index.new(ferret_cfg).tap do |i|
         | 
| 186 186 | 
             
                        i.batch_size = index_definition[:reindex_batch_size]
         | 
| 187 187 | 
             
                        i.logger = @logger
         | 
| 188 188 | 
             
                      end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,11 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: acts_as_ferret
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 5 | 
            -
              segments: 
         | 
| 6 | 
            -
              - 0
         | 
| 7 | 
            -
              - 5
         | 
| 8 | 
            -
              version: "0.5"
         | 
| 4 | 
            +
              version: 0.5.1
         | 
| 9 5 | 
             
            platform: ruby
         | 
| 10 6 | 
             
            authors: 
         | 
| 11 7 | 
             
            - Jens Kraemer
         | 
| @@ -18,33 +14,24 @@ default_executable: aaf_install | |
| 18 14 | 
             
            dependencies: 
         | 
| 19 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 20 16 | 
             
              name: jk-ferret
         | 
| 21 | 
            -
               | 
| 22 | 
            -
               | 
| 23 | 
            -
             | 
| 17 | 
            +
              type: :runtime
         | 
| 18 | 
            +
              version_requirement: 
         | 
| 19 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 24 20 | 
             
                requirements: 
         | 
| 25 21 | 
             
                - - ">="
         | 
| 26 22 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 27 | 
            -
                    segments: 
         | 
| 28 | 
            -
                    - 0
         | 
| 29 | 
            -
                    - 11
         | 
| 30 | 
            -
                    - 8
         | 
| 31 23 | 
             
                    version: 0.11.8
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              version_requirements: *id001
         | 
| 24 | 
            +
                version: 
         | 
| 34 25 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 35 26 | 
             
              name: rails
         | 
| 36 | 
            -
               | 
| 37 | 
            -
               | 
| 38 | 
            -
             | 
| 27 | 
            +
              type: :runtime
         | 
| 28 | 
            +
              version_requirement: 
         | 
| 29 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 39 30 | 
             
                requirements: 
         | 
| 40 31 | 
             
                - - ">="
         | 
| 41 32 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 42 | 
            -
                    segments: 
         | 
| 43 | 
            -
                    - 3
         | 
| 44 | 
            -
                    - 0
         | 
| 45 33 | 
             
                    version: "3.0"
         | 
| 46 | 
            -
             | 
| 47 | 
            -
              version_requirements: *id002
         | 
| 34 | 
            +
                version: 
         | 
| 48 35 | 
             
            description: Rails plugin that adds powerful full text search capabilities to ActiveRecord models.
         | 
| 49 36 | 
             
            email: jk@jkraemer.net
         | 
| 50 37 | 
             
            executables: 
         | 
| @@ -226,27 +213,21 @@ rdoc_options: | |
| 226 213 | 
             
            require_paths: 
         | 
| 227 214 | 
             
            - lib
         | 
| 228 215 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 229 | 
            -
              none: false
         | 
| 230 216 | 
             
              requirements: 
         | 
| 231 217 | 
             
              - - ">="
         | 
| 232 218 | 
             
                - !ruby/object:Gem::Version 
         | 
| 233 | 
            -
                  segments: 
         | 
| 234 | 
            -
                  - 1
         | 
| 235 | 
            -
                  - 8
         | 
| 236 | 
            -
                  - 7
         | 
| 237 219 | 
             
                  version: 1.8.7
         | 
| 220 | 
            +
              version: 
         | 
| 238 221 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 239 | 
            -
              none: false
         | 
| 240 222 | 
             
              requirements: 
         | 
| 241 223 | 
             
              - - ">="
         | 
| 242 224 | 
             
                - !ruby/object:Gem::Version 
         | 
| 243 | 
            -
                  segments: 
         | 
| 244 | 
            -
                  - 0
         | 
| 245 225 | 
             
                  version: "0"
         | 
| 226 | 
            +
              version: 
         | 
| 246 227 | 
             
            requirements: []
         | 
| 247 228 |  | 
| 248 229 | 
             
            rubyforge_project: acts_as_ferret
         | 
| 249 | 
            -
            rubygems_version: 1.3. | 
| 230 | 
            +
            rubygems_version: 1.3.5
         | 
| 250 231 | 
             
            signing_key: 
         | 
| 251 232 | 
             
            specification_version: 3
         | 
| 252 233 | 
             
            summary: acts_as_ferret - Ferret based full text search for any ActiveRecord model
         |