zabbix_protocol 0.1.5.beta → 0.1.5.beta2

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: a62768171ebe8a4628070f57c06e1c7926e9e25a
4
- data.tar.gz: 06884716424ddcb37733ffe44e1540b7b0ecfc67
3
+ metadata.gz: 2ad71e098d1d6641e868186bbcb191fe022f36db
4
+ data.tar.gz: 2b49036eb5e410e380be019f7475103ea3752130
5
5
  SHA512:
6
- metadata.gz: b96e8c4175247e9acb3727753a72ae8f1149b72b0da732d9bc3fbd04b3035c77d0102668b3eba7ba58da4f0c1560067f705b3509fb804ad3e4b5be53719bb538
7
- data.tar.gz: 212615a265fde21f1efae21b0ae0f16566c90976fbd211cb07cadb9fb527cd06071cfe0b214fb4773aedc6dcec619dbb3015cf003cfad55d55e26630c3adbd8b
6
+ metadata.gz: a8be4c0d4a6f51aab987d34c8641f0687ae2693d8344bfaa0e31e001a89917d32583916623afffa5e7f9a7ba5bc62531ba9abb390cdbbd2d4bbed469db458933
7
+ data.tar.gz: a8255c048e7a19d59423f69324aa33cf900709ac8cf42347a164763711a3cbb84e285bbabe85a874d69eff895d06b7541978c6f4a092294123138cdcf8d43824
@@ -1,3 +1,3 @@
1
1
  module ZabbixProtocol
2
- VERSION = "0.1.5.beta"
2
+ VERSION = "0.1.5.beta2"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  require "multi_json"
2
-
3
2
  require "zabbix_protocol/version"
4
3
 
5
4
  module ZabbixProtocol
@@ -34,6 +33,7 @@ module ZabbixProtocol
34
33
  raise TypeError, "wrong argument type #{data.class} (expected String)"
35
34
  end
36
35
 
36
+ original_encoding = data.encoding
37
37
  data = data.dup
38
38
  data.force_encoding('ASCII-8BIT')
39
39
 
@@ -61,6 +61,15 @@ module ZabbixProtocol
61
61
  raise Error, "invalid payload length: expected=#{payload_len}, actual=#{sliced.bytesize} (data: #{data.inspect})"
62
62
  end
63
63
 
64
+ duplicated = sliced.dup
65
+
66
+ begin
67
+ duplicated.force_encoding(original_encoding)
68
+ sliced = duplicated
69
+ rescue
70
+ # XXX: nothing to do
71
+ end
72
+
64
73
  begin
65
74
  MultiJson.load(sliced)
66
75
  rescue MultiJson::ParseError
@@ -59,6 +59,13 @@ describe ZabbixProtocol do
59
59
  data = subject.load(res_data)
60
60
  expect(data).to eq({"response"=>"success", "data"=>[]})
61
61
  end
62
+
63
+ it "should parse string" do
64
+ res_data = "ZBXD\x01\x0f\x00\x00\x00\x00\x00\x00\x00response-string"
65
+ data = subject.load(res_data)
66
+ expect(data).to eq("response-string")
67
+ expect(data.encoding).to eq Encoding::UTF_8
68
+ end
62
69
  end
63
70
 
64
71
  context "when error happen" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbix_protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.beta
4
+ version: 0.1.5.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara