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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d5716fb4b1a3cb3f6f46816ba15855bb411cc1e
4
- data.tar.gz: b35730d96cd5a0711b6c6f3c7b97465eff4ca749
3
+ metadata.gz: 1a9f52dfc0c2e2780556e0c4a7fd27a76310585c
4
+ data.tar.gz: e53c81058a6d7ca4fd799e970a78fba436f4f3f8
5
5
  SHA512:
6
- metadata.gz: ef65158b4fb7a5541b9510331e74ca7b19360e596f7ea79b11ac9d731e62ef278c316f35e61d4ae0d10e769a9f821bd7fcc901ba827cedf28c7316a21d7b6fc8
7
- data.tar.gz: a2551102ba59aaf3abcc2faac35c1726326f7fbf8a80bd02df98f9aca80398f39aa1122f7a9cd2d23286489314b263f9a0a7bd3e7a625766de2ae4ea340388c6
6
+ metadata.gz: c5cb4182fece15d6169a68cddbb42067661361e3be94009a7ecb42eb20eea0a934c6128e148f4060d886e3b1cf80f9d72253c1cd17dd93e49c0888d42cd7151a
7
+ data.tar.gz: 71b3094e064b82bbfbb315bac82cb8cd53490af2b991fc3ba7b037694e7ec90fd4e7bf4d31cec63ded27ab7ce147cf5431323adcbc17900e77e1e88f260038af
@@ -65,19 +65,15 @@ module PDUTools
65
65
  end
66
66
 
67
67
  def parse_address_type type
68
- case type
69
- when "91"
68
+ case type.to_i(16).to_s(2)[1,3]
69
+ when "001"
70
70
  :international
71
- when "81"
71
+ when "010", "100", "000"
72
72
  :national
73
+ when "101"
74
+ :a7bit
73
75
  else
74
- if type.to_i(16).to_s(2)[1,3] == "101"
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdu_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filip Zachar