sunspot 2.6.0 → 2.7.1

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
  SHA256:
3
- metadata.gz: c13ef43c3d9e3c45ca9d1ccc170ba55947797e788911fda1982b817d34207c5d
4
- data.tar.gz: 8a2dc3da8797d0ff4945c99732c9808e1ff9d06f94d0611b932a20cc49210d08
3
+ metadata.gz: f9749564050cadeb45de77d96ed183f7bb07a856b5199fea3bbede0365147e97
4
+ data.tar.gz: 5bdedfb6911ecbad36de8314822b536c6fb698e6432dcea03bd23be14672dcf7
5
5
  SHA512:
6
- metadata.gz: dbdf307d46210db9f3430a7a46d615709aa181c61c2400f6e42d23edd5dfa0c619ecb249cf148eb7215d4dd37d9907c630acf4d13ec83319cff1cbdd2652882e
7
- data.tar.gz: f77be8b5ee7ea9226565214951f4af0930b994f9fe568b4c79ac7d0733d414644d32018b4bdfb0ebd23a19b30ecece2c45da5d29b8bd46e28aafaf33ff58796f
6
+ metadata.gz: 1850a3b888c9589cb98878344d76d95882ebd95f8aae56095767a0ed3b49787a1c65cb5f1c3c84406afcc2c8cf8da4d533434b9e2850c3bd635a4417d45c14e4
7
+ data.tar.gz: 5d1a20b95d6f11caab821b186952d05e3c68a86b7e23bf673f451b23fa0429df0f4113e2a91cd12c50617375456b00d41656c7b5c7d402450b08e5df22b69b89
data/lib/sunspot/field.rb CHANGED
@@ -243,6 +243,8 @@ module Sunspot
243
243
  end
244
244
 
245
245
  class TypeField #:nodoc:
246
+ MODULAR_MODEL_MARK = '\:\:'
247
+
246
248
  class <<self
247
249
  def instance
248
250
  @instance ||= new
@@ -256,6 +258,10 @@ module Sunspot
256
258
  def to_indexed(clazz)
257
259
  clazz.name
258
260
  end
261
+
262
+ def to_solr_conditional(value)
263
+ value.include?(MODULAR_MODEL_MARK) ? "\"#{value}\"" : value
264
+ end
259
265
  end
260
266
 
261
267
  class IdField #:nodoc:
@@ -317,9 +317,14 @@ module Sunspot
317
317
  if @value.empty?
318
318
  "[* TO *]"
319
319
  else
320
- "(#{@value.map { |v| solr_value v } * ' OR '})"
320
+ "(#{@value.map { |v| to_solr_conditional_per_value v } * ' OR '})"
321
321
  end
322
322
  end
323
+
324
+ def to_solr_conditional_per_value(v)
325
+ @field.respond_to?(:to_solr_conditional) ?
326
+ @field.to_solr_conditional(solr_value(v)) : "#{solr_value(v)}"
327
+ end
323
328
  end
324
329
 
325
330
  #
@@ -256,7 +256,7 @@ module Sunspot
256
256
  def connection
257
257
  @connection ||= self.class.connection_class.connect(
258
258
  url: config.solr.url,
259
- read_timeout: config.solr.read_timeout,
259
+ timeout: config.solr.read_timeout,
260
260
  open_timeout: config.solr.open_timeout,
261
261
  proxy: config.solr.proxy,
262
262
  update_format: update_format
data/lib/sunspot/util.rb CHANGED
@@ -248,7 +248,7 @@ module Sunspot
248
248
  Coordinates = Struct.new(:lat, :lng)
249
249
 
250
250
  class ContextBoundDelegate
251
- class <<self
251
+ class << self
252
252
  def instance_eval_with_context(receiver, &block)
253
253
  calling_context = eval('self', block.binding)
254
254
  if parent_calling_context = calling_context.instance_eval{@__calling_context__ if defined?(@__calling_context__)}
@@ -289,21 +289,31 @@ module Sunspot
289
289
  __proxy_method__(:sub, *args, &block)
290
290
  end
291
291
 
292
- def method_missing(method, *args, &block)
293
- __proxy_method__(method, *args, &block)
292
+ def method_missing(method, *args, **kwargs, &block)
293
+ __proxy_method__(method, *args, **kwargs, &block)
294
294
  end
295
295
 
296
- def __proxy_method__(method, *args, &block)
297
- begin
296
+ def respond_to_missing?(method, _)
297
+ @__receiver__.respond_to?(method, true) || super
298
+ end
299
+
300
+ def __proxy_method__(method, *args, **kwargs, &block)
301
+ if kwargs.empty?
298
302
  @__receiver__.__send__(method.to_sym, *args, &block)
299
- rescue ::NoMethodError => e
300
- begin
303
+ else
304
+ @__receiver__.__send__(method.to_sym, *args, **kwargs, &block)
305
+ end
306
+ rescue ::NoMethodError => e
307
+ begin
308
+ if kwargs.empty?
301
309
  @__calling_context__.__send__(method.to_sym, *args, &block)
302
- rescue ::NoMethodError
303
- raise(e)
310
+ else
311
+ @__calling_context__.__send__(method.to_sym, *args, **kwargs, &block)
304
312
  end
313
+ rescue ::NoMethodError
314
+ raise(e)
305
315
  end
306
- end
316
+ end
307
317
  end
308
318
  end
309
319
  end
@@ -1,3 +1,3 @@
1
1
  module Sunspot
2
- VERSION = '2.6.0'
2
+ VERSION = '2.7.1'
3
3
  end
@@ -36,6 +36,17 @@ describe "DSL bindings" do
36
36
  end
37
37
  end
38
38
  end
39
+ expect(value).to eq('value')
40
+ end
41
+
42
+ it 'should give access to calling context\'s methods with keyword arguments' do
43
+ value = nil
44
+ session.search(Post) do
45
+ any_of do
46
+ value = kwargs_method(a: 10, b: 20)
47
+ end
48
+ end
49
+ expect(value).to eq({ a: 10, b: 20 })
39
50
  end
40
51
 
41
52
  private
@@ -47,4 +58,8 @@ describe "DSL bindings" do
47
58
  def id
48
59
  16
49
60
  end
61
+
62
+ def kwargs_method(a:, b:)
63
+ { a: a, b: b }
64
+ end
50
65
  end
@@ -98,7 +98,7 @@ describe 'indexing attribute fields', :type => :indexer do
98
98
 
99
99
  it 'should index latitude and longitude passed as non-Floats' do
100
100
  coordinates = Sunspot::Util::Coordinates.new(
101
- BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
101
+ BigDecimal('40.7'), BigDecimal('-73.5'))
102
102
  session.index(post(:coordinates => coordinates))
103
103
  expect(connection).to have_add_with(:coordinates_s => 'dr5xx3nytvgs')
104
104
  end
@@ -10,7 +10,7 @@ shared_examples_for 'geohash query' do
10
10
 
11
11
  it 'searches for nearby points with non-Float arguments' do
12
12
  search do
13
- with(:coordinates).near(BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
13
+ with(:coordinates).near(BigDecimal('40.7'), BigDecimal('-73.5'))
14
14
  end
15
15
  expect(connection).to have_last_search_including(:q, build_geo_query)
16
16
  end
@@ -1,12 +1,12 @@
1
1
  describe 'typed query' do
2
2
  it 'properly escapes namespaced type names' do
3
3
  session.search(Namespaced::Comment)
4
- expect(connection).to have_last_search_with(:fq => ['type:Namespaced\:\:Comment'])
4
+ expect(connection).to have_last_search_with(:fq => ['type:"Namespaced\:\:Comment"'])
5
5
  end
6
6
 
7
7
  it 'builds search for multiple types' do
8
8
  session.search(Post, Namespaced::Comment)
9
- expect(connection).to have_last_search_with(:fq => ['type:(Post OR Namespaced\:\:Comment)'])
9
+ expect(connection).to have_last_search_with(:fq => ['type:(Post OR "Namespaced\:\:Comment")'])
10
10
  end
11
11
 
12
12
  it 'searches type of subclass when superclass is configured' do
@@ -38,7 +38,7 @@ describe Sunspot::SessionProxy::MasterSlaveSessionProxy do
38
38
  end
39
39
 
40
40
  it 'should raise ArgumentError when bogus config specified' do
41
- expect { @proxy.config(:bogus) }.to raise_error
41
+ expect { @proxy.config(:bogus) }.to raise_error(ArgumentError)
42
42
  end
43
43
 
44
44
  it_should_behave_like 'session proxy'
@@ -1,7 +1,8 @@
1
1
  require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+ require 'uri'
2
3
 
3
4
  describe Sunspot::SessionProxy::Retry5xxSessionProxy do
4
-
5
+
5
6
  before :each do
6
7
  Sunspot::Session.connection_class = Mock::ConnectionFactory.new
7
8
  @sunspot_session = Sunspot.session
@@ -21,11 +22,14 @@ describe Sunspot::SessionProxy::Retry5xxSessionProxy do
21
22
  end
22
23
 
23
24
  let :fake_rsolr_request do
24
- {:uri => 'http://solr.test/uri'}
25
+ {:uri => URI('http://solr.test/uri')}
25
26
  end
26
27
 
27
28
  def fake_rsolr_response(status)
28
- {:status => status.to_s}
29
+ {
30
+ :status => status.to_s,
31
+ :body => ''
32
+ }
29
33
  end
30
34
 
31
35
  let :post do
@@ -67,12 +71,12 @@ describe Sunspot::SessionProxy::Retry5xxSessionProxy do
67
71
  it "should not retry a 4xx" do
68
72
  e = FakeRSolrErrorHttp.new(fake_rsolr_request, fake_rsolr_response(400))
69
73
  expect(@sunspot_session).to receive(:index).and_raise(e)
70
- expect { Sunspot.index(post) }.to raise_error
74
+ expect { Sunspot.index(post) }.to raise_error(FakeRSolrErrorHttp)
71
75
  end
72
76
 
73
77
  # TODO: try against more than just Sunspot.index? but that's just testing the
74
78
  # invocation of delegate, so probably not important. -nz 11Apr12
75
79
 
76
80
  it_should_behave_like 'session proxy'
77
-
81
+
78
82
  end
@@ -109,7 +109,7 @@ describe 'Session' do
109
109
  it 'should open a connection with custom read timeout' do
110
110
  Sunspot.config.solr.read_timeout = 0.5
111
111
  Sunspot.commit
112
- expect(connection.opts[:read_timeout]).to eq(0.5)
112
+ expect(connection.opts[:timeout]).to eq(0.5)
113
113
  end
114
114
 
115
115
  it 'should open a connection with custom open timeout' do
@@ -17,5 +17,5 @@ Sunspot.setup(Namespaced::Comment) do
17
17
  long :hash
18
18
  double :average_rating
19
19
  dynamic_float :custom_float, :multiple => true
20
- boost :boost
20
+ boost(:boost)
21
21
  end
data/sunspot.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  'Dylan Vaughn', 'Brian Durand', 'Sam Granieri', 'Nick Zadrozny', 'Jason Ronallo', 'Ryan Wallace', 'Nicholas Jakobsen',
12
12
  'Bragadeesh J', 'Ethiraj Srinivasan']
13
13
  s.email = ["mat@patch.com"]
14
- s.homepage = "http://outoftime.github.com/sunspot"
14
+ s.homepage = "https://sunspot.github.io"
15
15
  s.summary = 'Library for expressive, powerful interaction with the Solr search engine'
16
16
  s.license = 'MIT'
17
17
  s.description = <<-TEXT
@@ -27,10 +27,10 @@ Gem::Specification.new do |s|
27
27
 
28
28
  s.add_dependency 'rsolr', '>= 1.1.1', '< 3'
29
29
  s.add_dependency 'pr_geohash', '~>1.0'
30
-
31
- s.add_development_dependency 'rake', '< 12.3'
30
+ s.add_dependency 'bigdecimal'
31
+ s.add_development_dependency 'rake', '~> 13.2'
32
32
  s.add_development_dependency 'rspec', '~> 3.7'
33
- s.add_development_dependency 'appraisal', '2.2.0'
33
+ s.add_development_dependency 'appraisal', '~> 2.5'
34
34
 
35
35
  s.rdoc_options << '--webcvs=http://github.com/outoftime/sunspot/tree/master/%s' <<
36
36
  '--title' << 'Sunspot - Solr-powered search for Ruby objects - API Documentation' <<
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -30,7 +30,7 @@ authors:
30
30
  autorequire:
31
31
  bindir: bin
32
32
  cert_chain: []
33
- date: 2022-05-30 00:00:00.000000000 Z
33
+ date: 2024-07-16 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rsolr
@@ -66,20 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bigdecimal
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "<"
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '12.3'
89
+ version: '13.2'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "<"
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '12.3'
96
+ version: '13.2'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +112,16 @@ dependencies:
98
112
  name: appraisal
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '='
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 2.2.0
117
+ version: '2.5'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '='
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 2.2.0
124
+ version: '2.5'
111
125
  description: |2
112
126
  Sunspot is a library providing a powerful, all-ruby API for the Solr search engine. Sunspot manages the configuration of persistent
113
127
  Ruby classes for search and indexing and exposes Solr's most powerful features through a collection of DSLs. Complex search operations
@@ -334,7 +348,7 @@ files:
334
348
  - tasks/rdoc.rake
335
349
  - tasks/schema.rake
336
350
  - tasks/todo.rake
337
- homepage: http://outoftime.github.com/sunspot
351
+ homepage: https://sunspot.github.io
338
352
  licenses:
339
353
  - MIT
340
354
  metadata: {}
@@ -358,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
372
  - !ruby/object:Gem::Version
359
373
  version: '0'
360
374
  requirements: []
361
- rubygems_version: 3.1.4
375
+ rubygems_version: 3.4.19
362
376
  signing_key:
363
377
  specification_version: 4
364
378
  summary: Library for expressive, powerful interaction with the Solr search engine