flying-sphinx 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,3 +1,6 @@
1
+ 0.6.2 - 2nd January 2012
2
+ * Pass Sphinx version through to Flying Sphinx servers.
3
+
1
4
  0.6.1 - 4th November 2011
2
5
  * Adding Riddle dependency requirement.
3
6
  * Updating indexes (index plural) references to indices.
@@ -33,10 +33,10 @@ class FlyingSphinx::IndexRequest
33
33
  update_sphinx_reference_files
34
34
  index
35
35
  end
36
-
36
+
37
37
  def status_message
38
38
  raise "Index Request failed to start. Something's not right!" if @index_id.nil?
39
-
39
+
40
40
  status = request_status
41
41
  case status
42
42
  when 'FINISHED'
@@ -67,9 +67,11 @@ class FlyingSphinx::IndexRequest
67
67
  end
68
68
 
69
69
  def update_sphinx_configuration
70
- api.put('/', :configuration => configuration.sphinx_configuration)
70
+ api.put '/',
71
+ :configuration => configuration.sphinx_configuration,
72
+ :sphinx_version => ThinkingSphinx::Configuration.instance.version
71
73
  end
72
-
74
+
73
75
  def update_sphinx_reference_files
74
76
  FlyingSphinx::Configuration::FileSettings.each do |setting|
75
77
  configuration.file_setting_pairs(setting).each do |local, remote|
@@ -94,22 +96,22 @@ class FlyingSphinx::IndexRequest
94
96
  rescue RuntimeError => err
95
97
  puts err.message
96
98
  end
97
-
99
+
98
100
  def tunnelled_index
99
101
  FlyingSphinx::Tunnel.connect(configuration) do
100
102
  begin_request unless request_begun?
101
-
103
+
102
104
  true
103
105
  end
104
106
  end
105
-
107
+
106
108
  def direct_index
107
109
  begin_request
108
110
  while !request_complete?
109
111
  sleep 1
110
112
  end
111
113
  end
112
-
114
+
113
115
  def begin_request
114
116
  response = api.post 'indices', :indices => indices.join(',')
115
117
 
@@ -118,11 +120,11 @@ class FlyingSphinx::IndexRequest
118
120
 
119
121
  raise RuntimeError, 'Your account does not support delta indexing. Upgrading plans is probably the best way around this.' if response.body.status == 'BLOCKED'
120
122
  end
121
-
123
+
122
124
  def request_begun?
123
125
  @request_begun
124
126
  end
125
-
127
+
126
128
  def request_complete?
127
129
  case request_status
128
130
  when 'FINISHED', 'FAILED'
@@ -133,7 +135,7 @@ class FlyingSphinx::IndexRequest
133
135
  raise "Unknown index response: '#{response.body}'"
134
136
  end
135
137
  end
136
-
138
+
137
139
  def request_status
138
140
  api.get("indices/#{index_id}").body.status
139
141
  end
@@ -150,7 +152,7 @@ class FlyingSphinx::IndexRequest
150
152
  def api
151
153
  configuration.api
152
154
  end
153
-
155
+
154
156
  def log?
155
157
  ENV['VERBOSE_LOGGING'] && ENV['VERBOSE_LOGGING'].length > 0
156
158
  end
@@ -1,3 +1,3 @@
1
1
  module FlyingSphinx
2
- Version = '0.6.1'
2
+ Version = '0.6.2'
3
3
  end
@@ -6,60 +6,66 @@ describe FlyingSphinx::IndexRequest do
6
6
  stub(:configuration, :api => api, :sphinx_configuration => 'foo {}',
7
7
  :file_setting_pairs => {})
8
8
  }
9
-
9
+
10
10
  let(:index_response) {
11
11
  stub(:response, :body => stub(:body, :id => 42, :status => 'OK'))
12
12
  }
13
13
  let(:blocked_response) {
14
14
  stub(:response, :body => stub(:body, :id => nil, :status => 'BLOCKED'))
15
15
  }
16
-
16
+
17
17
  before :each do
18
18
  ThinkingSphinx.database_adapter = FlyingSphinx::HerokuSharedAdapter
19
-
19
+
20
20
  FlyingSphinx::Configuration.stub!(:new => configuration)
21
21
  FlyingSphinx::Tunnel.stub(:connect) { |config, block| block.call }
22
22
  end
23
-
23
+
24
24
  describe '.cancel_jobs' do
25
25
  before :each do
26
26
  Delayed::Job.stub!(:delete_all => true)
27
27
  end
28
-
28
+
29
29
  it "should not delete any rows if the delayed_jobs table does not exist" do
30
30
  Delayed::Job.stub!(:table_exists? => false)
31
31
  Delayed::Job.should_not_receive(:delete_all)
32
-
32
+
33
33
  FlyingSphinx::IndexRequest.cancel_jobs
34
34
  end
35
-
35
+
36
36
  it "should delete rows if the delayed_jobs table does exist" do
37
37
  Delayed::Job.stub!(:table_exists? => true)
38
38
  Delayed::Job.should_receive(:delete_all)
39
-
39
+
40
40
  FlyingSphinx::IndexRequest.cancel_jobs
41
41
  end
42
-
42
+
43
43
  it "should delete only Thinking Sphinx jobs" do
44
44
  Delayed::Job.stub!(:table_exists? => true)
45
45
  Delayed::Job.should_receive(:delete_all) do |sql|
46
46
  sql.should match(/handler LIKE '--- !ruby\/object:FlyingSphinx::\%'/)
47
47
  end
48
-
48
+
49
49
  FlyingSphinx::IndexRequest.cancel_jobs
50
50
  end
51
51
  end
52
-
52
+
53
53
  describe '#update_and_index' do
54
54
  let(:index_request) { FlyingSphinx::IndexRequest.new }
55
- let(:conf_params) { { :configuration => 'foo {}' } }
55
+ let(:conf_params) { { :configuration => 'foo {}',
56
+ :sphinx_version => '2.1.0-dev' } }
56
57
  let(:index_params) { { :indices => '' } }
57
-
58
+ let(:ts_config) { double('config', :version => '2.1.0-dev') }
59
+
60
+ before :each do
61
+ ThinkingSphinx::Configuration.stub :instance => ts_config
62
+ end
63
+
58
64
  it "makes a new request" do
59
65
  api.should_receive(:put).with('/', conf_params).and_return('ok')
60
66
  api.should_receive(:post).
61
67
  with('indices', index_params).and_return(index_response)
62
-
68
+
63
69
  begin
64
70
  Timeout::timeout(0.2) {
65
71
  index_request.update_and_index
@@ -67,7 +73,7 @@ describe FlyingSphinx::IndexRequest do
67
73
  rescue Timeout::Error
68
74
  end
69
75
  end
70
-
76
+
71
77
  [
72
78
  :stopwords, :wordforms, :exceptions, :mysql_ssl_cert, :mysql_ssl_key,
73
79
  :mysql_ssl_ca
@@ -76,22 +82,22 @@ describe FlyingSphinx::IndexRequest do
76
82
  let(:file_params) {
77
83
  {:setting => setting.to_s, :file_name => 'bar.txt', :content => 'baz'}
78
84
  }
79
-
85
+
80
86
  before :each do
81
87
  configuration.stub!(:file_setting_pairs => {})
82
88
  index_request.stub!(:open => double('file', :read => 'baz'))
83
89
  end
84
-
90
+
85
91
  it "sends the #{setting} file" do
86
92
  api.should_receive(:put).with('/', conf_params).and_return('ok')
87
93
  api.should_receive(:post).with('/add_file', file_params).
88
94
  and_return('ok')
89
95
  api.should_receive(:post).
90
96
  with('indices', index_params).and_return(index_response)
91
-
97
+
92
98
  configuration.should_receive(:file_setting_pairs).
93
99
  with(setting).and_return({'foo.txt' => 'bar.txt'})
94
-
100
+
95
101
  begin
96
102
  Timeout::timeout(0.2) {
97
103
  index_request.update_and_index
@@ -101,7 +107,7 @@ describe FlyingSphinx::IndexRequest do
101
107
  end
102
108
  end
103
109
  end
104
-
110
+
105
111
  context 'delta request without delta support' do
106
112
  it "should explain why the request failed" do
107
113
  api.should_receive(:put).
@@ -114,38 +120,38 @@ describe FlyingSphinx::IndexRequest do
114
120
  index_request.update_and_index
115
121
  end
116
122
  end
117
-
123
+
118
124
  context 'request for a MySQL database' do
119
125
  before :each do
120
126
  ThinkingSphinx.database_adapter = nil
121
127
  end
122
-
128
+
123
129
  after :each do
124
130
  ThinkingSphinx.database_adapter = FlyingSphinx::HerokuSharedAdapter
125
131
  end
126
-
132
+
127
133
  it "should not establish an SSH connection" do
128
134
  FlyingSphinx::Tunnel.should_not_receive(:connect)
129
-
135
+
130
136
  api.should_receive(:put).with('/', conf_params).and_return('ok')
131
137
  api.should_receive(:post).
132
138
  with('indices', index_params).and_return(index_response)
133
139
  api.should_receive(:get).with('indices/42').
134
140
  and_return(stub(:response, :body => stub(:body, :status => 'FINISHED')))
135
-
141
+
136
142
  index_request.update_and_index
137
143
  end
138
144
  end
139
145
  end
140
-
146
+
141
147
  describe '#perform' do
142
148
  let(:index_request) { FlyingSphinx::IndexRequest.new ['foo_delta'] }
143
149
  let(:index_params) { { :indices => 'foo_delta' } }
144
-
150
+
145
151
  it "makes a new request" do
146
152
  api.should_receive(:post).
147
153
  with('indices', index_params).and_return(index_response)
148
-
154
+
149
155
  begin
150
156
  Timeout::timeout(0.2) {
151
157
  index_request.perform
@@ -154,7 +160,7 @@ describe FlyingSphinx::IndexRequest do
154
160
  end
155
161
  end
156
162
  end
157
-
163
+
158
164
  describe '#status_message' do
159
165
  let(:index_request) { FlyingSphinx::IndexRequest.new }
160
166
  let(:finished_response) {
@@ -169,51 +175,51 @@ describe FlyingSphinx::IndexRequest do
169
175
  let(:unknown_response) {
170
176
  stub(:response, :body => stub(:body, :status => 'UNKNOWN'))
171
177
  }
172
-
178
+
173
179
  before :each do
174
180
  api.stub(:post => index_response)
175
-
181
+
176
182
  index_request.instance_variable_set :@index_id, 42
177
183
  end
178
-
184
+
179
185
  it "returns with a positive message on success" do
180
186
  api.stub(:get => finished_response)
181
-
187
+
182
188
  index_request.status_message.should == 'Index Request has completed.'
183
189
  end
184
-
190
+
185
191
  it "returns with a failure message on failure" do
186
192
  api.stub(:get => failure_response)
187
-
193
+
188
194
  index_request.status_message.should == 'Index Request failed.'
189
195
  end
190
-
196
+
191
197
  it "warns the user if the request is still pending" do
192
198
  api.stub(:get => pending_response)
193
-
199
+
194
200
  index_request.status_message.should == 'Index Request is still pending - something has gone wrong.'
195
201
  end
196
-
202
+
197
203
  it "treats all other statuses as unknown" do
198
204
  api.stub(:get => unknown_response)
199
-
205
+
200
206
  index_request.status_message.should == "Unknown index response: 'UNKNOWN'."
201
207
  end
202
-
208
+
203
209
  it "raises a warning if the index id isn't set" do
204
210
  index_request.instance_variable_set :@index_id, nil
205
-
211
+
206
212
  lambda {
207
213
  index_request.status_message
208
214
  }.should raise_error
209
215
  end
210
216
  end
211
-
217
+
212
218
  describe "#display_name" do
213
219
  let(:index_request) {
214
220
  FlyingSphinx::IndexRequest.new ['foo_core', 'bar_core']
215
221
  }
216
-
222
+
217
223
  it "should display class name with all indexes" do
218
224
  index_request.display_name.should == "FlyingSphinx::IndexRequest for foo_core, bar_core"
219
225
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flying-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Allan
@@ -15,12 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-04 00:00:00 +02:00
18
+ date: 2012-01-02 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: thinking-sphinx
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
25
26
  requirements:
26
27
  - - ">="
@@ -30,11 +31,11 @@ dependencies:
30
31
  - 0
31
32
  version: "0"
32
33
  type: :runtime
33
- prerelease: false
34
- requirement: *id001
34
+ version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: riddle
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
38
39
  none: false
39
40
  requirements:
40
41
  - - ">="
@@ -46,11 +47,11 @@ dependencies:
46
47
  - 0
47
48
  version: 1.5.0
48
49
  type: :runtime
49
- prerelease: false
50
- requirement: *id002
50
+ version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: net-ssh
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
54
55
  none: false
55
56
  requirements:
56
57
  - - ">="
@@ -62,11 +63,11 @@ dependencies:
62
63
  - 23
63
64
  version: 2.0.23
64
65
  type: :runtime
65
- prerelease: false
66
- requirement: *id003
66
+ version_requirements: *id003
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: multi_json
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
70
71
  none: false
71
72
  requirements:
72
73
  - - ~>
@@ -78,11 +79,11 @@ dependencies:
78
79
  - 1
79
80
  version: 1.0.1
80
81
  type: :runtime
81
- prerelease: false
82
- requirement: *id004
82
+ version_requirements: *id004
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: faraday_middleware
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
86
87
  none: false
87
88
  requirements:
88
89
  - - ~>
@@ -94,11 +95,11 @@ dependencies:
94
95
  - 0
95
96
  version: 0.7.0
96
97
  type: :runtime
97
- prerelease: false
98
- requirement: *id005
98
+ version_requirements: *id005
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: rash
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
102
103
  none: false
103
104
  requirements:
104
105
  - - ~>
@@ -110,11 +111,11 @@ dependencies:
110
111
  - 0
111
112
  version: 0.3.0
112
113
  type: :runtime
113
- prerelease: false
114
- requirement: *id006
114
+ version_requirements: *id006
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: rake
117
- version_requirements: &id007 !ruby/object:Gem::Requirement
117
+ prerelease: false
118
+ requirement: &id007 !ruby/object:Gem::Requirement
118
119
  none: false
119
120
  requirements:
120
121
  - - "="
@@ -126,11 +127,11 @@ dependencies:
126
127
  - 7
127
128
  version: 0.8.7
128
129
  type: :development
129
- prerelease: false
130
- requirement: *id007
130
+ version_requirements: *id007
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: yajl-ruby
133
- version_requirements: &id008 !ruby/object:Gem::Requirement
133
+ prerelease: false
134
+ requirement: &id008 !ruby/object:Gem::Requirement
134
135
  none: false
135
136
  requirements:
136
137
  - - ~>
@@ -142,11 +143,11 @@ dependencies:
142
143
  - 2
143
144
  version: 0.8.2
144
145
  type: :development
145
- prerelease: false
146
- requirement: *id008
146
+ version_requirements: *id008
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: rspec
149
- version_requirements: &id009 !ruby/object:Gem::Requirement
149
+ prerelease: false
150
+ requirement: &id009 !ruby/object:Gem::Requirement
150
151
  none: false
151
152
  requirements:
152
153
  - - ~>
@@ -158,11 +159,11 @@ dependencies:
158
159
  - 0
159
160
  version: 2.5.0
160
161
  type: :development
161
- prerelease: false
162
- requirement: *id009
162
+ version_requirements: *id009
163
163
  - !ruby/object:Gem::Dependency
164
164
  name: rcov
165
- version_requirements: &id010 !ruby/object:Gem::Requirement
165
+ prerelease: false
166
+ requirement: &id010 !ruby/object:Gem::Requirement
166
167
  none: false
167
168
  requirements:
168
169
  - - ~>
@@ -174,11 +175,11 @@ dependencies:
174
175
  - 9
175
176
  version: 0.9.9
176
177
  type: :development
177
- prerelease: false
178
- requirement: *id010
178
+ version_requirements: *id010
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: fakeweb
181
- version_requirements: &id011 !ruby/object:Gem::Requirement
181
+ prerelease: false
182
+ requirement: &id011 !ruby/object:Gem::Requirement
182
183
  none: false
183
184
  requirements:
184
185
  - - ~>
@@ -190,11 +191,11 @@ dependencies:
190
191
  - 0
191
192
  version: 1.3.0
192
193
  type: :development
193
- prerelease: false
194
- requirement: *id011
194
+ version_requirements: *id011
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: fakeweb-matcher
197
- version_requirements: &id012 !ruby/object:Gem::Requirement
197
+ prerelease: false
198
+ requirement: &id012 !ruby/object:Gem::Requirement
198
199
  none: false
199
200
  requirements:
200
201
  - - ~>
@@ -206,11 +207,11 @@ dependencies:
206
207
  - 2
207
208
  version: 1.2.2
208
209
  type: :development
209
- prerelease: false
210
- requirement: *id012
210
+ version_requirements: *id012
211
211
  - !ruby/object:Gem::Dependency
212
212
  name: delayed_job
213
- version_requirements: &id013 !ruby/object:Gem::Requirement
213
+ prerelease: false
214
+ requirement: &id013 !ruby/object:Gem::Requirement
214
215
  none: false
215
216
  requirements:
216
217
  - - ~>
@@ -222,8 +223,7 @@ dependencies:
222
223
  - 4
223
224
  version: 2.1.4
224
225
  type: :development
225
- prerelease: false
226
- requirement: *id013
226
+ version_requirements: *id013
227
227
  description: Hooks Thinking Sphinx into the Flying Sphinx service
228
228
  email: pat@freelancing-gods.com
229
229
  executables: []