tire 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,7 +100,7 @@ module Tire
100
100
  end
101
101
 
102
102
  should "perform the search" do
103
- response = stub(:body => '{"took":1,"hits":[]}', :code => 200)
103
+ response = mock_response '{"took":1,"hits":[]}', 200
104
104
  Configuration.client.expects(:get).returns(response)
105
105
  Results::Collection.expects(:new).returns([])
106
106
 
@@ -110,19 +110,20 @@ module Tire
110
110
  assert_not_nil s.response
111
111
  end
112
112
 
113
- should "print debugging information on exception and re-raise it" do
114
- Configuration.client.expects(:get).raises(RestClient::InternalServerError)
113
+ should "print debugging information on exception and return false" do
114
+ ::RestClient::Request.any_instance.
115
+ expects(:execute).
116
+ raises(::RestClient::InternalServerError)
115
117
  STDERR.expects(:puts)
116
118
 
117
119
  s = Search::Search.new('index')
118
- assert_raise(RestClient::InternalServerError) { s.perform }
120
+ assert ! s.perform
119
121
  end
120
122
 
121
123
  should "log request, but not response, when logger is set" do
122
124
  Configuration.logger STDERR
123
125
 
124
- response = stub(:body => '{"took":1,"hits":[]}', :code => 200)
125
- Configuration.client.expects(:get).returns(response)
126
+ Configuration.client.expects(:get).returns(mock_response( '{"took":1,"hits":[]}', 200 ))
126
127
 
127
128
  Results::Collection.expects(:new).returns([])
128
129
  Configuration.logger.expects(:log_request).returns(true)
@@ -25,7 +25,7 @@ module Tire
25
25
  should "allow searching with a Ruby Hash" do
26
26
  Tire::Configuration.client.expects(:post).
27
27
  with('http://localhost:9200/dummy/_search','{"query":{"query_string":{"query":"foo"}}}').
28
- returns( stub(:body => '{}') )
28
+ returns( mock_response('{}') )
29
29
  Tire::Results::Collection.expects(:new)
30
30
 
31
31
  Tire.search 'dummy', :query => { :query_string => { :query => 'foo' }}
@@ -34,7 +34,7 @@ module Tire
34
34
  should "allow searching with a JSON string" do
35
35
  Tire::Configuration.client.expects(:post).
36
36
  with('http://localhost:9200/dummy/_search','{"query":{"query_string":{"query":"foo"}}}').
37
- returns( stub(:body => '{}') )
37
+ returns( mock_response('{}') )
38
38
  Tire::Results::Collection.expects(:new)
39
39
 
40
40
  Tire.search 'dummy', '{"query":{"query_string":{"query":"foo"}}}'
metadata CHANGED
@@ -1,224 +1,196 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tire
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Karel Minarik
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-09-04 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-09-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 8
30
- - 0
16
+ requirement: &70278654851940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
31
21
  version: 0.8.0
32
22
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rest-client
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
24
+ version_requirements: *70278654851940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &70278654850560 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
39
30
  - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 6
44
- - 0
31
+ - !ruby/object:Gem::Version
45
32
  version: 1.6.0
46
33
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: multi_json
50
34
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
35
+ version_requirements: *70278654850560
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &70278654847700 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
53
41
  - - ~>
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 1
57
- - 0
58
- version: "1.0"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
59
44
  type: :runtime
60
- version_requirements: *id003
61
- - !ruby/object:Gem::Dependency
62
- name: activemodel
63
45
  prerelease: false
64
- requirement: &id004 !ruby/object:Gem::Requirement
65
- requirements:
46
+ version_requirements: *70278654847700
47
+ - !ruby/object:Gem::Dependency
48
+ name: activemodel
49
+ requirement: &70278654860600 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
66
52
  - - ~>
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 3
70
- - 0
71
- version: "3.0"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
72
55
  type: :runtime
73
- version_requirements: *id004
74
- - !ruby/object:Gem::Dependency
75
- name: bundler
76
56
  prerelease: false
77
- requirement: &id005 !ruby/object:Gem::Requirement
78
- requirements:
57
+ version_requirements: *70278654860600
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &70278654857400 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
79
63
  - - ~>
80
- - !ruby/object:Gem::Version
81
- segments:
82
- - 1
83
- - 0
84
- - 0
64
+ - !ruby/object:Gem::Version
85
65
  version: 1.0.0
86
66
  type: :development
87
- version_requirements: *id005
88
- - !ruby/object:Gem::Dependency
89
- name: yajl-ruby
90
67
  prerelease: false
91
- requirement: &id006 !ruby/object:Gem::Requirement
92
- requirements:
68
+ version_requirements: *70278654857400
69
+ - !ruby/object:Gem::Dependency
70
+ name: yajl-ruby
71
+ requirement: &70278654869180 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
93
74
  - - ~>
94
- - !ruby/object:Gem::Version
95
- segments:
96
- - 0
97
- - 8
98
- - 0
75
+ - !ruby/object:Gem::Version
99
76
  version: 0.8.0
100
77
  type: :development
101
- version_requirements: *id006
102
- - !ruby/object:Gem::Dependency
103
- name: shoulda
104
78
  prerelease: false
105
- requirement: &id007 !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
- version: "0"
79
+ version_requirements: *70278654869180
80
+ - !ruby/object:Gem::Dependency
81
+ name: shoulda
82
+ requirement: &70278654865940 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
112
88
  type: :development
113
- version_requirements: *id007
114
- - !ruby/object:Gem::Dependency
115
- name: mocha
116
89
  prerelease: false
117
- requirement: &id008 !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- segments:
122
- - 0
123
- version: "0"
90
+ version_requirements: *70278654865940
91
+ - !ruby/object:Gem::Dependency
92
+ name: mocha
93
+ requirement: &70278654863500 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
124
99
  type: :development
125
- version_requirements: *id008
126
- - !ruby/object:Gem::Dependency
127
- name: activerecord
128
100
  prerelease: false
129
- requirement: &id009 !ruby/object:Gem::Requirement
130
- requirements:
101
+ version_requirements: *70278654863500
102
+ - !ruby/object:Gem::Dependency
103
+ name: activerecord
104
+ requirement: &70278654877920 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
131
107
  - - ~>
132
- - !ruby/object:Gem::Version
133
- segments:
134
- - 3
135
- - 0
136
- - 7
108
+ - !ruby/object:Gem::Version
137
109
  version: 3.0.7
138
110
  type: :development
139
- version_requirements: *id009
140
- - !ruby/object:Gem::Dependency
141
- name: sqlite3
142
111
  prerelease: false
143
- requirement: &id010 !ruby/object:Gem::Requirement
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- segments:
148
- - 0
149
- version: "0"
112
+ version_requirements: *70278654877920
113
+ - !ruby/object:Gem::Dependency
114
+ name: sqlite3
115
+ requirement: &70278654876960 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
150
121
  type: :development
151
- version_requirements: *id010
152
- - !ruby/object:Gem::Dependency
153
- name: supermodel
154
122
  prerelease: false
155
- requirement: &id011 !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- segments:
160
- - 0
161
- version: "0"
123
+ version_requirements: *70278654876960
124
+ - !ruby/object:Gem::Dependency
125
+ name: supermodel
126
+ requirement: &70278654875960 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
162
132
  type: :development
163
- version_requirements: *id011
164
- - !ruby/object:Gem::Dependency
165
- name: sdoc
166
133
  prerelease: false
167
- requirement: &id012 !ruby/object:Gem::Requirement
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- segments:
172
- - 0
173
- version: "0"
134
+ version_requirements: *70278654875960
135
+ - !ruby/object:Gem::Dependency
136
+ name: sdoc
137
+ requirement: &70278654874800 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
174
143
  type: :development
175
- version_requirements: *id012
176
- - !ruby/object:Gem::Dependency
177
- name: rdoc
178
144
  prerelease: false
179
- requirement: &id013 !ruby/object:Gem::Requirement
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- segments:
184
- - 0
185
- version: "0"
145
+ version_requirements: *70278654874800
146
+ - !ruby/object:Gem::Dependency
147
+ name: rdoc
148
+ requirement: &70278654874180 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
186
154
  type: :development
187
- version_requirements: *id013
188
- - !ruby/object:Gem::Dependency
189
- name: rcov
190
155
  prerelease: false
191
- requirement: &id014 !ruby/object:Gem::Requirement
192
- requirements:
193
- - - ">="
194
- - !ruby/object:Gem::Version
195
- segments:
196
- - 0
197
- version: "0"
156
+ version_requirements: *70278654874180
157
+ - !ruby/object:Gem::Dependency
158
+ name: rcov
159
+ requirement: &70278654873460 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
198
165
  type: :development
199
- version_requirements: *id014
200
- - !ruby/object:Gem::Dependency
201
- name: turn
202
166
  prerelease: false
203
- requirement: &id015 !ruby/object:Gem::Requirement
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- segments:
208
- - 0
209
- version: "0"
167
+ version_requirements: *70278654873460
168
+ - !ruby/object:Gem::Dependency
169
+ name: turn
170
+ requirement: &70278654872820 !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
210
176
  type: :development
211
- version_requirements: *id015
212
- description: " Tire is a Ruby client for the ElasticSearch search engine/database.\n\n It provides Ruby-like API for fluent communication with the ElasticSearch server\n and blends with ActiveModel class for convenient usage in Rails applications.\n\n It allows to delete and create indices, define mapping for them, supports\n the bulk API, and presents an easy-to-use DSL for constructing your queries.\n\n It has full ActiveRecord/ActiveModel compatibility, allowing you to index\n your models (incrementally upon saving, or in bulk), searching and\n paginating the results.\n\n Please check the documentation at <http://karmi.github.com/tire/>.\n"
177
+ prerelease: false
178
+ version_requirements: *70278654872820
179
+ description: ! " Tire is a Ruby client for the ElasticSearch search engine/database.\n\n
180
+ \ It provides Ruby-like API for fluent communication with the ElasticSearch server\n
181
+ \ and blends with ActiveModel class for convenient usage in Rails applications.\n\n
182
+ \ It allows to delete and create indices, define mapping for them, supports\n the
183
+ bulk API, and presents an easy-to-use DSL for constructing your queries.\n\n It
184
+ has full ActiveRecord/ActiveModel compatibility, allowing you to index\n your
185
+ models (incrementally upon saving, or in bulk), searching and\n paginating the
186
+ results.\n\n Please check the documentation at <http://karmi.github.com/tire/>.\n"
213
187
  email: karmi@karmi.cz
214
188
  executables: []
215
-
216
189
  extensions: []
217
-
218
- extra_rdoc_files:
190
+ extra_rdoc_files:
219
191
  - README.markdown
220
192
  - MIT-LICENSE
221
- files:
193
+ files:
222
194
  - .gitignore
223
195
  - .travis.yml
224
196
  - Gemfile
@@ -228,9 +200,11 @@ files:
228
200
  - examples/rails-application-template.rb
229
201
  - examples/tire-dsl.rb
230
202
  - lib/tire.rb
231
- - lib/tire/client.rb
232
203
  - lib/tire/configuration.rb
233
204
  - lib/tire/dsl.rb
205
+ - lib/tire/http/client.rb
206
+ - lib/tire/http/clients/curb.rb
207
+ - lib/tire/http/response.rb
234
208
  - lib/tire/index.rb
235
209
  - lib/tire/logger.rb
236
210
  - lib/tire/model/callbacks.rb
@@ -276,6 +250,7 @@ files:
276
250
  - test/integration/sort_test.rb
277
251
  - test/models/active_model_article.rb
278
252
  - test/models/active_model_article_with_callbacks.rb
253
+ - test/models/active_model_article_with_custom_document_type.rb
279
254
  - test/models/active_model_article_with_custom_index_name.rb
280
255
  - test/models/active_record_models.rb
281
256
  - test/models/article.rb
@@ -285,8 +260,9 @@ files:
285
260
  - test/models/validated_model.rb
286
261
  - test/test_helper.rb
287
262
  - test/unit/active_model_lint_test.rb
288
- - test/unit/client_test.rb
289
263
  - test/unit/configuration_test.rb
264
+ - test/unit/http_client_test.rb
265
+ - test/unit/http_response_test.rb
290
266
  - test/unit/index_test.rb
291
267
  - test/unit/logger_test.rb
292
268
  - test/unit/model_callbacks_test.rb
@@ -304,72 +280,48 @@ files:
304
280
  - test/unit/search_test.rb
305
281
  - test/unit/tire_test.rb
306
282
  - tire.gemspec
307
- has_rdoc: true
308
283
  homepage: http://github.com/karmi/tire
309
284
  licenses: []
310
-
311
- post_install_message: |
312
- ================================================================================
313
-
314
- Please check the documentation at <http://karmi.github.com/tire/>.
315
-
316
- --------------------------------------------------------------------------------
317
-
318
- IMPORTANT CHANGES LATELY:
319
-
320
- 0.2.0
321
- ---------------------------------------------------------
322
- # By default, results are wrapped in Item class
323
- # Completely rewritten ActiveModel/ActiveRecord support
324
- # Added infrastructure for loading "real" models from database (eagerly or in runtime)
325
- # Deprecated the dynamic sort methods in favour of the 'sort { by :field_name }' syntax
326
-
327
- 0.2.1
328
- ---------------------------------------------------------
329
- # Lighweight check for index presence
330
- # Added the 'settings' method for models to define index settings
331
- # Fixed errors when importing data with will_paginate vs Kaminari (MongoDB)
332
- # Added support for histogram facets [Paco Guzman]
333
-
334
- 0.3.0
335
- ---------------------------------------------------------
336
- # Isolated Tire ActiveModel integration into `tire` class and instance method.
337
-
338
- When there's no conflict with existing methods, Tire methods are added
339
- to the class namespace, as well, so the change is 100% backwards-compatible.
340
-
341
- See the full changelog at <http://github.com/karmi/tire/commits/v0.3.2>.
342
-
343
- --------------------------------------------------------------------------------
344
-
345
- rdoc_options:
285
+ post_install_message: ! "================================================================================\n\n
286
+ \ Please check the documentation at <http://karmi.github.com/tire/>.\n\n--------------------------------------------------------------------------------\n\n
287
+ \ IMPORTANT CHANGES LATELY:\n\n 0.2.0\n ---------------------------------------------------------\n
288
+ \ # By default, results are wrapped in Item class\n # Completely rewritten ActiveModel/ActiveRecord
289
+ support\n # Added infrastructure for loading \"real\" models from database (eagerly
290
+ or in runtime)\n # Deprecated the dynamic sort methods in favour of the 'sort {
291
+ by :field_name }' syntax\n\n 0.2.1\n ---------------------------------------------------------\n
292
+ \ # Lighweight check for index presence\n # Added the 'settings' method for models
293
+ to define index settings\n # Fixed errors when importing data with will_paginate
294
+ vs Kaminari (MongoDB)\n # Added support for histogram facets [Paco Guzman]\n\n
295
+ \ 0.3.0\n ---------------------------------------------------------\n # Isolated
296
+ Tire ActiveModel integration into `tire` class and instance method.\n \n When
297
+ there's no conflict with existing methods, Tire methods are added\n to the class
298
+ namespace, as well, so the change is 100% backwards-compatible.\n\n 0.3.3\n ---------------------------------------------------------\n
299
+ \ # Added proper will_paginate compatibility\n # Added support for plugging in
300
+ another HTTP library (see lib/http/clients/curb for an example)\n\n\n See the full
301
+ changelog at <http://github.com/karmi/tire/commits/v0.3.3>.\n\n--------------------------------------------------------------------------------\n"
302
+ rdoc_options:
346
303
  - --charset=UTF-8
347
- require_paths:
304
+ require_paths:
348
305
  - lib
349
- required_ruby_version: !ruby/object:Gem::Requirement
350
- requirements:
351
- - - ">="
352
- - !ruby/object:Gem::Version
353
- segments:
354
- - 0
355
- version: "0"
356
- required_rubygems_version: !ruby/object:Gem::Requirement
357
- requirements:
358
- - - ">="
359
- - !ruby/object:Gem::Version
360
- segments:
361
- - 1
362
- - 3
363
- - 6
306
+ required_ruby_version: !ruby/object:Gem::Requirement
307
+ none: false
308
+ requirements:
309
+ - - ! '>='
310
+ - !ruby/object:Gem::Version
311
+ version: '0'
312
+ required_rubygems_version: !ruby/object:Gem::Requirement
313
+ none: false
314
+ requirements:
315
+ - - ! '>='
316
+ - !ruby/object:Gem::Version
364
317
  version: 1.3.6
365
318
  requirements: []
366
-
367
319
  rubyforge_project: tire
368
- rubygems_version: 1.3.6
320
+ rubygems_version: 1.8.6
369
321
  signing_key:
370
322
  specification_version: 3
371
323
  summary: Ruby client for ElasticSearch
372
- test_files:
324
+ test_files:
373
325
  - test/fixtures/articles/1.json
374
326
  - test/fixtures/articles/2.json
375
327
  - test/fixtures/articles/3.json
@@ -390,6 +342,7 @@ test_files:
390
342
  - test/integration/sort_test.rb
391
343
  - test/models/active_model_article.rb
392
344
  - test/models/active_model_article_with_callbacks.rb
345
+ - test/models/active_model_article_with_custom_document_type.rb
393
346
  - test/models/active_model_article_with_custom_index_name.rb
394
347
  - test/models/active_record_models.rb
395
348
  - test/models/article.rb
@@ -399,8 +352,9 @@ test_files:
399
352
  - test/models/validated_model.rb
400
353
  - test/test_helper.rb
401
354
  - test/unit/active_model_lint_test.rb
402
- - test/unit/client_test.rb
403
355
  - test/unit/configuration_test.rb
356
+ - test/unit/http_client_test.rb
357
+ - test/unit/http_response_test.rb
404
358
  - test/unit/index_test.rb
405
359
  - test/unit/logger_test.rb
406
360
  - test/unit/model_callbacks_test.rb