Skip to content

Commit

Permalink
Removed usage of String#unpack and Array#pack because Ruby 1.9.2 does…
Browse files Browse the repository at this point in the history
… not support reading big-endian signed numbers on platforms that are natively little-endian.

Replaced pack/unpack with the BinData gem.
Added support for connecting to servers that implement protocol versions 10 and 11, but are backward compatible with version 9 (which is the highest version currently implemented in this gem).
  • Loading branch information
beverlycodes committed May 10, 2012
1 parent eb10719 commit bfa5739
Show file tree
Hide file tree
Showing 12 changed files with 626 additions and 429 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
.DS_Store
4 changes: 2 additions & 2 deletions lib/orient_db_client.rb
Expand Up @@ -11,9 +11,9 @@ def connect(host, options = {})

s = TCPSocket.open(host, options[:port])

protocol = s.read(2).unpack('s>').first
protocol = BinData::Int16be.read(s)

Connection.new(s, protocol)
Connection.new(s, options[:protocol] || protocol)
end
module_function :connect
end
3 changes: 3 additions & 0 deletions lib/orient_db_client/network_message.rb
@@ -1,5 +1,8 @@
require "bindata"

module OrientDbClient
class NetworkMessage

def initialize(&block)
@components = []

Expand Down
8 changes: 7 additions & 1 deletion lib/orient_db_client/protocol_factory.rb
Expand Up @@ -4,9 +4,15 @@
module OrientDbClient
class ProtocolFactory

# Orient server 1.0 supports Protocols 7 and 9.
# Since Protocols 10 and 11 are not implemented by this client,
# protocol 9 is substituted to allow connections to succeed.

PROTOCOLS = {
'7' => Protocols::Protocol7,
'9' => Protocols::Protocol9
'9' => Protocols::Protocol9,
'10' => Protocols::Protocol9,
'11' => Protocols::Protocol9
}

def self.get_protocol(version)
Expand Down
Binary file removed lib/orient_db_client/protocols/.DS_Store
Binary file not shown.

0 comments on commit bfa5739

Please sign in to comment.