Skip to content

Commit

Permalink
Merge branch 'release/v4.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Jun 27, 2019
2 parents 9f6e1ff + 1b581b6 commit 3bd06ec
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

All notable changes to this project (at least, from v3.0.0 onwards) are documented in this file.

## 4.3.1 - 2019-06-27

[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.3.1)

### Fixed

* Fixed loading of index files to work with Rails 6 and Zeitwerk ([#1137](https://github.com/pat/thinking-sphinx/issues/1137)).

## 4.3.0 - 2019-05-18

[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v4.3.0)

### Added

* Allow overriding of Sphinx's running state, which is useful when Sphinx commands are interacting with a remote Sphinx daemon. As per discussions in [#1131](https://github.com/pat/thinking-sphinx/pull/1124).
* Allow overriding of Sphinx's running state, which is useful when Sphinx commands are interacting with a remote Sphinx daemon. As per discussions in [#1131](https://github.com/pat/thinking-sphinx/pull/1131).
* Allow skipping of directory creation, as per discussions in [#1131](https://github.com/pat/thinking-sphinx/pull/1131).

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.textile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
h1. Thinking Sphinx

Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v4.3.0.
Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v4.3.1.

h2. Upgrading

Expand Down
12 changes: 9 additions & 3 deletions lib/thinking_sphinx/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def preload_indices
return if @preloaded_indices

index_paths.each do |path|
Dir["#{path}/**/*.rb"].sort.each do |file|
ActiveSupport::Dependencies.require_or_load file
end
Dir["#{path}/**/*.rb"].sort.each { |file| preload_index file }
end

normalise
Expand All @@ -99,6 +97,14 @@ def preload_indices
end
end

def preload_index(file)
if ActiveRecord::VERSION::MAJOR < 5
ActiveSupport::Dependencies.require_or_load file
else
load file
end
end

def render
preload_indices

Expand Down
33 changes: 17 additions & 16 deletions spec/thinking_sphinx/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

describe ThinkingSphinx::Configuration do
let(:config) { ThinkingSphinx::Configuration.instance }
let(:use_load?) { ActiveRecord::VERSION::MAJOR >= 5 }
let(:loading_object) { use_load? ? config : ActiveSupport::Dependencies }
let(:loading_method) { use_load? ? :load : :require_or_load }

after :each do
ThinkingSphinx::Configuration.reset
end

def expect_loading_of(file)
expect(loading_object).to receive(loading_method).with(file).once
end

describe '.instance' do
it "returns an instance of ThinkingSphinx::Configuration" do
expect(ThinkingSphinx::Configuration.instance).
Expand Down Expand Up @@ -254,10 +261,8 @@
'/path/to/indices/bar_index.rb'
]

expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/foo_index.rb').once
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/bar_index.rb').once
expect_loading_of('/path/to/indices/foo_index.rb')
expect_loading_of('/path/to/indices/bar_index.rb')

config.preload_indices
end
Expand All @@ -269,10 +274,8 @@
'/path/to/indices/bar_index.rb'
]

expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/foo_index.rb').once
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/bar_index.rb').once
expect_loading_of('/path/to/indices/foo_index.rb')
expect_loading_of('/path/to/indices/bar_index.rb')

config.preload_indices
config.preload_indices
Expand Down Expand Up @@ -316,10 +319,8 @@
'/path/to/indices/bar_index.rb'
]

expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/foo_index.rb').once
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/bar_index.rb').once
expect_loading_of('/path/to/indices/foo_index.rb')
expect_loading_of('/path/to/indices/bar_index.rb')

config.render
end
Expand All @@ -331,10 +332,8 @@
'/path/to/indices/bar_index.rb'
]

expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/foo_index.rb').once
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
with('/path/to/indices/bar_index.rb').once
expect_loading_of('/path/to/indices/foo_index.rb')
expect_loading_of('/path/to/indices/bar_index.rb')

config.preload_indices
config.preload_indices
Expand Down Expand Up @@ -372,6 +371,8 @@
end

it "skips creating a directory when the binlog_path is blank" do
allow(loading_object).to receive(loading_method)

allow(FileUtils).to receive_messages :mkdir_p => true
allow(config).to receive_messages :searchd => double(:binlog_path => '')

Expand Down
2 changes: 1 addition & 1 deletion thinking-sphinx.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $:.push File.expand_path('../lib', __FILE__)

Gem::Specification.new do |s|
s.name = 'thinking-sphinx'
s.version = '4.3.0'
s.version = '4.3.1'
s.platform = Gem::Platform::RUBY
s.authors = ["Pat Allan"]
s.email = ["[email protected]"]
Expand Down

0 comments on commit 3bd06ec

Please sign in to comment.