Skip to content

Commit

Permalink
Merge branch 'master' into patch-rsolr-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
serggl authored Jun 4, 2024
2 parents 4de2112 + 605e345 commit 4f60935
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 125 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on: [push, pull_request]

jobs:
skip_concurrent_build:
name: Skip Concurrent Builds
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- uses: fkirc/[email protected]
id: skip_check
with:
concurrent_skipping: 'same_content'
github_token: ${{ github.token }}
do_not_skip: '["pull_request"]'
cancel_others: 'true'
skip_after_successful_duplicate: 'false'

build:
needs: skip_concurrent_build
if: ${{ needs.skip_concurrent_build.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
ruby-version:
- '2.5'
- '2.6'
- '2.7'
- '3.0'
- '3.1'
# - 'head'
gem: ['sunspot', 'sunspot_rails', 'sunspot_solr']
update-format: ['xml', 'json']
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler: '1'
bundler-cache: true # 'bundle install' and cache are handled automatically
- name: Test
run: ci/sunspot_test_script.sh
env:
GEM: ${{ matrix.gem }}
UPDATE_FORMAT: ${{ matrix.update-format }}
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sunspot

[![Gem Version](https://badge.fury.io/rb/sunspot.svg)](http://badge.fury.io/rb/sunspot)
[![Build Status](https://secure.travis-ci.org/sunspot/sunspot.svg?branch=master)](http://travis-ci.org/sunspot/sunspot)
[![CI](https://github.com/sunspot/sunspot/actions/workflows/ci.yml/badge.svg)](https://github.com/sunspot/sunspot/actions/workflows/ci.yml)

Sunspot is a Ruby library for expressive, powerful interaction with the Solr
search engine. Sunspot is built on top of the RSolr library, which
Expand Down Expand Up @@ -1667,9 +1667,9 @@ To run all the specs just call `rake` from the library root folder.
To run specs related to individual gems, consider using one of the following commands:

```bash
GEM=sunspot ci/travis.sh
GEM=sunspot_rails ci/travis.sh
GEM=sunspot_solr ci/travis.sh
GEM=sunspot ci/sunspot_test_script.sh
GEM=sunspot_rails ci/sunspot_test_script.sh
GEM=sunspot_solr ci/sunspot_test_script.sh
```

### Generating Documentation
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ end

desc 'Run all the tests'
task :default do
exit system([ "GEM=sunspot ci/travis.sh",
"GEM=sunspot_rails ci/travis.sh",
"GEM=sunspot_solr ci/travis.sh"].join(" && ")) ? 0 : 1
exit system([ "GEM=sunspot ci/sunspot_test_script.sh",
"GEM=sunspot_rails ci/sunspot_test_script.sh",
"GEM=sunspot_solr ci/sunspot_test_script.sh"].join(" && ")) ? 0 : 1
end
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/solr7_core/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
<!-- change field to textSpell and use copyField in schema.xml
to spellcheck multiple fields -->
<str name="field">textSpell</str>
<str name="buildOnCommit">true</str>
<str name="buildOnOptimize">true</str>
</lst>

<lst name="spellchecker">
Expand Down
30 changes: 20 additions & 10 deletions sunspot/lib/sunspot/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def deep_merge_into(destination, left, right)
Coordinates = Struct.new(:lat, :lng)

class ContextBoundDelegate
class <<self
class << self
def instance_eval_with_context(receiver, &block)
calling_context = eval('self', block.binding)
if parent_calling_context = calling_context.instance_eval{@__calling_context__ if defined?(@__calling_context__)}
Expand Down Expand Up @@ -289,21 +289,31 @@ def sub(*args, &block)
__proxy_method__(:sub, *args, &block)
end

def method_missing(method, *args, &block)
__proxy_method__(method, *args, &block)
def method_missing(method, *args, **kwargs, &block)
__proxy_method__(method, *args, **kwargs, &block)
end

def __proxy_method__(method, *args, &block)
begin
def respond_to_missing?(method, _)
@__receiver__.respond_to?(method, true) || super
end

def __proxy_method__(method, *args, **kwargs, &block)
if kwargs.empty?
@__receiver__.__send__(method.to_sym, *args, &block)
rescue ::NoMethodError => e
begin
else
@__receiver__.__send__(method.to_sym, *args, **kwargs, &block)
end
rescue ::NoMethodError => e
begin
if kwargs.empty?
@__calling_context__.__send__(method.to_sym, *args, &block)
rescue ::NoMethodError
raise(e)
else
@__calling_context__.__send__(method.to_sym, *args, **kwargs, &block)
end
rescue ::NoMethodError
raise(e)
end
end
end
end
end
end
15 changes: 15 additions & 0 deletions sunspot/spec/api/binding_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
end
end
end
expect(value).to eq('value')
end

it 'should give access to calling context\'s methods with keyword arguments' do
value = nil
session.search(Post) do
any_of do
value = kwargs_method(a: 10, b: 20)
end
end
expect(value).to eq({ a: 10, b: 20 })
end

private
Expand All @@ -47,4 +58,8 @@ def test_method
def id
16
end

def kwargs_method(a:, b:)
{ a: a, b: b }
end
end
2 changes: 1 addition & 1 deletion sunspot/spec/api/indexer/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

it 'should index latitude and longitude passed as non-Floats' do
coordinates = Sunspot::Util::Coordinates.new(
BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
BigDecimal('40.7'), BigDecimal('-73.5'))
session.index(post(:coordinates => coordinates))
expect(connection).to have_add_with(:coordinates_s => 'dr5xx3nytvgs')
end
Expand Down
2 changes: 1 addition & 1 deletion sunspot/spec/api/query/geo_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

it 'searches for nearby points with non-Float arguments' do
search do
with(:coordinates).near(BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
with(:coordinates).near(BigDecimal('40.7'), BigDecimal('-73.5'))
end
expect(connection).to have_last_search_including(:q, build_geo_query)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ def backtrace
end

let :fake_rsolr_request do
{:uri => 'http://solr.test/uri'}
{:uri => URI('http://solr.test/uri')}
end

def fake_rsolr_response(status)
{:status => status.to_s}
{
:status => status.to_s,
:body => ''
}
end

let :post do
Expand Down
2 changes: 1 addition & 1 deletion sunspot/spec/mocks/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ def custom_float
long :hash
double :average_rating
dynamic_float :custom_float, :multiple => true
boost :boost
boost(:boost)
end
2 changes: 1 addition & 1 deletion sunspot/sunspot.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
'Dylan Vaughn', 'Brian Durand', 'Sam Granieri', 'Nick Zadrozny', 'Jason Ronallo', 'Ryan Wallace', 'Nicholas Jakobsen',
'Bragadeesh J', 'Ethiraj Srinivasan']
s.email = ["[email protected]"]
s.homepage = "http://outoftime.github.com/sunspot"
s.homepage = "https://sunspot.github.io"
s.summary = 'Library for expressive, powerful interaction with the Solr search engine'
s.license = 'MIT'
s.description = <<-TEXT
Expand Down
55 changes: 11 additions & 44 deletions sunspot_rails/Appraisals
Original file line number Diff line number Diff line change
@@ -1,64 +1,31 @@
ruby_version = Gem::Version.new(RUBY_VERSION)

if ruby_version < Gem::Version.new('2.2.0')
['3.0.0', '3.1.0'].each do |rails_version|
appraise "rails-#{rails_version}" do
gem 'bundler', '>= 1.3.0', '< 2.0'
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
gem 'rails', "~> #{rails_version}"
gem 'progress_bar', '~> 1.0.5', require: false
gem 'rspec', '~> 3.4.0'
gem 'rspec-rails', '~> 3.4.0'
end
end
end

if ruby_version < Gem::Version.new('2.4.0')
appraise 'rails-3.2.0' do
gem 'bundler', '>= 1.3.0', '< 2.0'
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
gem 'rails', '~> 3.2.0'
gem 'progress_bar', '~> 1.0.5', require: false
gem 'test-unit', '~> 3.2.0'
gem 'rspec', '~> 3.4.0'
gem 'rspec-rails', '~> 3.4.0'
end

['4.0.0', '4.1.0'].each do |rails_version|
if ruby_version < Gem::Version.new('3.0.0')
['5.0.0', '5.1.0', '5.2.0'].each do |rails_version|
appraise "rails-#{rails_version}" do
gem 'bundler', '>= 1.3.0', '< 2.0'
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
gem 'rails', "~> #{rails_version}"
gem 'sprockets', '~> 3.0'
gem 'progress_bar', '~> 1.0.5', require: false
gem 'rspec', '~> 3.4.0'
gem 'rspec-rails', '~> 3.4.0'
gem 'sqlite3', '~> 1.3.0'
gem 'rspec', '~> 3.7'
gem 'rspec-rails', '~> 3.7'
end
end
end

if ruby_version < Gem::Version.new('2.5.0')
appraise 'rails-4.2.0' do
gem 'bundler', '>= 1.3.0', '< 2.0'
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
gem 'rails', '~> 4.2.0'
gem 'progress_bar', '~> 1.0.5', require: false
gem 'rspec', '~> 3.4.0'
gem 'rspec-rails', '~> 3.4.0'
end
end

if ruby_version >= Gem::Version.new('2.2.0')
['5.0.0', '5.1.0', '5.2.0'].each do |rails_version|
if Gem::Version.new('3.0.0') <= ruby_version && ruby_version < Gem::Version.new('3.3.0')
['6.1.0', '7.0.0'].each do |rails_version|
appraise "rails-#{rails_version}" do
gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
gem 'rails', "~> #{rails_version}"
gem 'sprockets', '~> 3.0'
gem 'progress_bar', '~> 1.0.5', require: false
gem 'sqlite3', '~> 1.4.0'
gem 'rspec', '~> 3'
gem 'rspec-rails', '~> 6'
end
end
end
6 changes: 3 additions & 3 deletions sunspot_rails/lib/sunspot/rails/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def request(event)
name = '%s (%.1fms)' % ["SOLR Request", event.duration]

# produces: path=select parameters={fq: ["type:Tag"], q: "rossi", fl: "* score", qf: "tag_name_text", defType: "edismax", start: 0, rows: 20}
path = color(event.payload[:path], BOLD, true)
path = color(event.payload[:path], nil, bold: true)
parameters = event.payload[:parameters].map { |k, v|
v = "\"#{v}\"" if v.is_a? String
v = v.to_s.gsub(/\\/,'') # unescape
"#{k}: #{color(v, BOLD, true)}"
"#{k}: #{color(v, nil, bold: true)}"
}.join(', ')
request = "path=#{path} parameters={#{parameters}}"

debug " #{color(name, GREEN, true)} [ #{request} ]"
debug " #{color(name, GREEN, bold: true)} [ #{request} ]"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion sunspot_rails/spec/model_lifecycle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
describe 'on update' do
before :each do
@post = PostWithAuto.create
@post.update_attributes(:title => 'Test 1')
@post.update(:title => 'Test 1')
Sunspot.commit
end

Expand Down
2 changes: 1 addition & 1 deletion sunspot_rails/spec/rails_app/config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
3 changes: 3 additions & 0 deletions sunspot_rails/spec/rails_app/config/storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
service: Disk
root: <%= Rails.root.join("storage") %>
Loading

0 comments on commit 4f60935

Please sign in to comment.