indextank 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/indextank.rb +4 -4
- data/lib/indextank/client.rb +1 -1
- data/lib/indextank/document.rb +1 -1
- data/spec/lib/indextank/document_spec.rb +5 -5
- data/spec/lib/indextank/function_spec.rb +1 -1
- data/spec/lib/indextank/index_spec.rb +13 -11
- data/spec/spec_helper.rb +1 -1
- metadata +14 -47
data/lib/indextank.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday_middleware'
|
2
2
|
require 'uri'
|
3
3
|
|
4
4
|
directory = File.expand_path(File.dirname(__FILE__))
|
5
5
|
require File.join(directory, 'indextank', 'client')
|
6
6
|
|
7
7
|
module IndexTank
|
8
|
-
VERSION = "1.0.
|
8
|
+
VERSION = "1.0.13"
|
9
9
|
|
10
10
|
def self.setup_connection(url)
|
11
11
|
@conn = Faraday::Connection.new(:url => url) do |builder|
|
12
|
-
builder.use
|
13
|
-
yield builder if block_given?
|
12
|
+
builder.use FaradayMiddleware::ParseJson
|
13
|
+
yield builder if block_given?
|
14
14
|
builder.adapter Faraday.default_adapter
|
15
15
|
end
|
16
16
|
@uri = URI.parse(url)
|
data/lib/indextank/client.rb
CHANGED
data/lib/indextank/document.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|
3
3
|
describe IndexTank::Document do
|
4
4
|
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
|
5
5
|
let(:document) { IndexTank::Client.new("http://:xxxx@dstqe.api.indextank.com").indexes('new-index').document('document1') }
|
6
|
-
let(:path_prefix) { '/v1/indexes/new-index/docs
|
6
|
+
let(:path_prefix) { '/v1/indexes/new-index/docs' }
|
7
7
|
|
8
8
|
before { stub_setup_connection do |builder| builder.use IndexTank::DocumentResponseMiddleware; end }
|
9
9
|
|
@@ -106,7 +106,7 @@ describe IndexTank::Document do
|
|
106
106
|
|
107
107
|
context "variables indexed" do
|
108
108
|
before do
|
109
|
-
stubs.put("#{path_prefix}variables") { [200, {}, ''] }
|
109
|
+
stubs.put("#{path_prefix}/variables") { [200, {}, ''] }
|
110
110
|
end
|
111
111
|
|
112
112
|
it { should be_true }
|
@@ -114,7 +114,7 @@ describe IndexTank::Document do
|
|
114
114
|
|
115
115
|
context "index is initializing" do
|
116
116
|
before do
|
117
|
-
stubs.put("#{path_prefix}variables") { [409, {}, ''] }
|
117
|
+
stubs.put("#{path_prefix}/variables") { [409, {}, ''] }
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should raise an exception" do
|
@@ -124,7 +124,7 @@ describe IndexTank::Document do
|
|
124
124
|
|
125
125
|
context "invalid or missing argument" do
|
126
126
|
before do
|
127
|
-
stubs.put("#{path_prefix}variables") { [400, {}, ''] }
|
127
|
+
stubs.put("#{path_prefix}/variables") { [400, {}, ''] }
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should raise an exception" do
|
@@ -134,7 +134,7 @@ describe IndexTank::Document do
|
|
134
134
|
|
135
135
|
context "no index existed for the given name" do
|
136
136
|
before do
|
137
|
-
stubs.put("#{path_prefix}variables") { [404, {}, ''] }
|
137
|
+
stubs.put("#{path_prefix}/variables") { [404, {}, ''] }
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should raise an exception" do
|
@@ -3,7 +3,7 @@ require File.expand_path('../../../spec_helper', __FILE__)
|
|
3
3
|
describe IndexTank::Function do
|
4
4
|
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
|
5
5
|
let(:function) { IndexTank::Client.new("http://:xxxx@dstqe.api.indextank.com").indexes('new-index').functions(0, '-age') }
|
6
|
-
let(:path_prefix) { '/v1/indexes/new-index/functions/0
|
6
|
+
let(:path_prefix) { '/v1/indexes/new-index/functions/0' }
|
7
7
|
|
8
8
|
before { stub_setup_connection do |builder| builder.use IndexTank::DocumentResponseMiddleware; end}
|
9
9
|
|
@@ -4,7 +4,7 @@ require 'yajl'
|
|
4
4
|
describe IndexTank::Index do
|
5
5
|
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
|
6
6
|
let(:index) { IndexTank::Client.new("http://:xxxx@dstqe.api.indextank.com").indexes('new-index') }
|
7
|
-
let(:path_prefix) { '/v1/indexes/new-index
|
7
|
+
let(:path_prefix) { '/v1/indexes/new-index' }
|
8
8
|
|
9
9
|
before { stub_setup_connection }
|
10
10
|
|
@@ -17,6 +17,7 @@ describe IndexTank::Index do
|
|
17
17
|
|
18
18
|
context "the index does not exist" do
|
19
19
|
before do
|
20
|
+
stubs.get(path_prefix) { [404, {}, ''] }
|
20
21
|
stubs.put(path_prefix) { [201, {}, '{"started": false, "code": "dsyaj", "creation_time": "2010-08-14T13:01:48.454624", "size": 0}'] }
|
21
22
|
end
|
22
23
|
|
@@ -26,7 +27,7 @@ describe IndexTank::Index do
|
|
26
27
|
context "when an index already exists" do
|
27
28
|
before do
|
28
29
|
# @index.add
|
29
|
-
stubs.
|
30
|
+
stubs.get(path_prefix) { [200, {}, '{"started": true, "code": "dsyaj", "creation_time": "2010-08-14T13:01:48.454624", "size": 0}'] }
|
30
31
|
end
|
31
32
|
|
32
33
|
it "should raise an exception" do
|
@@ -36,6 +37,7 @@ describe IndexTank::Index do
|
|
36
37
|
|
37
38
|
context "when the user has too many indexes" do
|
38
39
|
before do
|
40
|
+
stubs.get(path_prefix) { [404, {}, ''] }
|
39
41
|
stubs.put(path_prefix) { [409, {}, ''] }
|
40
42
|
end
|
41
43
|
|
@@ -144,7 +146,7 @@ describe IndexTank::Index do
|
|
144
146
|
|
145
147
|
context "search is successful" do
|
146
148
|
before do
|
147
|
-
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [200, {}, '{"matches": 4, "search_time": "0.022", "results": [{"docid": "http://cnn.com/HEALTH"}, {"docid": "http://www.cnn.com/HEALTH/"}, {"docid": "http://cnn.com/HEALTH/?hpt=Sbin"}, {"docid": "http://cnn.com/HEALTH/"}]}'] }
|
149
|
+
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [200, {}, '{"matches": 4, "search_time": "0.022", "results": [{"docid": "http://cnn.com/HEALTH"}, {"docid": "http://www.cnn.com/HEALTH/"}, {"docid": "http://cnn.com/HEALTH/?hpt=Sbin"}, {"docid": "http://cnn.com/HEALTH/"}]}'] }
|
148
150
|
end
|
149
151
|
|
150
152
|
it "should have the number of matches" do
|
@@ -165,7 +167,7 @@ describe IndexTank::Index do
|
|
165
167
|
|
166
168
|
context "index is initializing" do
|
167
169
|
before do
|
168
|
-
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [409, {}, ''] }
|
170
|
+
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [409, {}, ''] }
|
169
171
|
end
|
170
172
|
|
171
173
|
it "should return raise an exception" do
|
@@ -175,7 +177,7 @@ describe IndexTank::Index do
|
|
175
177
|
|
176
178
|
context "index is invalid/missing argument" do
|
177
179
|
before do
|
178
|
-
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [400, {}, ''] }
|
180
|
+
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [400, {}, ''] }
|
179
181
|
end
|
180
182
|
|
181
183
|
it "should return raise an exception" do
|
@@ -185,7 +187,7 @@ describe IndexTank::Index do
|
|
185
187
|
|
186
188
|
context "no index existed for the given name" do
|
187
189
|
before do
|
188
|
-
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [404, {}, ''] }
|
190
|
+
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [404, {}, ''] }
|
189
191
|
end
|
190
192
|
|
191
193
|
it "should return raise an exception" do
|
@@ -199,7 +201,7 @@ describe IndexTank::Index do
|
|
199
201
|
|
200
202
|
context "when the document is promoted" do
|
201
203
|
before do
|
202
|
-
stubs.put("#{path_prefix}promote", Yajl::dump({"docid" => "4", "query" =>"foo"})) { [200, {}, ''] }
|
204
|
+
stubs.put("#{path_prefix}/promote", Yajl::dump({"docid" => "4", "query" =>"foo"})) { [200, {}, ''] }
|
203
205
|
end
|
204
206
|
|
205
207
|
it { should be_nil }
|
@@ -207,7 +209,7 @@ describe IndexTank::Index do
|
|
207
209
|
|
208
210
|
context "when the index is initializing" do
|
209
211
|
before do
|
210
|
-
stubs.put("#{path_prefix}promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [409, {}, ''] }
|
212
|
+
stubs.put("#{path_prefix}/promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [409, {}, ''] }
|
211
213
|
end
|
212
214
|
|
213
215
|
it "should raise an exception" do
|
@@ -217,7 +219,7 @@ describe IndexTank::Index do
|
|
217
219
|
|
218
220
|
context "when invalid or missing argument" do
|
219
221
|
before do
|
220
|
-
stubs.put("#{path_prefix}promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [400, {}, ''] }
|
222
|
+
stubs.put("#{path_prefix}/promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [400, {}, ''] }
|
221
223
|
end
|
222
224
|
|
223
225
|
it "should raise an exception" do
|
@@ -227,7 +229,7 @@ describe IndexTank::Index do
|
|
227
229
|
|
228
230
|
context "when no index exists for the given name" do
|
229
231
|
before do
|
230
|
-
stubs.put("#{path_prefix}promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [404, {}, ''] }
|
232
|
+
stubs.put("#{path_prefix}/promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [404, {}, ''] }
|
231
233
|
end
|
232
234
|
|
233
235
|
it "should raise an exception" do
|
@@ -250,7 +252,7 @@ describe IndexTank::Index do
|
|
250
252
|
subject { index.functions }
|
251
253
|
|
252
254
|
before do
|
253
|
-
stubs.get("#{path_prefix}functions") { [200, {}, '{"0": "0-A", "1": "-age", "2": "relevance"}'] }
|
255
|
+
stubs.get("#{path_prefix}/functions") { [200, {}, '{"0": "0-A", "1": "-age", "2": "relevance"}'] }
|
254
256
|
end
|
255
257
|
|
256
258
|
it "should return an array of functions" do
|
data/spec/spec_helper.rb
CHANGED
@@ -21,7 +21,7 @@ end
|
|
21
21
|
def stub_setup_connection
|
22
22
|
stub(IndexTank).setup_connection(anything) do |url|
|
23
23
|
Faraday::Connection.new(:url => url) do |builder|
|
24
|
-
builder.use
|
24
|
+
builder.use FaradayMiddleware::ParseJson
|
25
25
|
yield builder if block_given?
|
26
26
|
builder.adapter :test, stubs
|
27
27
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indextank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
8
|
+
- 13
|
9
|
+
version: 1.0.13
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Santiago Perez
|
@@ -17,18 +16,16 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2011-04-04 00:00:00 -
|
19
|
+
date: 2011-04-04 00:00:00 -07:00
|
21
20
|
default_executable:
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: jeweler
|
25
24
|
prerelease: false
|
26
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
26
|
requirements:
|
29
27
|
- - ">="
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 7
|
32
29
|
segments:
|
33
30
|
- 1
|
34
31
|
- 4
|
@@ -40,11 +37,9 @@ dependencies:
|
|
40
37
|
name: rspec-core
|
41
38
|
prerelease: false
|
42
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
40
|
requirements:
|
45
41
|
- - ">="
|
46
42
|
- !ruby/object:Gem::Version
|
47
|
-
hash: 62196421
|
48
43
|
segments:
|
49
44
|
- 2
|
50
45
|
- 0
|
@@ -58,11 +53,9 @@ dependencies:
|
|
58
53
|
name: rspec-expectations
|
59
54
|
prerelease: false
|
60
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
56
|
requirements:
|
63
57
|
- - ">="
|
64
58
|
- !ruby/object:Gem::Version
|
65
|
-
hash: 62196421
|
66
59
|
segments:
|
67
60
|
- 2
|
68
61
|
- 0
|
@@ -76,11 +69,9 @@ dependencies:
|
|
76
69
|
name: rr
|
77
70
|
prerelease: false
|
78
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
72
|
requirements:
|
81
73
|
- - ">="
|
82
74
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 33
|
84
75
|
segments:
|
85
76
|
- 0
|
86
77
|
- 10
|
@@ -92,11 +83,9 @@ dependencies:
|
|
92
83
|
name: rake
|
93
84
|
prerelease: false
|
94
85
|
requirement: &id005 !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
86
|
requirements:
|
97
87
|
- - ">="
|
98
88
|
- !ruby/object:Gem::Version
|
99
|
-
hash: 49
|
100
89
|
segments:
|
101
90
|
- 0
|
102
91
|
- 8
|
@@ -104,66 +93,48 @@ dependencies:
|
|
104
93
|
version: 0.8.7
|
105
94
|
type: :development
|
106
95
|
version_requirements: *id005
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
name: ruby-debug
|
109
|
-
prerelease: false
|
110
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
|
-
requirements:
|
113
|
-
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
hash: 3
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
119
|
-
type: :development
|
120
|
-
version_requirements: *id006
|
121
96
|
- !ruby/object:Gem::Dependency
|
122
97
|
name: parka
|
123
98
|
prerelease: false
|
124
|
-
requirement: &
|
125
|
-
none: false
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
126
100
|
requirements:
|
127
101
|
- - ">="
|
128
102
|
- !ruby/object:Gem::Version
|
129
|
-
hash: 17
|
130
103
|
segments:
|
131
104
|
- 0
|
132
105
|
- 3
|
133
106
|
- 1
|
134
107
|
version: 0.3.1
|
135
108
|
type: :development
|
136
|
-
version_requirements: *
|
109
|
+
version_requirements: *id006
|
137
110
|
- !ruby/object:Gem::Dependency
|
138
|
-
name:
|
111
|
+
name: faraday_middleware
|
139
112
|
prerelease: false
|
140
|
-
requirement: &
|
141
|
-
none: false
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
142
114
|
requirements:
|
143
115
|
- - ">="
|
144
116
|
- !ruby/object:Gem::Version
|
145
|
-
hash: 3
|
146
117
|
segments:
|
147
118
|
- 0
|
148
|
-
|
119
|
+
- 9
|
120
|
+
- 0
|
121
|
+
version: 0.9.0
|
149
122
|
type: :runtime
|
150
|
-
version_requirements: *
|
123
|
+
version_requirements: *id007
|
151
124
|
- !ruby/object:Gem::Dependency
|
152
125
|
name: yajl-ruby
|
153
126
|
prerelease: false
|
154
|
-
requirement: &
|
155
|
-
none: false
|
127
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
156
128
|
requirements:
|
157
129
|
- - ">="
|
158
130
|
- !ruby/object:Gem::Version
|
159
|
-
hash: 13
|
160
131
|
segments:
|
161
132
|
- 0
|
162
133
|
- 7
|
163
134
|
- 7
|
164
135
|
version: 0.7.7
|
165
136
|
type: :runtime
|
166
|
-
version_requirements: *
|
137
|
+
version_requirements: *id008
|
167
138
|
description: Ruby Client for the IndexTank API
|
168
139
|
email:
|
169
140
|
- santip@santip.com.ar
|
@@ -197,27 +168,23 @@ rdoc_options: []
|
|
197
168
|
require_paths:
|
198
169
|
- lib
|
199
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
-
none: false
|
201
171
|
requirements:
|
202
172
|
- - ">="
|
203
173
|
- !ruby/object:Gem::Version
|
204
|
-
hash: 3
|
205
174
|
segments:
|
206
175
|
- 0
|
207
176
|
version: "0"
|
208
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
178
|
requirements:
|
211
179
|
- - ">="
|
212
180
|
- !ruby/object:Gem::Version
|
213
|
-
hash: 3
|
214
181
|
segments:
|
215
182
|
- 0
|
216
183
|
version: "0"
|
217
184
|
requirements: []
|
218
185
|
|
219
186
|
rubyforge_project: nowarning
|
220
|
-
rubygems_version: 1.3.
|
187
|
+
rubygems_version: 1.3.6
|
221
188
|
signing_key:
|
222
189
|
specification_version: 3
|
223
190
|
summary: Ruby Client for the IndexTank API
|