codec 0.0.2 → 0.0.4

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.
@@ -0,0 +1,82 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Codec::Tlv do
4
+ subject { Codec::Tlv.new('Tlv', Codec::Numbin.new('*',1),
5
+ Codec::Binary.new('*',1), Codec::Binary.new('*',0))
6
+ }
7
+
8
+ before do
9
+ @buffer = ["950580000000009C0100"].pack("H*")
10
+ @field = Codec::Field.from_array('Tlv',[['95','8000000000'],['9C','00']])
11
+ end
12
+
13
+ it "must be a Tlv codec" do
14
+ subject.must_be_instance_of(Codec::Tlv)
15
+ end
16
+
17
+ it "must generate composed field from buffer" do
18
+ subject.decode(@buffer).first.
19
+ must_equal(@field)
20
+ end
21
+
22
+ it "must generate buffer from composed field" do
23
+ subject.encode(@field).must_equal(@buffer)
24
+ end
25
+ end
26
+
27
+ describe Codec::Tlv do
28
+ subject { Codec::Tlv.new('Tlv', Codec::Numbin.new('*',1),
29
+ Codec::Binary.new('*',1), Codec::Binary.new('*',0))
30
+ }
31
+
32
+ before do
33
+ tvr_codec = Codec::BaseComposed.new("Tvr")
34
+ one_byte_codec = Codec::Binary.new("*",1)
35
+ (1..5).each do |i|
36
+ tvr_codec.add_sub_codec("BIT#{i}",one_byte_codec)
37
+ end
38
+ subject.add_sub_codec('95',tvr_codec)
39
+
40
+ @buffer = ["950580000000009C0100"].pack("H*")
41
+ @field = Codec::Field.from_array('Tlv',
42
+ [['95',[['BIT1','80'],['BIT2','00'],['BIT3','00'],
43
+ ['BIT4','00'],['BIT5','00']]],['9C','00']])
44
+ end
45
+
46
+ it "must be a Tlv codec" do
47
+ subject.must_be_instance_of(Codec::Tlv)
48
+ end
49
+
50
+ it "must generate composed field from buffer" do
51
+ subject.decode(@buffer).first.
52
+ must_equal(@field)
53
+ end
54
+
55
+ it "must generate buffer from composed field" do
56
+ subject.encode(@field).must_equal(@buffer)
57
+ end
58
+ end
59
+
60
+
61
+ describe Codec::Bertlv do
62
+ subject { Codec::Bertlv.new('Bertlv') }
63
+
64
+ before do
65
+ @tlv_buf = ["9F100A0102030405060708091095058000000000"].pack("H*")
66
+ @field = Codec::Field.from_array('Bertlv',
67
+ [['9F10','01020304050607080910'],['95','8000000000']])
68
+ end
69
+
70
+ it "must be a Tlv codec" do
71
+ subject.must_be_instance_of(Codec::Bertlv)
72
+ end
73
+
74
+ it "must generate composed field from buffer" do
75
+ subject.decode(@tlv_buf).first.
76
+ must_equal(@field)
77
+ end
78
+
79
+ it "must generate buffer from composed field" do
80
+ subject.encode(@field).must_equal(@tlv_buf)
81
+ end
82
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-06 00:00:00.000000000 Z
12
+ date: 2013-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: log4r
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  description: Generic Coder Decoder Tool
47
63
  email:
48
64
  - bernard.rodier@gmail.com
@@ -51,6 +67,7 @@ extensions: []
51
67
  extra_rdoc_files: []
52
68
  files:
53
69
  - .gitignore
70
+ - .travis.yml
54
71
  - Gemfile
55
72
  - LICENSE.txt
56
73
  - README.md
@@ -58,12 +75,23 @@ files:
58
75
  - codec.gemspec
59
76
  - lib/codec.rb
60
77
  - lib/codec/base.rb
78
+ - lib/codec/bitmap.rb
79
+ - lib/codec/composed.rb
61
80
  - lib/codec/exceptions.rb
81
+ - lib/codec/factory.rb
62
82
  - lib/codec/field.rb
63
83
  - lib/codec/fix.rb
64
- - lib/codec/protocols/core.rb
84
+ - lib/codec/packed.rb
85
+ - lib/codec/prefix.rb
86
+ - lib/codec/tlv.rb
65
87
  - lib/codec/version.rb
88
+ - test/lib/codec/bitmap_test.rb
89
+ - test/lib/codec/composed_test.rb
90
+ - test/lib/codec/field_test.rb
66
91
  - test/lib/codec/fix_test.rb
92
+ - test/lib/codec/pckd_test.rb
93
+ - test/lib/codec/prefix_test.rb
94
+ - test/lib/codec/tlv_test.rb
67
95
  - test/lib/codec/version_test.rb
68
96
  - test/test_helper.rb
69
97
  homepage: https://github.com/brodier/codec
@@ -93,6 +121,12 @@ specification_version: 3
93
121
  summary: This Gem provide class that permit to instantiate Codec to parse or build
94
122
  any protocol
95
123
  test_files:
124
+ - test/lib/codec/bitmap_test.rb
125
+ - test/lib/codec/composed_test.rb
126
+ - test/lib/codec/field_test.rb
96
127
  - test/lib/codec/fix_test.rb
128
+ - test/lib/codec/pckd_test.rb
129
+ - test/lib/codec/prefix_test.rb
130
+ - test/lib/codec/tlv_test.rb
97
131
  - test/lib/codec/version_test.rb
98
132
  - test/test_helper.rb
File without changes