poliqarpr 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/changelog.txt +5 -0
- data/lib/poliqarpr/client.rb +9 -8
- data/lib/poliqarpr/connector.rb +8 -2
- data/lib/poliqarpr/exceptions.rb +4 -0
- data/poliqarpr.gemspec +2 -2
- data/spec/client.rb +14 -0
- metadata +3 -3
data/changelog.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.1.1
|
2
|
+
- remove messy debug message
|
3
|
+
- raise IndexOutOfBounds exception when the excerpt index is larger than the
|
4
|
+
buffer size or is larger than the result count
|
5
|
+
|
1
6
|
0.1.0
|
2
7
|
- synchronization on ansync call without handler done via internal mutex
|
3
8
|
instead of call to STATUS
|
data/lib/poliqarpr/client.rb
CHANGED
@@ -340,9 +340,12 @@ protected
|
|
340
340
|
|
341
341
|
# Reads number stored in the message received from the server.
|
342
342
|
def read_number
|
343
|
-
|
344
|
-
|
345
|
-
|
343
|
+
@connector.read_message.match(/\d+/)[0].to_i
|
344
|
+
end
|
345
|
+
|
346
|
+
# Reads string stored in the last message received from server
|
347
|
+
def read_word
|
348
|
+
@connector.read_message
|
346
349
|
end
|
347
350
|
|
348
351
|
# Counts number of results for given answer
|
@@ -368,15 +371,12 @@ protected
|
|
368
371
|
if handler.nil?
|
369
372
|
@last_result = result
|
370
373
|
end
|
374
|
+
else
|
375
|
+
stop_waiting
|
371
376
|
end
|
372
377
|
@last_result
|
373
378
|
end
|
374
379
|
|
375
|
-
# Reads string stored in the last message received from server
|
376
|
-
def read_word
|
377
|
-
@connector.read_message
|
378
|
-
end
|
379
|
-
|
380
380
|
private
|
381
381
|
# Wait for the assynchronous answer, if some synchronous query
|
382
382
|
# was sent without handler.
|
@@ -415,6 +415,7 @@ protected
|
|
415
415
|
end
|
416
416
|
|
417
417
|
def make_async_query(query,answer_offset)
|
418
|
+
raise IndexOutOfBounds if answer_offset > config.buffer_size
|
418
419
|
start_waiting
|
419
420
|
# we access the result count through BUFFER-STATE call
|
420
421
|
make_query(query){|msg| stop_waiting}
|
data/lib/poliqarpr/connector.rb
CHANGED
@@ -84,8 +84,14 @@ module Poliqarp
|
|
84
84
|
message = @message_queue.shift
|
85
85
|
if message =~ /^ERR/
|
86
86
|
code = message.match(/\d+/)[0].to_i
|
87
|
-
|
88
|
-
|
87
|
+
case code
|
88
|
+
when 15
|
89
|
+
raise JobInProgress.new()
|
90
|
+
when 17
|
91
|
+
raise IndexOutOfBounds.new()
|
92
|
+
else
|
93
|
+
raise RuntimeError.new("Poliqarp Error: "+ERRORS[code])
|
94
|
+
end
|
89
95
|
else
|
90
96
|
message
|
91
97
|
end
|
data/lib/poliqarpr/exceptions.rb
CHANGED
@@ -6,4 +6,8 @@ module Poliqarp
|
|
6
6
|
# to the server which haven't finished, which is interrupted by another
|
7
7
|
# asynchronous call.
|
8
8
|
class JobInProgress < Exception; end
|
9
|
+
|
10
|
+
# The IndexOutOfBounds exception is raised if the index of given excerpt
|
11
|
+
# is larger than the size of query buffer.
|
12
|
+
class IndexOutOfBounds < Exception; end
|
9
13
|
end
|
data/poliqarpr.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "poliqarpr"
|
3
|
-
s.version = "0.1.
|
4
|
-
s.date = "
|
3
|
+
s.version = "0.1.1"
|
4
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
5
5
|
s.summary = "Ruby client for Poliqarp"
|
6
6
|
s.email = "apohllo@o2.pl"
|
7
7
|
s.homepage = "http://www.github.com/apohllo/poliqarpr"
|
data/spec/client.rb
CHANGED
@@ -146,6 +146,20 @@ describe Poliqarp::Client do
|
|
146
146
|
it "should fetch the same excerpt as in find without index " do
|
147
147
|
@result.to_s.should == @client.find("nachalny")[0].to_s
|
148
148
|
end
|
149
|
+
|
150
|
+
it "should raise IndexOutOfBounds if the index is larger than the results count" do
|
151
|
+
count = @client.count("nachalny")
|
152
|
+
(proc do
|
153
|
+
@client.find("nachalny",:index => count+1)
|
154
|
+
end).should raise_error(Poliqarp::IndexOutOfBounds)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should raise IndexOutOfBounds error if the index is larger than the buffer size" do
|
158
|
+
@client.config.buffer_size = 1
|
159
|
+
(proc do
|
160
|
+
@client.find("nachalny",:index => 2)
|
161
|
+
end).should raise_error(Poliqarp::IndexOutOfBounds)
|
162
|
+
end
|
149
163
|
end
|
150
164
|
|
151
165
|
describe("(with lemmata flags set to true)") do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aleksander Pohl
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-18 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|