flying-sphinx 2.1.3 → 3.0.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
  SHA256:
3
- metadata.gz: 727f92b2356f83883fab5b51f106d39c43b8e89c57811a33fb5ea8541f21c09b
4
- data.tar.gz: 81451cc912cf38baad334a63f5e996bcb561da3bc94a6422da19c3b074f02ca0
3
+ metadata.gz: 32b8175efa0d0846873f557091c82fc88f3618840a176b4e04af8e913c52b2b3
4
+ data.tar.gz: d0e1bc6ba2684eb8785ded846e92e2946ce3fe2dd8e42386a54551d8433810e9
5
5
  SHA512:
6
- metadata.gz: 2add3250b48d68914f9bdaddbcb0f502f3b1f6a503a7ada15989df33788fde8e8eeecdef9d16bc9acdb4ae501cb8b5df4118ed45121d913bc4733d60678fff4b
7
- data.tar.gz: 315fec177d81494362eecfcb4bb368fc9ab6ae096b9027fdb1f26b75528b8300bfe6b1c74bfeb844f6cc8184310fa69a62aa17ca56dbf515f6cbc007728c6daf
6
+ metadata.gz: dac4e7aec527cda3258d06ac3fb8cb3eb959ccf3f87af9f0c1b6241dd5f3c8293932163dba66740eee54e748d7842622d49742352d706d8405fec4f269251d2e
7
+ data.tar.gz: 99c512ceac2d85230f6d144c1154d77ade553ca3de54de354e899d441c50706cce981bde3cc1e4ca4b398f237276f1f139ff4a71e1ab3f544393cce585357b3c
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-20.04
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby: [ '2.6', '2.7', '3.0', '3.1' ]
13
+ rails: [ '5.0', '5.1', '5.2', '6.0', '6.1', '7.0' ]
14
+ exclude:
15
+ - ruby: '2.6'
16
+ rails: '7.0'
17
+ - ruby: '2.7'
18
+ rails: '7.0'
19
+ - ruby: '3.0'
20
+ rails: '5.0'
21
+ - ruby: '3.0'
22
+ rails: '5.1'
23
+ - ruby: '3.0'
24
+ rails: '5.2'
25
+ - ruby: '3.1'
26
+ rails: '5.0'
27
+ - ruby: '3.1'
28
+ rails: '5.1'
29
+ - ruby: '3.1'
30
+ rails: '5.2'
31
+ - ruby: '3.1'
32
+ rails: '6.0'
33
+
34
+ steps:
35
+ - name: Check out code
36
+ uses: actions/checkout@v2
37
+ - name: Set up ruby
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ bundler-cache: true
42
+ - name: Set up Appraisal
43
+ run: bundle exec appraisal generate
44
+ - name: Install gems
45
+ env:
46
+ BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile"
47
+ run: bundle update
48
+ - name: Test
49
+ env:
50
+ CI: "true"
51
+ BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile"
52
+ run: bundle exec rspec
data/Appraisals CHANGED
@@ -1,29 +1,23 @@
1
- appraise 'rails-3.2' do
2
- gem 'rails', '~> 3.2.18'
3
- gem 'faraday', '~> 0.8.0'
4
- end if RUBY_VERSION.to_f <= 2.3
5
-
6
- appraise 'rails-4.0' do
7
- gem 'rails', '~> 4.0.5'
8
- gem 'faraday', '~> 0.9.0'
9
- end if RUBY_VERSION.to_f <= 2.3
10
-
11
- appraise 'rails-4.1' do
12
- gem 'rails', '~> 4.1.16'
13
- end if RUBY_VERSION.to_f <= 2.3
14
-
15
- appraise 'rails-4.2' do
16
- gem 'rails', '~> 4.2.10'
17
- end if RUBY_VERSION.to_f <= 2.3
18
-
19
- appraise 'rails-5.0' do
1
+ appraise 'rails_5.0' do
20
2
  gem 'rails', '~> 5.0.6'
21
- end
3
+ end if RUBY_VERSION.to_f <= 2.7
22
4
 
23
- appraise 'rails-5.1' do
5
+ appraise 'rails_5.1' do
24
6
  gem 'rails', '~> 5.1.4'
25
- end
7
+ end if RUBY_VERSION.to_f <= 2.7
26
8
 
27
- appraise 'rails-5.2' do
9
+ appraise 'rails_5.2' do
28
10
  gem 'rails', '~> 5.2.0'
11
+ end if RUBY_VERSION.to_f <= 2.7
12
+
13
+ appraise 'rails_6.0' do
14
+ gem 'rails', '~> 6.0.0'
15
+ end if RUBY_VERSION.to_f <= 3.0
16
+
17
+ appraise 'rails_6.1' do
18
+ gem 'rails', '~> 6.1.0'
29
19
  end
20
+
21
+ appraise 'rails_7.0' do
22
+ gem 'rails', '~> 7.0.0'
23
+ end if RUBY_VERSION.to_f >= 2.7
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project (at least, from v0.4.0 onwards) are documented in this file.
4
4
 
5
+ ## 3.0.0 - 2022-04-12
6
+
7
+ ### Changed
8
+
9
+ * Supports (and requires) Faraday v2+.
10
+ * Dropped support for Ruby 2.5 and older.
11
+ * Dropped support for Rails 4.2 and older.
12
+
13
+ No functional changes to the gem beyond the Faraday changes, though the tests and CI have had some improvements.
14
+
15
+ ## 2.2.0 - 2020-04-04
16
+
17
+ ### Added
18
+
19
+ * The `lemmatizer_base` option is now respected and files in that specified directory are copied to the Flying Sphinx servers as part of the configure command.
20
+
21
+ ### Changed
22
+
23
+ * Official support for Ruby 2.2 has ended. The gem may continue to work, but there is no guarantee of ongoing compatibility.
24
+
25
+ ## 2.1.4 - 2019-03-10
26
+
27
+ ### Fixed
28
+
29
+ * Fixed the overriding of Flying Sphinx connection details by Thinking Sphinx's new prepare hook (added in Thinking Sphinx v4.2.0).
30
+
5
31
  ## 2.1.3 - 2018-12-12
6
32
 
7
33
  ### Fixed
data/README.textile CHANGED
@@ -12,7 +12,7 @@ This is all covered pretty well on "the Flying Sphinx site":http://flying-sphinx
12
12
 
13
13
  h2. Compatibility and Limitations
14
14
 
15
- The current (2.x) releases support Thinking Sphinx v4+, ActiveRecord/Rails 3.2+, and Ruby 2.2+.
15
+ The current (2.x) releases support Thinking Sphinx v4+, ActiveRecord/Rails 3.2+, and Ruby 2.3+. Ruby 2.2.x will probably work well too, but is not tested against, and thus not officially supported.
16
16
 
17
17
  If you are using older versions of any of these, please use v1.3.1 (which supports Thinking Sphinx v1.5+, ActiveRecord/Rails 2.3.6+, and Ruby 1.9.3+).
18
18
 
@@ -39,4 +39,4 @@ h2. Contributors
39
39
 
40
40
  h2. Licence
41
41
 
42
- Copyright &copy; 2011-2018 Pat Allan, released under an MIT licence.
42
+ Copyright &copy; 2011-2019 Pat Allan, released under an MIT licence.
@@ -17,19 +17,20 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ['lib']
18
18
  s.executables = ['flying-sphinx']
19
19
 
20
- s.add_runtime_dependency 'ey-hmac', '~> 2.2'
21
- s.add_runtime_dependency 'faraday', '>= 0.7'
22
- s.add_runtime_dependency 'gzipped_tar', '~> 0.1.1'
20
+ s.add_runtime_dependency 'ey-hmac', '~> 2.4'
21
+ s.add_runtime_dependency 'faraday', '>= 2'
22
+ s.add_runtime_dependency 'faraday-multipart'
23
+ s.add_runtime_dependency 'gzipped_tar', '>= 0.1.2'
23
24
  s.add_runtime_dependency 'multi_json', '>= 1.3.0'
24
- s.add_runtime_dependency 'pusher-client', '~> 0.3'
25
+ s.add_runtime_dependency 'pusher-client', '~> 0.6'
25
26
  s.add_runtime_dependency 'thinking-sphinx', '>= 4.0.0'
26
27
 
27
- s.add_development_dependency 'appraisal', '~> 2.2'
28
- s.add_development_dependency 'dotenv', '~> 0.11.1'
29
- s.add_development_dependency 'em-websocket', '~> 0.5.1'
30
- s.add_development_dependency 'mysql2', '~> 0.3.15'
28
+ s.add_development_dependency 'appraisal', '~> 2.4'
29
+ s.add_development_dependency 'dotenv', '~> 2.7'
30
+ s.add_development_dependency 'mysql2', '>= 0.3.15'
31
31
  s.add_development_dependency 'rack'
32
32
  s.add_development_dependency 'rspec', '~> 2.14'
33
33
  s.add_development_dependency 'rspec-retry', '~> 0.4'
34
- s.add_development_dependency 'webmock', '~> 1.17.4'
34
+ s.add_development_dependency 'webmock', '~> 3.14'
35
+ s.add_development_dependency 'websocket-driver'
35
36
  end
@@ -8,7 +8,10 @@ class FlyingSphinx::ConfigurationOptions
8
8
  end
9
9
 
10
10
  def settings
11
- @settings ||= FlyingSphinx::SettingFiles.new(indices).to_hash
11
+ @settings ||= begin
12
+ configuration.render
13
+ FlyingSphinx::SettingFiles.new(configuration).to_hash
14
+ end
12
15
  end
13
16
 
14
17
  def version
@@ -21,11 +24,6 @@ class FlyingSphinx::ConfigurationOptions
21
24
  @configuration ||= ThinkingSphinx::Configuration.instance
22
25
  end
23
26
 
24
- def indices
25
- configuration.render
26
- configuration.indices
27
- end
28
-
29
27
  def version_defined?
30
28
  configuration.version.present?
31
29
  end
@@ -1,3 +1,5 @@
1
+ require "faraday/multipart"
2
+
1
3
  class FlyingSphinx::Configurer
2
4
  InvalidVersionError = Class.new FlyingSphinx::Error
3
5
  PresignatureError = Class.new FlyingSphinx::Error
@@ -1,13 +1,29 @@
1
1
  class FlyingSphinx::Railtie < Rails::Railtie
2
2
  rake_tasks do
3
+ next unless FlyingSphinx::Railtie.remote_sphinx?
4
+
3
5
  require 'flying_sphinx/commands'
4
6
 
5
7
  ThinkingSphinx.rake_interface = FlyingSphinx::RakeInterface
6
8
 
7
9
  load File.expand_path('../tasks.rb', __FILE__)
8
- end if ENV['FLYING_SPHINX_IDENTIFIER'] || ENV['STAGED_SPHINX_IDENTIFIER']
10
+ end
9
11
 
10
12
  initializer "flying_sphinx.set_sphinx_host_and_port" do |app|
13
+ FlyingSphinx::Railtie.set_up_remote_connection
14
+ end
15
+
16
+ config.to_prepare do
17
+ FlyingSphinx::Railtie.set_up_remote_connection
18
+ end
19
+
20
+ def self.remote_sphinx?
21
+ ENV['FLYING_SPHINX_IDENTIFIER'] || ENV['STAGED_SPHINX_IDENTIFIER']
22
+ end
23
+
24
+ def self.set_up_remote_connection
25
+ return unless remote_sphinx?
26
+
11
27
  configuration = FlyingSphinx::Configuration.new
12
28
 
13
29
  ThinkingSphinx::Configuration.instance.settings['connection_options'] = {
@@ -15,5 +31,5 @@ class FlyingSphinx::Railtie < Rails::Railtie
15
31
  :port => 9306,
16
32
  :username => configuration.username
17
33
  }
18
- end if ENV['FLYING_SPHINX_IDENTIFIER'] || ENV['STAGED_SPHINX_IDENTIFIER']
34
+ end
19
35
  end
@@ -1,4 +1,4 @@
1
- class FlyingSphinx::Response::Invalid < Faraday::Response::Middleware
1
+ class FlyingSphinx::Response::Invalid < Faraday::Middleware
2
2
  def on_complete(environment)
3
3
  return unless environment[:status] == 403
4
4
 
@@ -1,4 +1,4 @@
1
- class FlyingSphinx::Response::JSON < Faraday::Response::Middleware
1
+ class FlyingSphinx::Response::JSON < Faraday::Middleware
2
2
  def on_complete(environment)
3
3
  return if environment[:request_headers]['Authorization'].nil?
4
4
 
@@ -1,4 +1,4 @@
1
- class FlyingSphinx::Response::Logger < Faraday::Response::Middleware
1
+ class FlyingSphinx::Response::Logger < Faraday::Middleware
2
2
  extend Forwardable
3
3
 
4
4
  def call(environment)
@@ -1,9 +1,10 @@
1
1
  class FlyingSphinx::SettingFiles
2
2
  INDEX_SETTINGS = [:stopwords, :wordforms, :exceptions]
3
3
  SOURCE_SETTINGS = [:mysql_ssl_cert, :mysql_ssl_key, :mysql_ssl_ca]
4
+ COMMON_SETTINGS = [:lemmatizer_base]
4
5
 
5
- def initialize(indices)
6
- @indices = indices
6
+ def initialize(configuration)
7
+ @configuration = configuration
7
8
  end
8
9
 
9
10
  def to_hash
@@ -19,11 +20,27 @@ class FlyingSphinx::SettingFiles
19
20
 
20
21
  private
21
22
 
22
- attr_reader :indices
23
+ attr_reader :configuration
24
+
25
+ delegate :indices, :to => :configuration
26
+
27
+ def common_settings(&block)
28
+ return unless configuration.respond_to?(:common)
29
+
30
+ COMMON_SETTINGS.each do |setting|
31
+ path = configuration.common.public_send(setting)
32
+ next if path.nil?
33
+
34
+ Dir["#{path}/**/*"].each do |file|
35
+ block.call setting, file
36
+ end
37
+ end
38
+ end
23
39
 
24
40
  def each_file_for_setting(&block)
25
41
  index_settings &block
26
42
  source_settings &block
43
+ common_settings &block
27
44
  end
28
45
 
29
46
  def index_settings(&block)
@@ -1,3 +1,3 @@
1
1
  module FlyingSphinx
2
- Version = '2.1.3'
2
+ Version = '3.0.0'
3
3
  end
@@ -4,7 +4,7 @@ require 'cgi'
4
4
  describe 'Configuring Sphinx' do
5
5
  let(:interface) { ThinkingSphinx.rake_interface.new }
6
6
  let(:configuration) { configuration_double :indices => [double('Index')],
7
- :render => 'searchd { }', :version => '2.2.11' }
7
+ :render => 'searchd { }', :version => '2.2.11', :common => double('common', lemmatizer_base: nil) }
8
8
 
9
9
  before :each do
10
10
  allow(ThinkingSphinx::Configuration).to receive(:instance).
@@ -17,6 +17,7 @@ describe FlyingSphinx::Action do
17
17
  end
18
18
 
19
19
  def perform_and_complete(action)
20
+ Thread.report_on_exception = false
20
21
  thread = Thread.new { action.perform }
21
22
  sleep 0.01
22
23
  action.send :completion, '{"id":748}'
@@ -83,6 +84,7 @@ describe FlyingSphinx::Action do
83
84
  it "logs a warning when the action fails" do
84
85
  logger.should_receive(:warn).with("Action failed.")
85
86
 
87
+ Thread.report_on_exception = false
86
88
  thread = Thread.new { action.perform }
87
89
  sleep 0.01
88
90
  action.send :failure, '{"id":748}'
@@ -1,8 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FlyingSphinx::SettingFiles do
4
- let(:files) { FlyingSphinx::SettingFiles.new indices }
4
+ let(:files) { FlyingSphinx::SettingFiles.new configuration }
5
+ let(:configuration) do
6
+ double(:configuration, :indices => indices, :common => common)
7
+ end
5
8
  let(:indices) { [] }
9
+ let(:common) { double(:common, :lemmatizer_base => nil) }
6
10
 
7
11
  def index_double(methods)
8
12
  double 'Riddle::Configuration::Index', methods
@@ -14,38 +18,38 @@ describe FlyingSphinx::SettingFiles do
14
18
 
15
19
  describe '#to_hash' do
16
20
  before :each do
17
- File.stub :read => 'blah'
21
+ allow(File).to receive(:read).and_return('blah')
18
22
  end
19
23
 
20
24
  [:stopwords, :wordforms, :exceptions].each do |setting|
21
25
  it "collects #{setting} files from indices" do
22
26
  indices << index_double(setting => '/my/file/foo.txt')
23
27
 
24
- files.to_hash.should == {
28
+ expect(files.to_hash).to eq(
25
29
  "#{setting}/foo.txt" => 'blah',
26
30
  'extra' => "#{setting}/foo.txt"
27
- }
31
+ )
28
32
  end
29
33
 
30
34
  it "does not repeat same files for #{setting}" do
31
35
  indices << index_double(setting => '/my/file/foo.txt')
32
36
  indices << index_double(setting => '/my/file/foo.txt')
33
37
 
34
- files.to_hash.should == {
38
+ expect(files.to_hash).to eq(
35
39
  "#{setting}/foo.txt" => 'blah',
36
40
  'extra' => "#{setting}/foo.txt"
37
- }
41
+ )
38
42
  end
39
43
 
40
44
  it "accepts multiples files for #{setting}" do
41
45
  indices << index_double(
42
46
  setting => '/my/file/foo.txt /my/file/bar.txt')
43
47
 
44
- files.to_hash["#{setting}/foo.txt"].should == 'blah'
45
- files.to_hash["#{setting}/bar.txt"].should == 'blah'
46
- files.to_hash['extra'].split(';').should =~ [
48
+ expect(files.to_hash["#{setting}/foo.txt"]).to eq('blah')
49
+ expect(files.to_hash["#{setting}/bar.txt"]).to eq('blah')
50
+ expect(files.to_hash['extra'].split(';')).to match_array([
47
51
  "#{setting}/foo.txt", "#{setting}/bar.txt"
48
- ]
52
+ ])
49
53
  end
50
54
  end
51
55
 
@@ -54,10 +58,10 @@ describe FlyingSphinx::SettingFiles do
54
58
  indices << index_double(:sources => [
55
59
  source_double(setting => '/my/file/foo.txt')])
56
60
 
57
- files.to_hash.should == {
61
+ expect(files.to_hash).to eq(
58
62
  "#{setting}/foo.txt" => 'blah',
59
63
  'extra' => "#{setting}/foo.txt"
60
- }
64
+ )
61
65
  end
62
66
 
63
67
  it "does not repeat same files for #{setting}" do
@@ -66,21 +70,35 @@ describe FlyingSphinx::SettingFiles do
66
70
  indices << index_double(:sources => [
67
71
  source_double(setting => '/my/file/foo.txt')])
68
72
 
69
- files.to_hash.should == {
73
+ expect(files.to_hash).to eq(
70
74
  "#{setting}/foo.txt" => 'blah',
71
75
  'extra' => "#{setting}/foo.txt"
72
- }
76
+ )
73
77
  end
74
78
 
75
79
  it "accepts multiples files for #{setting}" do
76
80
  indices << index_double(:sources => [
77
81
  source_double(setting => '/my/file/foo.txt /my/file/bar.txt')])
78
82
 
79
- files.to_hash["#{setting}/foo.txt"].should == 'blah'
80
- files.to_hash["#{setting}/bar.txt"].should == 'blah'
81
- files.to_hash['extra'].split(';').should =~ [
83
+ expect(files.to_hash["#{setting}/foo.txt"]).to eq('blah')
84
+ expect(files.to_hash["#{setting}/bar.txt"]).to eq('blah')
85
+ expect(files.to_hash['extra'].split(';')).to match_array([
82
86
  "#{setting}/foo.txt", "#{setting}/bar.txt"
83
- ]
87
+ ])
88
+ end
89
+ end
90
+
91
+ [:lemmatizer_base].each do |setting|
92
+ it "collects #{setting} files from sources" do
93
+ allow(common).to receive(setting).and_return("/my/path")
94
+
95
+ allow(Dir).to receive(:[]).with("/my/path/**/*").
96
+ and_return(["/my/path/foo.txt"])
97
+
98
+ expect(files.to_hash).to eq(
99
+ "#{setting}/foo.txt" => 'blah',
100
+ 'extra' => "#{setting}/foo.txt"
101
+ )
84
102
  end
85
103
  end
86
104
  end
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,6 @@ require 'bundler'
3
3
 
4
4
  require 'dotenv'
5
5
  require 'webmock/rspec'
6
- require 'em-websocket'
7
6
  require 'rack'
8
7
 
9
8
  Dotenv.load '.env.test'
@@ -1,48 +1,75 @@
1
+ require "socket"
2
+
1
3
  class LocalPusher
2
4
  attr_reader :connections
3
5
 
4
6
  def initialize
5
- @connections = []
7
+ mutex.synchronize do
8
+ @connections = []
9
+ @alive = true
10
+ end
6
11
  end
7
12
 
8
13
  def start
14
+ Thread.report_on_exception = false
9
15
  @server_thread ||= Thread.new do
10
- EM.run { socket_server }
16
+ socket_server
11
17
  end
12
18
  end
13
19
 
14
20
  def stop
15
- server_thread.kill
21
+ mutex.synchronize do
22
+ connections.each(&:close)
23
+ @alive = false
24
+ end
25
+
26
+ server_thread.join(5)
16
27
  end
17
28
 
18
29
  def send(event, data)
19
- connections.each do |connection|
20
- connection.send({
21
- 'event' => event,
22
- 'data' => data.to_json,
23
- 'channel' => ENV['FLYING_SPHINX_IDENTIFIER']
24
- }.to_json)
30
+ mutex.synchronize do
31
+ connections.each do |connection|
32
+ connection.write_json(
33
+ 'event' => event,
34
+ 'data' => data.to_json,
35
+ 'channel' => ENV['FLYING_SPHINX_IDENTIFIER']
36
+ )
37
+ end
25
38
  end
26
39
  end
27
40
 
28
41
  private
29
42
 
30
- attr_reader :server_thread
43
+ attr_reader :server_thread, :alive
44
+
45
+ def mutex
46
+ @mutex ||= Mutex.new
47
+ end
31
48
 
32
49
  def socket_server
33
- EM::WebSocket.run(
34
- :host => ENV['FLYING_SPHINX_SOCKETS_HOST'],
35
- :port => ENV['FLYING_SPHINX_SOCKETS_PORT']
36
- ) do |connection|
37
- connection.onopen do |handshake|
38
- connections << connection
39
- connection.send({
40
- 'event' => 'pusher:connection_established',
41
- 'data' => {'socket_id' => 101}.to_json
42
- }.to_json)
43
- end
50
+ server = TCPServer.new(
51
+ ENV['FLYING_SPHINX_SOCKETS_HOST'],
52
+ ENV['FLYING_SPHINX_SOCKETS_PORT'].to_i
53
+ )
44
54
 
45
- connection.onclose { connections.delete connection }
55
+ loop do
56
+ break unless mutex.synchronize { alive }
57
+ connection = LocalPusherConnection.new(server.accept_nonblock)
58
+ mutex.synchronize { connections << connection }
59
+
60
+ loop do
61
+ break unless mutex.synchronize { alive }
62
+ connection.parse
63
+ end
64
+ rescue IO::WaitReadable, Errno::EINTR
65
+ IO.select([server])
66
+ retry
46
67
  end
68
+ rescue Errno::EADDRINUSE
69
+ puts "Socket failure, retrying..."
70
+ sleep 1
71
+ retry
72
+ ensure
73
+ server.close
47
74
  end
48
75
  end
@@ -0,0 +1,40 @@
1
+ require "websocket/driver"
2
+
3
+ class LocalPusherConnection
4
+ def initialize(socket)
5
+ @socket = socket
6
+
7
+ driver.on :connect, -> (event) do
8
+ driver.start
9
+ write_json(
10
+ 'event' => 'pusher:connection_established',
11
+ 'data' => {'socket_id' => 101}.to_json
12
+ )
13
+ end
14
+ end
15
+
16
+ def close
17
+ socket.close
18
+ end
19
+
20
+ def parse
21
+ driver.parse(socket.gets)
22
+ rescue IOError
23
+ end
24
+
25
+ def write(string)
26
+ socket.write(string)
27
+ end
28
+
29
+ def write_json(object)
30
+ driver.text(object.to_json)
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :socket
36
+
37
+ def driver
38
+ @driver ||= WebSocket::Driver.server(self)
39
+ end
40
+ end
@@ -8,6 +8,7 @@ class SuccessfulAction
8
8
 
9
9
  def matches?(block)
10
10
  pusher.start
11
+ Thread.report_on_exception = false
11
12
  thread = Thread.new { call block }
12
13
  sleep 1.5
13
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flying-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ey-hmac
@@ -16,42 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: '2.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.2'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.7'
33
+ version: '2'
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: '0.7'
40
+ version: '2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday-multipart
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: gzipped_tar
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 0.1.1
61
+ version: 0.1.2
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: 0.1.1
68
+ version: 0.1.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: multi_json
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0.3'
89
+ version: '0.6'
76
90
  type: :runtime
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: '0.3'
96
+ version: '0.6'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: thinking-sphinx
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -100,54 +114,40 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '2.2'
117
+ version: '2.4'
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'
124
+ version: '2.4'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: dotenv
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: 0.11.1
131
+ version: '2.7'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: 0.11.1
125
- - !ruby/object:Gem::Dependency
126
- name: em-websocket
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 0.5.1
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.5.1
138
+ version: '2.7'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: mysql2
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: 0.3.15
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.3.15
153
153
  - !ruby/object:Gem::Dependency
@@ -198,14 +198,28 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 1.17.4
201
+ version: '3.14'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 1.17.4
208
+ version: '3.14'
209
+ - !ruby/object:Gem::Dependency
210
+ name: websocket-driver
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
209
223
  description: Hooks Thinking Sphinx into the Flying Sphinx service
210
224
  email: pat@freelancing-gods.com
211
225
  executables:
@@ -215,8 +229,8 @@ extra_rdoc_files:
215
229
  - README.textile
216
230
  files:
217
231
  - ".env.test"
232
+ - ".github/workflows/ci.yml"
218
233
  - ".gitignore"
219
- - ".travis.yml"
220
234
  - Appraisals
221
235
  - CHANGELOG.markdown
222
236
  - Gemfile
@@ -285,12 +299,13 @@ files:
285
299
  - spec/support/command_helpers.rb
286
300
  - spec/support/hmac.rb
287
301
  - spec/support/local_pusher.rb
302
+ - spec/support/local_pusher_connection.rb
288
303
  - spec/support/multipart.rb
289
304
  - spec/support/successful_action.rb
290
305
  homepage: https://flying-sphinx.com
291
306
  licenses: []
292
307
  metadata: {}
293
- post_install_message:
308
+ post_install_message:
294
309
  rdoc_options: []
295
310
  require_paths:
296
311
  - lib
@@ -305,9 +320,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
320
  - !ruby/object:Gem::Version
306
321
  version: '0'
307
322
  requirements: []
308
- rubyforge_project:
309
- rubygems_version: 2.7.6
310
- signing_key:
323
+ rubygems_version: 3.2.32
324
+ signing_key:
311
325
  specification_version: 4
312
326
  summary: Sphinx in the Cloud
313
327
  test_files:
@@ -335,5 +349,6 @@ test_files:
335
349
  - spec/support/command_helpers.rb
336
350
  - spec/support/hmac.rb
337
351
  - spec/support/local_pusher.rb
352
+ - spec/support/local_pusher_connection.rb
338
353
  - spec/support/multipart.rb
339
354
  - spec/support/successful_action.rb
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.10
4
- - 2.3.7
5
- - 2.4.4
6
- - 2.5.1
7
- before_install:
8
- - gem install bundler
9
- - gem update --system
10
- before_script:
11
- - bundle exec appraisal install
12
- cache: bundler
13
- script: bundle exec appraisal rspec