net-tns 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae395e30d483af200c9eda9c522288af1cdad4e1
4
- data.tar.gz: e4399ebb1818042b98d92b8e18e54de0e0b79d12
3
+ metadata.gz: c79686c4bd0a8d905987a42092ec1fa49cb140fa
4
+ data.tar.gz: 5a95a383671604fb14980ea2cfe099055f488db5
5
5
  SHA512:
6
- metadata.gz: 9bc129315cca6f165f1fdecbb211b436034fdb8606083b7e5d1d1ae80a4bafe87447e1463f1a21042afdb68e8b016b6bb392955f0b7f83165924db4d18840a7c
7
- data.tar.gz: f17cdca07bcc38a3199b30ded2eb9fe1384c892d43c8ff2d8865e746e1e8ff116763715cfde565ae339e8422670541a498333defaebd627ab86bdc7c9c57987f
6
+ metadata.gz: c135287fde902c9019eb0da3c5b38c71fb94d13ee90e4625f622bd7c8d71df0ca690c362c971843621da788f73476437aa281c04bb5698ebc073b3d2da35c8f5
7
+ data.tar.gz: afdce9a532326bb42af0fc093d6b08f2d4a26bc32369fd2c14c9014524b0b7f911a08e3f5241aa0f85896d021dbb4c80370ca567fb1a8a139a30de21a0b4920a
@@ -24,7 +24,7 @@ module Net
24
24
  request = ConnectPacket.new(:data => "(CONNECT_DATA=(COMMAND=VERSION))")
25
25
 
26
26
  response = conn.send_and_receive( request )
27
- raise "Expected AcceptPacket in response" unless response.is_a?(AcceptPacket)
27
+ raise Exceptions::ProtocolException.new("Expected AcceptPacket in response (got #{response.class})") unless response.is_a?(AcceptPacket)
28
28
 
29
29
  version_data = response.data
30
30
  rescue Exceptions::RefuseMessageReceived => refuse_err
@@ -1,5 +1,5 @@
1
1
  module Net
2
2
  module TNS
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -4,33 +4,12 @@ module Net::TNS
4
4
  module StringHelpers
5
5
  HEXCHARS = [("0".."9").to_a, ("a".."f").to_a].flatten
6
6
 
7
- #From the Ruby Black Bag (http://github.com/emonti/rbkb/)
8
- # Convert a string to ASCII hex string. Supports a few options for format:
9
- #
10
- # :delim - delimter between each hex byte
11
- # :prefix - prefix before each hex byte
12
- # :suffix - suffix after each hex byte
13
- #
14
- def tns_hexify(opts={})
15
- delim = opts[:delim]
16
- pre = (opts[:prefix] || "")
17
- suf = (opts[:suffix] || "")
18
-
19
- if (rx=opts[:rx]) and not rx.kind_of? Regexp
20
- raise "rx must be a regular expression for a character class"
21
- end
22
-
23
- out=Array.new
24
-
25
- self.each_byte do |c|
26
- hc = if (rx and not rx.match c.chr)
27
- c.chr
28
- else
29
- pre + (HEXCHARS[(c >> 4)] + HEXCHARS[(c & 0xf )]) + suf
30
- end
31
- out << (hc)
32
- end
33
- out.join(delim)
7
+ # Adapted from the Ruby Black Bag (http://github.com/emonti/rbkb/)
8
+ # Convert a string to ASCII hex string
9
+ def tns_hexify
10
+ self.each_byte.map do |byte|
11
+ (HEXCHARS[(byte >> 4)] + HEXCHARS[(byte & 0xf )])
12
+ end.join()
34
13
  end
35
14
 
36
15
  # Convert ASCII hex string to raw.
@@ -25,7 +25,7 @@ module Net
25
25
  @@tns_packet_types ||= {}
26
26
  if @@tns_packet_classes.has_key?(tns_type)
27
27
  existing_class = @@tns_packet_classes[tns_type]
28
- raise("Duplicate TNS Types Defined: #{existing_class} and #{self} both have a type of #{tns_type}")
28
+ raise ArgumentError.new("Duplicate TNS Types Defined: #{existing_class} and #{self} both have a type of #{tns_type}")
29
29
  end
30
30
 
31
31
  @@tns_packet_classes[tns_type] = self
@@ -46,13 +46,16 @@ module Net
46
46
  end
47
47
 
48
48
  if header_raw.nil? || header_raw.length != Header::LENGTH
49
- raise Exceptions::ProtocolException
49
+ header_length = header_raw.length unless header_raw.nil?
50
+ raise Exceptions::ProtocolException.new("Failed to read complete header. Read #{header_length.to_i} bytes.")
50
51
  end
51
52
 
52
53
  header = Header.new()
53
54
  header.read( header_raw )
54
55
  Net::TNS.logger.debug("Read header. Reported packet length is #{header.packet_length} bytes")
55
- raise Exceptions::ProtocolException if header.packet_length > SESSION_DATA_UNIT_SIZE
56
+ if header.packet_length > SESSION_DATA_UNIT_SIZE
57
+ raise Exceptions::ProtocolException.new("Packet length in header (#{header.packet_length}) is longer than SDU size.")
58
+ end
56
59
 
57
60
  payload_raw = socket.read( header.packet_length - Header::LENGTH )
58
61
  packet_raw = header_raw + payload_raw
@@ -62,7 +65,7 @@ module Net
62
65
  end
63
66
 
64
67
  unless packet_raw.length == header.packet_length
65
- raise Net::TNS::Exceptions::ProtocolException
68
+ raise Net::TNS::Exceptions::ProtocolException.new("Failed to read entire packet (read #{packet_raw.length} of #{header.packet_length} bytes).")
66
69
  end
67
70
 
68
71
  new_packet = payload_class.read( packet_raw )
@@ -22,7 +22,7 @@ module Net
22
22
  @@ttc_codes ||= {}
23
23
  if @@ttc_classes.has_key?(ttc_code)
24
24
  existing_class = @@ttc_classes[ttc_code]
25
- raise("Duplicate TTC response handlers defined: #{existing_class} and #{self} both have TTC code of #{ttc_code}")
25
+ raise ArgumentError.new("Duplicate TTC response handlers defined: #{existing_class} and #{self} both have TTC code of #{ttc_code}")
26
26
  end
27
27
 
28
28
  @@ttc_classes[ttc_code] = self
@@ -23,7 +23,7 @@ module Net
23
23
 
24
24
  def find_param(key, raise_if_not_found=false)
25
25
  param = self.parameters.find {|p| p.kvp_key == key}
26
- raise "No #{key} parameter found" if param.nil? && raise_if_not_found
26
+ raise Net::TTI::Exceptions::TTIException.new("No #{key} parameter found") if param.nil? && raise_if_not_found
27
27
  return param
28
28
  end
29
29
  private :find_param
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-tns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Woodbury
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-29 00:00:00.000000000 Z
12
+ date: 2014-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bindata
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: coveralls
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  description: A pure Ruby (partial) implementation of the Oracle TNS protocol
57
71
  email: woodbusy@gmail.com
58
72
  executables: []