algoliasearch-rails 1.19.1 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23f4ced41b37b645e2cce5d67f805d42850e029a
4
- data.tar.gz: a796b183866ab727b38d31be8235a3a8ff3883bb
3
+ metadata.gz: f7333f262a5b1e9d919ca00b85931fb980e4ecc0
4
+ data.tar.gz: 7337128b35c33d12690b1eaba6bf659e1df0f03f
5
5
  SHA512:
6
- metadata.gz: b31dbca7392ef79fa82ca7f949318e5365543797fa612cc0dad7cc0e453f57dc412e13c25acc1b24b7f0140944576bbe5de60e5d6bcc59f429d29a00e28db17c
7
- data.tar.gz: b0c7c3b271489fc8a10caf5a460e3bb236caa5992b98fe422581f219b07881386c126fcd3b8b1980dee556d34fe1e59a72da5a5e2a9c8ada8b0a9bee4662a641
6
+ metadata.gz: c300e5f50274dc54ed86224bb4c39c853e69473201a6a556c08bbe5f8868f2189ffbbecd1de6e26574831b3e42b73f8fba2254a8be41000b724347fc10c21782
7
+ data.tar.gz: 615ecacfba423c91e3f3e569041f82826fa778894be4c0b2ede19dfb00b3f7bdda723c6a87b57c2ef1b8514dde2bf3bd9cfce32b3202660d3faa8dd0ebf7e7e9
@@ -15,13 +15,17 @@ matrix:
15
15
  - rvm: 2.2.5
16
16
  env: RAILS_VERSION=4.2
17
17
  - rvm: 2.2.5
18
- env: RAILS_VERSION=5.0
19
- - rvm: 2.3.1
18
+ env: RAILS_VERSION=5.1
19
+ - rvm: 2.3.4
20
20
  env: RAILS_VERSION=3.2.0
21
- - rvm: 2.3.1
21
+ - rvm: 2.3.4
22
22
  env: RAILS_VERSION=4.2
23
- - rvm: 2.3.1
24
- env: RAILS_VERSION=5.0
23
+ - rvm: 2.3.4
24
+ env: RAILS_VERSION=5.1
25
+ - rvm: 2.4.1
26
+ env: RAILS_VERSION=4.2
27
+ - rvm: 2.4.1
28
+ env: RAILS_VERSION=5.1
25
29
  # - rvm: jruby-9.1.2.0
26
30
  # env: RAILS_VERSION=3.2.0
27
31
  # - rvm: jruby-9.1.2.0
@@ -47,5 +51,5 @@ install: rm -f Gemfile.lock && bundle install
47
51
  cache: bundler
48
52
  env:
49
53
  global:
50
- - secure: kD+PX8ZNg+AAzyr6WYs1vp9teAkzMfEoYkIMI0hrRN0ml9ccJVsJR1pIGpaIwyCa5PmFtCZ1Xi2vFb4XzTTeaZoHHS/ll9LwuQH6mwvdgj3n6TmNRdq3b/oGRHBX4Z0HMobqaftuzY/V8iTpVk92jwIY8NPj00k055b2jrKqhdw=
51
- - secure: Eai99h4K7s9/Sh3CHClWs3IQNaEUdVagpmA/A8m0rysGBAYJdMKbUOp9DZPAmCnT+06l0aFv87+CRYtgyX05pE5f21nqBOU46eKS38cLif3aPTwFmwokf28WLDgmZKa/zJp767SiQ/dp0hz+LJrkJvkDRnA1un36f7wiyY9xnYs=
54
+ - secure: "o/Hi/6KnBugN5P/cpVtpwyKrK5fVzAc0efw+qZ9ZqwqZN0GmipZrHmRNuLVUxVf+CIcqfLpIT0U172XGOZ5zJ1gs3qZZrDsJ1ptXnPyvvCrw+VX5yGhMh67JnlO0WLWvci0WdltJTmrhCoLSSw39nCPswC7I6/hai4KyiOXoMk4="
55
+ - secure: "Jv9jOYRwJq5i17Int/p75330yxCJXKLYlstHuBjwkKa6anJHFSXQaAxWj8sZHCY4IAVDsBfdi0j6S3dtVu2LaVLA3hfPp36YRVolSZu9zLbGqyPKBWM7E3i7GkS3Jub0nMV3Yo3cMeiFzQ4BmpSQOYo0biCkL8bh4/5NRZ7Q6VI="
data/ChangeLog CHANGED
@@ -1,5 +1,12 @@
1
1
  CHANGELOG
2
2
 
3
+ 2017-07-31 1.20.0
4
+
5
+ * Override the user-agent (#238)
6
+ * Fixed NPE while running mocked tests (#242)
7
+ * Add `paginationLimitedTo` setting (#243)
8
+ * Make `algolia_without_auto_index_scope` thread-safe (#234)
9
+
3
10
  2017-03-13 1.19.1
4
11
 
5
12
  * Make sure get_model_classes is not ActiveRecord compliant only
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'json', '~> 1.5', '>= 1.5.1'
4
- gem 'algoliasearch', '~> 1.12.4'
3
+ gem 'json', '~> 1.8', '>= 1.8.6'
4
+ gem 'algoliasearch', '~> 1.14.0'
5
5
 
6
6
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
7
7
  gem 'rubysl', '~> 2.0', :platform => :rbx
@@ -39,7 +39,7 @@ GEM
39
39
  minitest (~> 5.1)
40
40
  tzinfo (~> 1.1)
41
41
  addressable (2.4.0)
42
- algoliasearch (1.12.7)
42
+ algoliasearch (1.14.0)
43
43
  httpclient (~> 2.8.3)
44
44
  json (>= 1.5.1)
45
45
  arel (7.1.4)
@@ -175,9 +175,9 @@ PLATFORMS
175
175
  DEPENDENCIES
176
176
  activerecord-jdbc-adapter
177
177
  activerecord-jdbcsqlite3-adapter
178
- algoliasearch (~> 1.12.4)
178
+ algoliasearch (~> 1.14.0)
179
179
  jdbc-sqlite3
180
- json (~> 1.5, >= 1.5.1)
180
+ json (~> 1.8, >= 1.8.6)
181
181
  kaminari
182
182
  rails (>= 3.2.0)
183
183
  rake (~> 10.1.0)
@@ -190,4 +190,4 @@ DEPENDENCIES
190
190
  will_paginate (>= 2.3.15)
191
191
 
192
192
  BUNDLED WITH
193
- 1.13.6
193
+ 1.15.3
data/README.md CHANGED
@@ -291,8 +291,8 @@ class Contact < ActiveRecord::Base
291
291
  attribute :first_name, :last_name, :email
292
292
 
293
293
  # default search parameters stored in the index settings
294
- minWordSizeForApprox1 4
295
- minWordSizeForApprox2 8
294
+ minWordSizefor1Typo 4
295
+ minWordSizefor2Typos 8
296
296
  hitsPerPage 42
297
297
  end
298
298
  end
@@ -531,8 +531,16 @@ end
531
531
 
532
532
  class MySidekiqWorker
533
533
  def perform(id, remove)
534
- c = Contact.find(id)
535
- remove ? c.remove_from_index! : c.index!
534
+ if remove
535
+ # the record has likely already been removed from your database so we cannot
536
+ # use ActiveRecord#find to load it
537
+ index = Algolia::Index.new("index_name")
538
+ index.delete_object(id)
539
+ else
540
+ # the record should be present
541
+ c = Contact.find(id)
542
+ c.index!
543
+ end
536
544
  end
537
545
  end
538
546
  ```
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- VERSION = File.read(File.join(File.dirname(__FILE__), 'VERSION')).strip
3
+ require File.join(File.dirname(__FILE__), 'lib', 'algoliasearch', 'version')
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "algoliasearch-rails"
7
- s.version = VERSION
7
+ s.version = AlgoliaSearch::VERSION
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
10
  s.authors = ["Algolia"]
@@ -26,7 +26,6 @@ Gem::Specification.new do |s|
26
26
  "LICENSE",
27
27
  "README.md",
28
28
  "Rakefile",
29
- "VERSION",
30
29
  "algoliasearch-rails.gemspec",
31
30
  "lib/algoliasearch-rails.rb",
32
31
  "lib/algoliasearch/algolia_job.rb",
@@ -37,6 +36,7 @@ Gem::Specification.new do |s|
37
36
  "lib/algoliasearch/railtie.rb",
38
37
  "lib/algoliasearch/tasks/algoliasearch.rake",
39
38
  "lib/algoliasearch/utilities.rb",
39
+ "lib/algoliasearch/version.rb",
40
40
  "spec/spec_helper.rb",
41
41
  "spec/utilities_spec.rb",
42
42
  "vendor/assets/javascripts/algolia/algoliasearch.angular.js",
@@ -77,7 +77,7 @@ Gem::Specification.new do |s|
77
77
 
78
78
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
79
79
  s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
80
- s.add_runtime_dependency(%q<algoliasearch>, ["~> 1.12.4"])
80
+ s.add_runtime_dependency(%q<algoliasearch>, ["~> 1.14.0"])
81
81
  s.add_development_dependency(%q<will_paginate>, [">= 2.3.15"])
82
82
  s.add_development_dependency(%q<kaminari>, [">= 0"])
83
83
  s.add_development_dependency "travis"
@@ -85,11 +85,11 @@ Gem::Specification.new do |s|
85
85
  s.add_development_dependency "rdoc"
86
86
  else
87
87
  s.add_dependency(%q<json>, [">= 1.5.1"])
88
- s.add_dependency(%q<algoliasearch>, ["~> 1.12.1"])
88
+ s.add_dependency(%q<algoliasearch>, ["~> 1.14.0"])
89
89
  end
90
90
  else
91
91
  s.add_dependency(%q<json>, [">= 1.5.1"])
92
- s.add_dependency(%q<algoliasearch>, ["~> 1.12.1"])
92
+ s.add_dependency(%q<algoliasearch>, ["~> 1.14.0"])
93
93
  end
94
94
  end
95
95
 
@@ -8,6 +8,7 @@ rescue => e
8
8
  end
9
9
  require 'algoliasearch'
10
10
 
11
+ require 'algoliasearch/version'
11
12
  require 'algoliasearch/utilities'
12
13
 
13
14
  if defined? Rails
@@ -66,7 +67,8 @@ module AlgoliaSearch
66
67
  :unretrievableAttributes, :disableTypoToleranceOnWords, :disableTypoToleranceOnAttributes, :altCorrections,
67
68
  :ignorePlurals, :maxValuesPerFacet, :distinct, :numericAttributesToIndex, :numericAttributesForFiltering,
68
69
  :allowTyposOnNumericTokens, :allowCompressionOfIntegerArray,
69
- :advancedSyntax, :disablePrefixOnAttributes, :disableTypoToleranceOnAttributes]
70
+ :advancedSyntax, :disablePrefixOnAttributes, :disableTypoToleranceOnAttributes,
71
+ :paginationLimitedTo]
70
72
  OPTIONS.each do |k|
71
73
  define_method k do |v|
72
74
  instance_variable_set("@#{k}", v)
@@ -400,7 +402,7 @@ module AlgoliaSearch
400
402
  raise ArgumentError.new("Invalid `enqueue` option: #{options[:enqueue]}")
401
403
  end
402
404
  algoliasearch_options[:enqueue] = Proc.new do |record, remove|
403
- proc.call(record, remove) unless @algolia_without_auto_index_scope
405
+ proc.call(record, remove) unless algolia_without_auto_index_scope
404
406
  end
405
407
  end
406
408
  unless options[:auto_index] == false
@@ -456,16 +458,24 @@ module AlgoliaSearch
456
458
  end
457
459
 
458
460
  def algolia_without_auto_index(&block)
459
- @algolia_without_auto_index_scope = true
461
+ self.algolia_without_auto_index_scope = true
460
462
  begin
461
463
  yield
462
464
  ensure
463
- @algolia_without_auto_index_scope = false
465
+ self.algolia_without_auto_index_scope = false
464
466
  end
465
467
  end
466
468
 
469
+ def algolia_without_auto_index_scope=(value)
470
+ Thread.current["algolia_without_auto_index_scope_for_#{self.model_name}"] = value
471
+ end
472
+
473
+ def algolia_without_auto_index_scope
474
+ Thread.current["algolia_without_auto_index_scope_for_#{self.model_name}"]
475
+ end
476
+
467
477
  def algolia_reindex!(batch_size = 1000, synchronous = false)
468
- return if @algolia_without_auto_index_scope
478
+ return if algolia_without_auto_index_scope
469
479
  algolia_configurations.each do |options, settings|
470
480
  next if algolia_indexing_disabled?(options)
471
481
  index = algolia_ensure_init(options, settings)
@@ -496,7 +506,7 @@ module AlgoliaSearch
496
506
 
497
507
  # reindex whole database using a extra temporary index + move operation
498
508
  def algolia_reindex(batch_size = 1000, synchronous = false)
499
- return if @algolia_without_auto_index_scope
509
+ return if algolia_without_auto_index_scope
500
510
  algolia_configurations.each do |options, settings|
501
511
  next if algolia_indexing_disabled?(options)
502
512
  next if options[:slave] || options[:replica]
@@ -545,7 +555,7 @@ module AlgoliaSearch
545
555
  end
546
556
 
547
557
  def algolia_index!(object, synchronous = false)
548
- return if @algolia_without_auto_index_scope
558
+ return if algolia_without_auto_index_scope
549
559
  algolia_configurations.each do |options, settings|
550
560
  next if algolia_indexing_disabled?(options)
551
561
  object_id = algolia_object_id_of(object, options)
@@ -571,7 +581,7 @@ module AlgoliaSearch
571
581
  end
572
582
 
573
583
  def algolia_remove_from_index!(object, synchronous = false)
574
- return if @algolia_without_auto_index_scope
584
+ return if algolia_without_auto_index_scope
575
585
  object_id = algolia_object_id_of(object)
576
586
  raise ArgumentError.new("Cannot index a record with a blank objectID") if object_id.blank?
577
587
  algolia_configurations.each do |options, settings|
@@ -656,9 +666,9 @@ module AlgoliaSearch
656
666
  end
657
667
  end.compact
658
668
  # Algolia has a default limit of 1000 retrievable hits
659
- total_hits = json['nbHits'] < json['nbPages'] * json['hitsPerPage'] ?
660
- json['nbHits'] : json['nbPages'] * json['hitsPerPage']
661
- res = AlgoliaSearch::Pagination.create(results, total_hits, algoliasearch_options.merge({ :page => json['page'] + 1, :per_page => json['hitsPerPage'] }))
669
+ total_hits = json['nbHits'].to_i < json['nbPages'].to_i * json['hitsPerPage'].to_i ?
670
+ json['nbHits'].to_i: json['nbPages'].to_i * json['hitsPerPage'].to_i
671
+ res = AlgoliaSearch::Pagination.create(results, total_hits, algoliasearch_options.merge({ :page => json['page'].to_i + 1, :per_page => json['hitsPerPage'] }))
662
672
  res.extend(AdditionalMethods)
663
673
  res.send(:algolia_init_raw_answer, json)
664
674
  res
@@ -5,7 +5,7 @@ module AlgoliaSearch
5
5
  end
6
6
 
7
7
  def configuration=(configuration)
8
- @@configuration = configuration
8
+ @@configuration = configuration.merge(:user_agent => "Algolia for Rails (#{AlgoliaSearch::VERSION}); Algolia for Ruby (#{Algolia::VERSION})")
9
9
  Algolia.init @@configuration
10
10
  end
11
11
  end
@@ -20,10 +20,8 @@ module AlgoliaSearch
20
20
  puts ''
21
21
 
22
22
  klasses.each do |klass|
23
- say "#{klass}:"
24
-
25
- say "Reindexing #{klass.count} records...", true
26
-
23
+ puts klass
24
+ puts "Reindexing #{klass.count} records..."
27
25
  klass.algolia_reindex
28
26
  end
29
27
  end
@@ -0,0 +1,3 @@
1
+ module AlgoliaSearch
2
+ VERSION = '1.20.0'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.12.4
33
+ version: 1.14.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.12.4
40
+ version: 1.14.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: will_paginate
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +126,6 @@ files:
126
126
  - LICENSE
127
127
  - README.md
128
128
  - Rakefile
129
- - VERSION
130
129
  - algoliasearch-rails.gemspec
131
130
  - lib/algoliasearch-rails.rb
132
131
  - lib/algoliasearch/algolia_job.rb
@@ -137,6 +136,7 @@ files:
137
136
  - lib/algoliasearch/railtie.rb
138
137
  - lib/algoliasearch/tasks/algoliasearch.rake
139
138
  - lib/algoliasearch/utilities.rb
139
+ - lib/algoliasearch/version.rb
140
140
  - spec/spec_helper.rb
141
141
  - spec/utilities_spec.rb
142
142
  - vendor/assets/javascripts/algolia/algoliasearch.angular.js
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.19.1