Permalink
Browse files

riddle/0.9.9/client: Fix VersionError constant lookup.

  • Loading branch information...
1 parent 28e818b commit 4dc5b9eeb4eb494d9c2bb8f7a20c920e66891e4d @sce committed Apr 3, 2012
Showing with 43 additions and 40 deletions.
  1. +43 −40 lib/riddle/0.9.9/client.rb
View
83 lib/riddle/0.9.9/client.rb
@@ -1,49 +1,52 @@
Riddle::Client::Versions[:search] = 0x116
Riddle::Client::Versions[:update] = 0x102
-class Riddle::Client
- private
-
- def initialise_connection
- socket = initialise_socket
-
- # Send version
- socket.send [1].pack('N'), 0
-
- # Checking version
- version = socket.recv(4).unpack('N*').first
- if version < 1
- socket.close
- raise VersionError, "Can only connect to searchd version 1.0 or better, not version #{version}"
- end
-
- socket
- end
-
- def update_message(index, attributes, values_by_doc)
- message = Message.new
-
- message.append_string index
- message.append_int attributes.length
- attributes.each_with_index do |attribute, index|
- message.append_string attribute
- message.append_boolean values_by_doc.values.first[index].is_a?(Array)
+module Riddle
+ class Client
+ private
+
+ def initialise_connection
+ socket = initialise_socket
+
+ # Send version
+ socket.send [1].pack('N'), 0
+
+ # Checking version
+ version = socket.recv(4).unpack('N*').first
+ if version < 1
+ socket.close
+ raise VersionError, "Can only connect to searchd version 1.0 or better, not version #{version}"
+ end
+
+ socket
end
-
- message.append_int values_by_doc.length
- values_by_doc.each do |key,values|
- message.append_64bit_int key # document ID
- values.each do |value|
- case value
- when Array
- message.append_int value.length
- message.append_ints *value
- else
- message.append_int value
+
+ def update_message(index, attributes, values_by_doc)
+ message = Message.new
+
+ message.append_string index
+ message.append_int attributes.length
+ attributes.each_with_index do |attribute, index|
+ message.append_string attribute
+ message.append_boolean values_by_doc.values.first[index].is_a?(Array)
+ end
+
+ message.append_int values_by_doc.length
+ values_by_doc.each do |key,values|
+ message.append_64bit_int key # document ID
+ values.each do |value|
+ case value
+ when Array
+ message.append_int value.length
+ message.append_ints *value
+ else
+ message.append_int value
+ end
end
end
+
+ message.to_s
end
-
- message.to_s
+
end
end

0 comments on commit 4dc5b9e

Please sign in to comment.