Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bichinger/sunspot into solr8-base…
Browse files Browse the repository at this point in the history
…d-update

# Conflicts:
#	.travis.yml
  • Loading branch information
gr8bit committed Nov 6, 2023
2 parents 1694743 + 4a86fbb commit 707accf
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 116 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 }}
40 changes: 0 additions & 40 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.
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def backtrace
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
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
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") %>
10 changes: 1 addition & 9 deletions sunspot_rails/sunspot_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,13 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

if RUBY_VERSION < '2.2'
s.add_dependency 'rails', '>= 3', '< 5'
else
s.add_dependency 'rails', '>= 3'
end

s.add_dependency 'rails', '>= 5'
s.add_dependency 'sunspot', Sunspot::VERSION

s.add_development_dependency 'appraisal', '2.2.0'
s.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0' if RUBY_VERSION <= '2.0.0'
s.add_development_dependency 'nokogiri', '< 1.7' if RUBY_VERSION <= '2.0.0'
s.add_development_dependency 'rake', '< 12.3'
s.add_development_dependency 'rspec', '~> 3.7'
s.add_development_dependency 'rspec-rails', '~> 3.7'
s.add_development_dependency 'sqlite3', '~> 1.3.0'

s.rdoc_options << '--webcvs=http://github.com/outoftime/sunspot/tree/master/%s' <<
'--title' << 'Sunspot-Rails - Rails integration for the Sunspot Solr search library - API Documentation' <<
Expand Down
4 changes: 2 additions & 2 deletions sunspot_solr/lib/sunspot/solr/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def exec_in_solr_executable_directory(command)
# Boolean:: success
#
def install_solr_home
unless File.exists?(solr_home)
unless File.exist?(solr_home)
Sunspot::Solr::Installer.execute(
solr_home,
:force => true,
Expand All @@ -189,7 +189,7 @@ def install_solr_home
#
def create_solr_directories
[pid_dir].each do |path|
FileUtils.mkdir_p(path) unless File.exists?(path)
FileUtils.mkdir_p(path) unless File.exist?(path)
end
end

Expand Down

0 comments on commit 707accf

Please sign in to comment.