pdu_tools 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pdu_tools/decoder.rb +6 -10
- data/spec/decoder_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a9f52dfc0c2e2780556e0c4a7fd27a76310585c
|
4
|
+
data.tar.gz: e53c81058a6d7ca4fd799e970a78fba436f4f3f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5cb4182fece15d6169a68cddbb42067661361e3be94009a7ecb42eb20eea0a934c6128e148f4060d886e3b1cf80f9d72253c1cd17dd93e49c0888d42cd7151a
|
7
|
+
data.tar.gz: 71b3094e064b82bbfbb315bac82cb8cd53490af2b991fc3ba7b037694e7ec90fd4e7bf4d31cec63ded27ab7ce147cf5431323adcbc17900e77e1e88f260038af
|
data/lib/pdu_tools/decoder.rb
CHANGED
@@ -65,19 +65,15 @@ module PDUTools
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def parse_address_type type
|
68
|
-
case type
|
69
|
-
when "
|
68
|
+
case type.to_i(16).to_s(2)[1,3]
|
69
|
+
when "001"
|
70
70
|
:international
|
71
|
-
when "
|
71
|
+
when "010", "100", "000"
|
72
72
|
:national
|
73
|
+
when "101"
|
74
|
+
:a7bit
|
73
75
|
else
|
74
|
-
|
75
|
-
:a7bit
|
76
|
-
elsif type.to_i(16).to_s(2)[1,3] == "100"
|
77
|
-
:national
|
78
|
-
else
|
79
|
-
raise StandardError, "unknown address type: #{type}"
|
80
|
-
end
|
76
|
+
raise StandardError, "unknown address type: #{type}"
|
81
77
|
end
|
82
78
|
end
|
83
79
|
|
data/spec/decoder_spec.rb
CHANGED
@@ -51,6 +51,15 @@ describe PDUTools::Decoder do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
context "Unknown address address type" do
|
55
|
+
let(:pdu) { "0791249150033330040C9124918017392100003190406104808024DA309C1DA6A7D9A0F9BB0DCAB940381748068BCD40D032BD2C072DEB6C76780C" }
|
56
|
+
it do
|
57
|
+
message_part = decoder.decode
|
58
|
+
expect(message_part.address).to eq("+421908719312")
|
59
|
+
expect(message_part.body).to match /^Zapla/
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
54
63
|
context "Odd length of address" do
|
55
64
|
let(:pdu) { "079124915000303904038109F5000041019022257580A0A8D84B960259C3FAB23B0FD287D761BD3BBD6681DC6190353C07955BED709A0D2AAFDFEE771BE02ED3E7F0F0B8EC9AAF41D6701B247EB3C3207D78CE0EBBC3A032BBBCA6CBDFEEF4781D0699C36B7A5D1E06CDE1EC30DD1D06C966AE18CC2583C5682E1008040281402010080402814020100804028140201008040281402010080402814020100804028140" }
|
56
65
|
|