semaphore_classification 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,6 +14,15 @@ To classify documents:
14
14
 
15
15
  Mostly likely you will specify a :document_uri when classifying documents, but if you do not you will need to specify an :alternate_body
16
16
 
17
+ Note that the classify method will only return the term IDs that matched and not
18
+ the term itself. In order to set it to return the terms as well, you can use the
19
+ option:
20
+
21
+ Semaphore::Client.decode_term_ids = true
22
+
23
+ This will slow down your classifications, however, as a new HTTP request is made
24
+ for each term in the response.
25
+
17
26
  == Semaphore::Client.decode_term_id(<term_id>) Options
18
27
 
19
28
  This method is used when you have the ID of a term and would like to retrieve
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -14,6 +14,7 @@ module Semaphore
14
14
  class NotFound < SemaphoreError; end
15
15
  class ServerError < SemaphoreError; end
16
16
  class Unavailable < SemaphoreError; end
17
+ class Timeout < SemaphoreError; end
17
18
  class DecodeError < SemaphoreError; end
18
19
  class RealmNotSpecified < SemaphoreError; end
19
20
  end
@@ -18,16 +18,16 @@ module Semaphore
18
18
  private
19
19
 
20
20
  def request(method, data)
21
- response = send_request method, construct_document(data)
21
+ response = send_request(method, construct_document(data))
22
22
 
23
- deconstruct_document(response)
23
+ deconstruct_document response
24
24
  end
25
25
 
26
26
  def send_request(method, data)
27
27
  RestClient.proxy = @proxy unless @proxy.nil?
28
28
 
29
29
  begin
30
- response = RestClient.post @realm, :XML_INPUT => data, :multipart => true
30
+ response = RestClient.post(@realm, :XML_INPUT => data, :multipart => true)
31
31
  rescue => e
32
32
  raise_errors(e.response)
33
33
  end
@@ -65,6 +65,7 @@ module Semaphore
65
65
 
66
66
  def deconstruct_document(response)
67
67
  data = Array.new
68
+ raise(Timeout, "The Semaphore server could not be reached") if response.nil?
68
69
 
69
70
  if !response.body.empty?
70
71
  begin
@@ -85,6 +86,8 @@ module Semaphore
85
86
  end
86
87
 
87
88
  def raise_errors(response)
89
+ raise(Timeout, "The Semaphore server could not be reached") if response.nil?
90
+
88
91
  case response.code
89
92
  when 500
90
93
  raise ServerError, "Semaphore Classification Server had an internal error. #{response.description}\n\n#{response.body}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semaphore_classification
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mauricio Gomes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-12 00:00:00 -04:00
18
+ date: 2010-11-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency