flying-sphinx 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/HISTORY +3 -0
- data/README.textile +1 -1
- data/lib/flying_sphinx.rb +2 -0
- data/lib/flying_sphinx/api.rb +3 -2
- data/lib/flying_sphinx/configuration_options.rb +29 -0
- data/lib/flying_sphinx/controller.rb +3 -19
- data/lib/flying_sphinx/gzipped_hash.rb +33 -0
- data/lib/flying_sphinx/version.rb +1 -1
- data/spec/specs/controller_spec.rb +61 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmFjZTkzNjBhNTJjNTBlYzI1ZmE4ODNlNDZmNTViMTk5MWM4ZmExNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Zjg1ZTkzYTM0MDE0ODcyYTg0ODBlMDZlMjQwNmI0ZGIyM2E2ODg3ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2MxZWNkYzYzOTE4ZDVhNDc1YTIyMDcwNzA3M2Q4OTIwMjlmMTViMTU1M2Vj
|
10
|
+
OWQ5MjdlNWQ1M2MxNTM4YzUyYWJlNDNhOWE3MzE4ZTJhMGFhM2QyOTU3ZGJm
|
11
|
+
YjFkZjg2MzkxYjBkZTY2YWM4YTAxOGQ3ODVjMzkyZTE5OTRiOTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDUzYTA3ZjVmZTQwZmNiMDk4NjVhNTE5ZTExMjE4NmE5ZGRiYjA5ODUyNWRi
|
14
|
+
MGEyOGM1ZjUzYmYxYjY2YzJlMTdhMWI5ZDIzMjc0MzUwNDBlZjlkOGIxYzUw
|
15
|
+
Mzk0N2Q2YzY2MGJmZTA3OGNlYzMwMDk0NzZmOTQwNTNlYWJhNzk=
|
data/HISTORY
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
1.2.0 - 30th March 2014
|
2
|
+
* All configuration files (Sphinx, wordforms, exceptions, etc) are now gzipped when sent to the API.
|
3
|
+
|
1
4
|
1.1.0 - 15th March 2014
|
2
5
|
* Updated Faraday dependency to require 0.9 or newer (and removed faraday_middleware dependency).
|
3
6
|
* Added remote rotate support via custom controller.
|
data/README.textile
CHANGED
@@ -9,7 +9,7 @@ This is all covered pretty well on "the Flying Sphinx site":http://flying-sphinx
|
|
9
9
|
<pre><code>gem 'flying-sphinx',
|
10
10
|
:git => 'git://github.com/flying-sphinx/flying-sphinx.git',
|
11
11
|
:branch => 'master',
|
12
|
-
:ref => '
|
12
|
+
:ref => '6b691c2b43'</code></pre>
|
13
13
|
|
14
14
|
h2. Compatibility and Limitations
|
15
15
|
|
data/lib/flying_sphinx.rb
CHANGED
@@ -41,7 +41,9 @@ require 'flying_sphinx/api'
|
|
41
41
|
require 'flying_sphinx/binary'
|
42
42
|
require 'flying_sphinx/cli'
|
43
43
|
require 'flying_sphinx/configuration'
|
44
|
+
require 'flying_sphinx/configuration_options'
|
44
45
|
require 'flying_sphinx/controller'
|
46
|
+
require 'flying_sphinx/gzipped_hash'
|
45
47
|
require 'flying_sphinx/setting_files'
|
46
48
|
require 'flying_sphinx/sphinxql'
|
47
49
|
require 'flying_sphinx/version'
|
data/lib/flying_sphinx/api.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class FlyingSphinx::ConfigurationOptions
|
2
|
+
def to_hash
|
3
|
+
{:sphinx_version => version, :configuration => gzipped_files_hash}
|
4
|
+
end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def configuration
|
9
|
+
@configuration ||= ThinkingSphinx::Configuration.instance
|
10
|
+
end
|
11
|
+
|
12
|
+
def files_hash
|
13
|
+
FlyingSphinx::SettingFiles.new.to_hash.merge(
|
14
|
+
'sphinx' => FlyingSphinx.translator.sphinx_configuration
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def gzipped_files_hash
|
19
|
+
FlyingSphinx::GzippedHash.new(files_hash).to_gzipped_hash
|
20
|
+
end
|
21
|
+
|
22
|
+
def version
|
23
|
+
version_defined? ? configuration.version : '2.0.4'
|
24
|
+
end
|
25
|
+
|
26
|
+
def version_defined?
|
27
|
+
configuration.respond_to?(:version) && configuration.version.present?
|
28
|
+
end
|
29
|
+
end
|
@@ -17,7 +17,7 @@ class FlyingSphinx::Controller
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def configure(file = nil)
|
20
|
-
options = file.nil? ?
|
20
|
+
options = file.nil? ? FlyingSphinx::ConfigurationOptions.new.to_hash :
|
21
21
|
{:configuration => {'sphinx' => file}, :sphinx_version => '2.0.6'}
|
22
22
|
|
23
23
|
FlyingSphinx::Action.perform api.identifier do
|
@@ -47,7 +47,7 @@ class FlyingSphinx::Controller
|
|
47
47
|
|
48
48
|
def rebuild
|
49
49
|
FlyingSphinx::Action.perform api.identifier, self.class.index_timeout do
|
50
|
-
api.put 'rebuild',
|
50
|
+
api.put 'rebuild', FlyingSphinx::ConfigurationOptions.new.to_hash
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -58,7 +58,7 @@ class FlyingSphinx::Controller
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def reset(file = nil)
|
61
|
-
options = file.nil? ?
|
61
|
+
options = file.nil? ? FlyingSphinx::ConfigurationOptions.new.to_hash :
|
62
62
|
{:configuration => {'sphinx' => file}, :sphinx_version => '2.0.6'}
|
63
63
|
|
64
64
|
FlyingSphinx::Action.perform api.identifier do
|
@@ -93,20 +93,4 @@ class FlyingSphinx::Controller
|
|
93
93
|
private
|
94
94
|
|
95
95
|
attr_reader :api
|
96
|
-
|
97
|
-
def configuration_options
|
98
|
-
version = '2.0.4'
|
99
|
-
configuration = ThinkingSphinx::Configuration.instance
|
100
|
-
|
101
|
-
if configuration.respond_to?(:version) && configuration.version.present?
|
102
|
-
version = configuration.version
|
103
|
-
end
|
104
|
-
|
105
|
-
{
|
106
|
-
:sphinx_version => version,
|
107
|
-
:configuration => FlyingSphinx::SettingFiles.new.to_hash.merge(
|
108
|
-
'sphinx' => FlyingSphinx.translator.sphinx_configuration
|
109
|
-
)
|
110
|
-
}
|
111
|
-
end
|
112
96
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
|
3
|
+
class FlyingSphinx::GzippedHash
|
4
|
+
def initialize(hash)
|
5
|
+
@hash = hash
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_gzipped_hash
|
9
|
+
hash['gzip'] = 'true'
|
10
|
+
|
11
|
+
keys.each { |key| hash[key] = gzip hash[key] }
|
12
|
+
|
13
|
+
hash
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :hash
|
19
|
+
|
20
|
+
def keys
|
21
|
+
keys = (hash['extra'] || '').split(';')
|
22
|
+
keys << 'sphinx' if hash['sphinx']
|
23
|
+
keys
|
24
|
+
end
|
25
|
+
|
26
|
+
def gzip(string)
|
27
|
+
io = StringIO.new 'w'
|
28
|
+
writer = Zlib::GzipWriter.new io
|
29
|
+
writer.write string
|
30
|
+
writer.close
|
31
|
+
Faraday::UploadIO.new StringIO.new(io.string, 'rb'), 'application/gzip'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'light_spec_helper'
|
2
|
+
require 'faraday'
|
3
|
+
require 'flying_sphinx/controller'
|
4
|
+
require 'flying_sphinx/configuration_options'
|
5
|
+
require 'flying_sphinx/gzipped_hash'
|
6
|
+
|
7
|
+
describe FlyingSphinx::Controller do
|
8
|
+
let(:controller) { FlyingSphinx::Controller.new api }
|
9
|
+
let(:api) { double 'API', :identifier => 'foo', :put => true }
|
10
|
+
let(:action_class) { double }
|
11
|
+
let(:configuration) { double 'TS Configuration' }
|
12
|
+
let(:setting_files) { double :to_hash => {'extra' => 'wordforms:txt.txt',
|
13
|
+
'wordforms:txt.txt' => 'something'} }
|
14
|
+
let(:translator) { double :sphinx_configuration => 'indexer ...' }
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
stub_const 'FlyingSphinx::Action', action_class
|
18
|
+
action_class.stub(:perform) do |identifier, &block|
|
19
|
+
block.call
|
20
|
+
end
|
21
|
+
|
22
|
+
stub_const 'ThinkingSphinx::Configuration',
|
23
|
+
double(:instance => configuration)
|
24
|
+
|
25
|
+
stub_const 'FlyingSphinx::SettingFiles', double(:new => setting_files)
|
26
|
+
FlyingSphinx.stub :translator => translator
|
27
|
+
end
|
28
|
+
|
29
|
+
def ungzip(contents)
|
30
|
+
io = StringIO.new contents, 'rb'
|
31
|
+
reader = Zlib::GzipReader.new io
|
32
|
+
reader.read
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'configure' do
|
36
|
+
it 'sends data to the server' do
|
37
|
+
api.should_receive(:put)
|
38
|
+
|
39
|
+
controller.configure
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'sends through gzipped configuration files' do
|
43
|
+
api.should_receive(:put) do |path, options|
|
44
|
+
path.should == 'configure'
|
45
|
+
options[:configuration]['gzip'].should == 'true'
|
46
|
+
ungzip(options[:configuration]['sphinx'].read).should == 'indexer ...'
|
47
|
+
ungzip(options[:configuration]['wordforms:txt.txt'].read).should == 'something'
|
48
|
+
end
|
49
|
+
|
50
|
+
controller.configure
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'sends through file if provided' do
|
54
|
+
api.should_receive(:put).with 'configure',
|
55
|
+
:configuration => {'sphinx' => 'searchd ...'},
|
56
|
+
:sphinx_version => '2.0.6'
|
57
|
+
|
58
|
+
controller.configure 'searchd ...'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thinking-sphinx
|
@@ -190,7 +190,9 @@ files:
|
|
190
190
|
- lib/flying_sphinx/binary/translator.rb
|
191
191
|
- lib/flying_sphinx/cli.rb
|
192
192
|
- lib/flying_sphinx/configuration.rb
|
193
|
+
- lib/flying_sphinx/configuration_options.rb
|
193
194
|
- lib/flying_sphinx/controller.rb
|
195
|
+
- lib/flying_sphinx/gzipped_hash.rb
|
194
196
|
- lib/flying_sphinx/rails.rb
|
195
197
|
- lib/flying_sphinx/railtie.rb
|
196
198
|
- lib/flying_sphinx/setting_files.rb
|
@@ -204,6 +206,7 @@ files:
|
|
204
206
|
- spec/specs/action_spec.rb
|
205
207
|
- spec/specs/api_spec.rb
|
206
208
|
- spec/specs/configuration_spec.rb
|
209
|
+
- spec/specs/controller_spec.rb
|
207
210
|
- spec/specs/setting_files_spec.rb
|
208
211
|
homepage: https://flying-sphinx.com
|
209
212
|
licenses: []
|
@@ -235,4 +238,5 @@ test_files:
|
|
235
238
|
- spec/specs/action_spec.rb
|
236
239
|
- spec/specs/api_spec.rb
|
237
240
|
- spec/specs/configuration_spec.rb
|
241
|
+
- spec/specs/controller_spec.rb
|
238
242
|
- spec/specs/setting_files_spec.rb
|