asciipack 0.0.2 → 0.1.0

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: 2f5ab153658fcc0d6bf96fc72ba0b3f19923a888
4
- data.tar.gz: 58520e74b5d6aa9dd8d6ed8b42dc8a8a77b012ab
3
+ metadata.gz: 2ed12a4882ea2f096a50dba7dd1832324432d90d
4
+ data.tar.gz: 4437fc5441e2c033a8201a135bff2738f522c320
5
5
  SHA512:
6
- metadata.gz: f9983cc226fd9edb1a150f0c47a0dd3bc5f7ee93dd61040f55ec85f9047dcf85b6c3fe49b61783c5818080b1dc883687fb814f45fee36d5d402d8ad8e0968011
7
- data.tar.gz: 5784d28550c7844af1fc747b8a7f44a05f08493cc37a3206f7397ac3ed89a05d0fa1a50d1947076b2feff3681c242dab5d82a10a6913404d45940d21b874905b
6
+ metadata.gz: 79fe2fde39fc99168eb2ce30db2b9078102414af5154ad98d4193917df1f3ef9de7e8a31c33625e77a072a54e729aac8a44730a33320f29b4f36a9d4084b100f
7
+ data.tar.gz: 451a0f8d12f1928f1057d8b60aebc74abfc5c5739ce7aa1e9fd95f1933b1c03b3238f32299f4b373eee1c60b50ea9c487b63e62ef83981dc1799ee744d13e08b
data/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # AsciiPack
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/asciipack.png)](http://badge.fury.io/rb/asciipack)
4
+
3
5
  ## Synopsis
4
6
 
5
7
  ```ruby
6
8
  demo = {"compact"=>true,"binary"=>0}
7
9
  ap = AsciiPack.pack demo
8
- p ap //=> "q2m7compactum6binaryf0"
10
+ p ap #=> "r2NcompactYMschema0"
9
11
 
10
12
  unpacked = AsciiPack.unpack ap
11
- p unpacked //=> {"compact"=>true,"binary"=>0}
13
+ p unpacked #=> {"compact"=>true,"binary"=>0}
12
14
  ```
13
15
 
14
16
  ## Install
data/asciipack.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # encoding: ascii-8bit
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'asciipack/version'
data/lib/asciipack.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require "asciipack/version"
2
- require 'asciipack/pack.rb'
3
- require 'asciipack/unpack.rb'
2
+ require 'asciipack/packer.rb'
3
+ require 'asciipack/unpacker.rb'
@@ -13,7 +13,7 @@ module AsciiPack
13
13
  if obj.kind_of?(Integer)
14
14
  if 0 <= obj
15
15
  if obj < 0x10
16
- uint4 obj
16
+ positive_fixint obj
17
17
  elsif obj < 0x100
18
18
  uint8 obj
19
19
  elsif obj < 0x10000
@@ -44,13 +44,13 @@ module AsciiPack
44
44
  when obj.kind_of?(String)
45
45
  case obj.length
46
46
  when 0...0x10
47
- str4 obj
47
+ fixbin obj
48
48
  when 0x10...0x100
49
- str8 obj
49
+ bin8 obj
50
50
  when 0x100...0x10000
51
- str16 obj
51
+ bin16 obj
52
52
  when 0x10000...0x100000000
53
- str32 obj
53
+ bin32 obj
54
54
  else
55
55
  raise "pack size limit over"
56
56
  end
@@ -89,8 +89,8 @@ module AsciiPack
89
89
  TypeMap.int64 + ((obj & 0xffffffffffffffff).to_s(16))
90
90
  end
91
91
 
92
- def uint4 (obj)
93
- format_uint(TypeMap.uint4, 1, obj)
92
+ def positive_fixint (obj)
93
+ obj.to_s(16).upcase
94
94
  end
95
95
 
96
96
  def uint8 (obj)
@@ -134,28 +134,39 @@ module AsciiPack
134
134
  ])
135
135
  end
136
136
 
137
- def str4 (obj)
138
- format_str TypeMap.str4, 1, obj
137
+ def fixbin (obj)
138
+ (obj.length + 71).chr + obj
139
139
  end
140
140
 
141
- def str8 (obj)
142
- format_str TypeMap.str8, 2, obj
141
+ def bin8 (obj)
142
+ format_bin TypeMap.bin8, 2, obj
143
143
  end
144
144
 
145
- def str16 (obj)
146
- format_str TypeMap.str16, 4, obj
145
+ def bin16 (obj)
146
+ format_bin TypeMap.bin16, 4, obj
147
147
  end
148
148
 
149
- def str32 (obj)
150
- format_str TypeMap.str32, 8, obj
149
+ def bin32 (obj)
150
+ format_bin TypeMap.bin32, 8, obj
151
151
  end
152
152
 
153
153
  def map (obj)
154
- keys = [];
155
- obj.each { |key, value|
156
- keys.push(pack(key.to_s) + pack(value));
157
- }
158
- TypeMap.map + keys.length.to_s + keys.join('');
154
+ keys = [];
155
+ obj.each { |key, value|
156
+ keys.push(pack(key) + pack(value))
157
+ }
158
+ if keys.length < 0x10
159
+ f = [TypeMap.map4, 1]
160
+ elsif keys.length < 0x100
161
+ f = [TypeMap.map8, 2]
162
+ elsif keys.length < 0x10000
163
+ f = [TypeMap.map16, 4]
164
+ elsif keys.length < 0x100000000
165
+ f = [TypeMap.map32, 8]
166
+ else
167
+ raise "pack size limit over"
168
+ end
169
+ format_uint(f[0], f[1], keys.length) + keys.join('');
159
170
  end
160
171
 
161
172
  def array (obj)
@@ -163,7 +174,18 @@ module AsciiPack
163
174
  obj.each { |value|
164
175
  keys.push(pack(value));
165
176
  }
166
- TypeMap.array + keys.length.to_s + keys.join('');
177
+ if keys.length < 0x10
178
+ f = [TypeMap.array4, 1]
179
+ elsif keys.length < 0x100
180
+ f = [TypeMap.array8, 2]
181
+ elsif keys.length < 0x10000
182
+ f = [TypeMap.array16, 4]
183
+ elsif keys.length < 0x100000000
184
+ f = [TypeMap.array32, 8]
185
+ else
186
+ raise "pack size limit over"
187
+ end
188
+ format_uint(f[0], f[1], keys.length) + keys.join('');
167
189
  end
168
190
 
169
191
  def format_uint (type, length, num)
@@ -173,11 +195,11 @@ module AsciiPack
173
195
  type + zero + hex;
174
196
  end
175
197
 
176
- def format_str (type, length, str)
177
- hex = str.length.to_s(16);
198
+ def format_bin (type, length, bin)
199
+ hex = bin.length.to_s(16);
178
200
  len = length - hex.length;
179
201
  zero = '0' * len;
180
- type + zero + hex + str;
202
+ type + zero + hex + bin;
181
203
  end
182
204
 
183
205
  def to_s16 (a)
@@ -1,35 +1,68 @@
1
+ require 'ostruct'
2
+
1
3
  module AsciiPack
2
- class TypeMap
3
- class << self
4
- {
5
- :int4 => 'a',
6
- :int8 => 'b',
7
- :int16 => 'c',
8
- :int32 => 'd',
9
- :int64 => 'e',
10
- :uint4 => 'f',
11
- :uint8 => 'g',
12
- :uint16 => 'h',
13
- :uint32 => 'i',
14
- :uint64 => 'j',
15
- :float32 => 'k',
16
- :float64 => 'l',
17
- :str4 => 'm',
18
- :str8 => 'n',
19
- :str16 => 'o',
20
- :str32 => 'p',
21
- :map => 'q',
22
- :array => 'r',
23
- :nil => 's',
24
- :false => 't',
25
- :true => 'u',
26
- }.each { |name, char|
27
- module_eval %{
28
- def #{name}
29
- "#{char}"
30
- end
31
- }
32
- }
33
- end
34
- end
4
+ TypeMap = OpenStruct.new({
5
+ :int4 => 'a',
6
+ :int8 => 'b',
7
+ :int16 => 'c',
8
+ :int32 => 'd',
9
+ :int64 => 'e',
10
+ # (blank) => 'f',
11
+ :uint8 => 'g',
12
+ :uint16 => 'h',
13
+ :uint32 => 'i',
14
+ :uint64 => 'j',
15
+ :float32 => 'k',
16
+ :float64 => 'l',
17
+ # (blank) => 'm',
18
+ :bin8 => 'n',
19
+ :bin16 => 'o',
20
+ :bin32 => 'p',
21
+ # (blank) => 'q',
22
+ :map4 => 'r',
23
+ :map8 => 's',
24
+ :map16 => 't',
25
+ :map32 => 'u',
26
+ :array4 => 'v',
27
+ :array8 => 'w',
28
+ :array16 => 'x',
29
+ :array32 => 'y',
30
+ # (blank) => 'z',
31
+ :positive_fixint_0 => '0',
32
+ :positive_fixint_1 => '1',
33
+ :positive_fixint_2 => '2',
34
+ :positive_fixint_3 => '3',
35
+ :positive_fixint_4 => '4',
36
+ :positive_fixint_5 => '5',
37
+ :positive_fixint_6 => '6',
38
+ :positive_fixint_7 => '7',
39
+ :positive_fixint_8 => '8',
40
+ :positive_fixint_9 => '9',
41
+ :positive_fixint_A => 'A',
42
+ :positive_fixint_B => 'B',
43
+ :positive_fixint_C => 'C',
44
+ :positive_fixint_D => 'D',
45
+ :positive_fixint_E => 'E',
46
+ :positive_fixint_F => 'F',
47
+ :fixbin_0 => 'G',
48
+ :fixbin_1 => 'H',
49
+ :fixbin_2 => 'I',
50
+ :fixbin_3 => 'J',
51
+ :fixbin_4 => 'K',
52
+ :fixbin_5 => 'L',
53
+ :fixbin_6 => 'M',
54
+ :fixbin_7 => 'N',
55
+ :fixbin_8 => 'O',
56
+ :fixbin_9 => 'P',
57
+ :fixbin_A => 'Q',
58
+ :fixbin_B => 'R',
59
+ :fixbin_C => 'S',
60
+ :fixbin_D => 'T',
61
+ :fixbin_E => 'U',
62
+ :fixbin_F => 'V',
63
+ :nil => 'W',
64
+ :false => 'X',
65
+ :true => 'Y',
66
+ # (blank) => 'Z',
67
+ })
35
68
  end
@@ -12,23 +12,29 @@ module AsciiPack
12
12
  def unpack
13
13
  move
14
14
  case @ch
15
+ when /[0-9A-F]/; positive_fixint
16
+ when /[G-V]/; fixbin
15
17
  when TypeMap.int4; int4
16
18
  when TypeMap.int8; int8
17
19
  when TypeMap.int16; int16
18
20
  when TypeMap.int32; int32
19
21
  when TypeMap.int64; int64
20
- when TypeMap.uint4; uint4
21
22
  when TypeMap.uint8; uint8
22
23
  when TypeMap.uint16; uint16
23
24
  when TypeMap.uint32; uint32
24
25
  when TypeMap.uint64; uint64
25
26
  when TypeMap.float64; float64
26
- when TypeMap.map; map
27
- when TypeMap.array; array
28
- when TypeMap.str4; str4
29
- when TypeMap.str8; str8
30
- when TypeMap.str16; str16
31
- when TypeMap.str32; str32
27
+ when TypeMap.map4; map4
28
+ when TypeMap.map8; map8
29
+ when TypeMap.map16; map16
30
+ when TypeMap.map32; map32
31
+ when TypeMap.array4; array4
32
+ when TypeMap.array8; array8
33
+ when TypeMap.array16; array16
34
+ when TypeMap.array32; array32
35
+ when TypeMap.bin8; bin8
36
+ when TypeMap.bin16; bin16
37
+ when TypeMap.bin32; bin32
32
38
  when TypeMap.nil; nil
33
39
  when TypeMap.false; false
34
40
  when TypeMap.true; true
@@ -40,13 +46,7 @@ private
40
46
 
41
47
  def move
42
48
  @ch = @ap[@at]
43
- @at = @at + 1
44
- @ch
45
- end
46
-
47
- def back
48
- @ch = @ap[@at]
49
- @at -= 1
49
+ @at += 1
50
50
  @ch
51
51
  end
52
52
 
@@ -57,48 +57,38 @@ private
57
57
  @ret
58
58
  end
59
59
 
60
- def length
61
- ret = []
62
- while (/\d/ =~ @ch)
63
- ret << @ch
64
- move()
65
- end
66
- back()
67
- ret.join('').to_i
68
- end
69
-
70
60
  def int4
71
61
  move
72
62
  i = @ch.to_i(16)
73
- return (@ch[0].to_i(16) < 0x8) ? i : i - 0x10;
63
+ (@ch[0].to_i(16) < 0x8) ? i : i - 0x10;
74
64
  end
75
65
 
76
66
  def int8
77
67
  c = cut(2)
78
68
  i = c.to_i(16)
79
- return (c[0].to_i(16) < 0x8) ? i : i - 0x100;
69
+ (c[0].to_i(16) < 0x8) ? i : i - 0x100;
80
70
  end
81
71
 
82
72
  def int16
83
73
  c = cut(4)
84
74
  i = c.to_i(16)
85
- return (c[0].to_i(16) < 0x8) ? i : i - 0x10000;
75
+ (c[0].to_i(16) < 0x8) ? i : i - 0x10000;
86
76
  end
87
77
 
88
78
  def int32
89
79
  c = cut(8)
90
80
  i = c.to_i(16)
91
- return (c[0].to_i(16) < 0x8) ? i : i - 0x100000000;
81
+ (c[0].to_i(16) < 0x8) ? i : i - 0x100000000;
92
82
  end
93
83
 
94
84
  def int64
95
85
  c = cut(16)
96
86
  i = c.to_i(16)
97
- return (c[0].to_i(16) < 0x8) ? i : i - 0x10000000000000000;
87
+ (c[0].to_i(16) < 0x8) ? i : i - 0x10000000000000000;
98
88
  end
99
89
 
100
- def uint4
101
- move.to_i(16)
90
+ def positive_fixint
91
+ @ch.to_i(16)
102
92
  end
103
93
 
104
94
  def uint8
@@ -136,10 +126,9 @@ private
136
126
  ((sign == 0 ? 1 : -1) * frac * (2**(exp - 52))).to_f
137
127
  end
138
128
 
139
- def map
140
- move
129
+ def map (length)
130
+ len = cut(length).to_i(16)
141
131
  hash = {}
142
- len = length()
143
132
  len.times {
144
133
  key = unpack
145
134
  hash[key] = unpack
@@ -147,32 +136,41 @@ private
147
136
  hash
148
137
  end
149
138
 
150
- def array
151
- move
139
+ def map4; map(1) end
140
+ def map8; map(2) end
141
+ def map16; map(4) end
142
+ def map32; map(8) end
143
+
144
+ def array (length)
145
+ len = cut(length).to_i(16)
152
146
  array = []
153
- len = length()
154
147
  len.times {
155
148
  array << unpack
156
149
  }
157
150
  array
158
151
  end
159
152
 
160
- def str4
161
- len = cut(1).to_i(16)
153
+ def array4; array(1) end
154
+ def array8; array(2) end
155
+ def array16; array(4) end
156
+ def array32; array(8) end
157
+
158
+ def fixbin
159
+ len = @ch.ord - 71 # 71 = TypeMap.fixbin_0.ord
162
160
  cut(len)
163
161
  end
164
162
 
165
- def str8
163
+ def bin8
166
164
  len = cut(2).to_i(16)
167
165
  cut(len)
168
166
  end
169
167
 
170
- def str16
168
+ def bin16
171
169
  len = cut(4).to_i(16)
172
170
  cut(len)
173
171
  end
174
172
 
175
- def str32
173
+ def bin32
176
174
  len = cut(8).to_i(16)
177
175
  cut(len)
178
176
  end
@@ -1,3 +1,3 @@
1
1
  module AsciiPack
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/bench.rb CHANGED
@@ -6,32 +6,49 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
  require 'asciipack'
7
7
  require 'json'
8
8
  require 'msgpack'
9
- require 'benchmark'
10
9
 
11
- value = {}
12
- 30.times { |i|
13
- value[i] = case i % 5
14
- when 0; 0xffffffff
15
- when 1; " " * 0xffff
16
- when 2; [1.1, -1.1, 1/3, 5]
17
- when 3; JSON.parse(value.to_json)
18
- when 4; nil
19
- end
20
- }
21
- json = JSON.generate value
22
- ap = AsciiPack.pack value
23
- ms = Marshal.dump value
24
- msg = MessagePack.pack value
25
- n = 10
10
+ def json_asciipack(name, obj)
11
+ obj = [obj]
12
+ json = obj.to_json
13
+ ap = AsciiPack.pack obj
14
+ ms = Marshal.dump obj
15
+ msg = MessagePack.pack obj
16
+
17
+ p '[' + name + ']'
18
+ bench "AsciiPack.pack" do AsciiPack.pack obj end
19
+ bench "AsciiPack.unpack" do AsciiPack.unpack ap end
20
+ bench "JSON.generate" do obj.to_json end
21
+ bench "JSON.parse" do JSON.parse json end
22
+ bench "Marshal.dump" do Marshal.dump obj end
23
+ bench "Marshal.load" do Marshal.load ms end
24
+ bench "MessagePack.pack" do MessagePack.pack obj end
25
+ bench "MessagePack.unpack" do MessagePack.unpack msg end
26
+ p({
27
+ :ap => ap.length,
28
+ :json => json.length,
29
+ :marshal => ms.length,
30
+ :msgpack => msg.length
31
+ })
32
+ end
26
33
 
27
- Benchmark.bm do |x|
28
- x.report("JSON.generate") {n.times{ JSON.generate value }}
29
- x.report("JSON.parse") {n.times{ JSON.parse json }}
30
- x.report("AsciiPack.pack") {n.times{ AsciiPack.pack value }}
31
- x.report("AsciiPack.unpack") {n.times{ AsciiPack.unpack ap }}
32
- x.report("Marshal.dump") {n.times{ Marshal.dump value }}
33
- x.report("Marshal.load") {n.times{ Marshal.load ms }}
34
- x.report("MessagePack.pack") {n.times{ MessagePack.pack value }}
35
- x.report("MessagePack.unpack") {n.times{ MessagePack.unpack msg }}
34
+ def bench(name)
35
+ t = Time.now
36
+ 100000.times {
37
+ yield
38
+ }
39
+ p name + ': ' + (Time.now - t).to_s + 'ms'
36
40
  end
37
41
 
42
+ {
43
+ "positive fixint" => 0,
44
+ "uint 4" => 16,
45
+ "fixbin" => "",
46
+ "bin 8" => '0123456789abcdef',
47
+ "float 64" => 1/3,
48
+ "map 4" => {},
49
+ "array 4" => [],
50
+ "nil" => nil,
51
+ }.each { |key, value|
52
+ json_asciipack key, value
53
+ }
54
+
data/spec/format_spec.rb CHANGED
@@ -1,8 +1,11 @@
1
- # encoding: utf-8
1
+ # encoding: ascii-8bit
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
5
  describe AsciiPack do
6
+ it "intro" do
7
+ expect(AsciiPack.pack({"compact"=>true,"binary"=>0})).to eq('r2NcompactYMbinary0')
8
+ end
6
9
  it "int 4" do
7
10
  format -1, T.int4, 2
8
11
  format -8, T.int4, 2
@@ -28,9 +31,11 @@ describe AsciiPack do
28
31
  format -0x8000000000000000, T.int64, 17
29
32
  end
30
33
 
31
- it "uint 4" do
32
- format 0x0, T.uint4, 2
33
- format 0xf, T.uint4, 2
34
+ it "positive fixint" do
35
+ format 0x0, T.positive_fixint_0, 1
36
+ format 0x1, T.positive_fixint_1, 1
37
+ format 0xe, T.positive_fixint_E, 1
38
+ format 0xf, T.positive_fixint_F, 1
34
39
  end
35
40
 
36
41
  it "uint 8" do
@@ -68,37 +73,69 @@ describe AsciiPack do
68
73
  expect(AsciiPack.pack(-1 / 0.0)).to eq(T.float64 + 'fff0000000000000')
69
74
  end
70
75
 
71
- it "str 4" do
72
- format "", T.str4, 2
73
- format " " * 0xf, T.str4, 17
76
+ it "fixbin" do
77
+ format "", T.fixbin_0, 1
78
+ format " ", T.fixbin_1, 2
79
+ format " " * 0xe, T.fixbin_E, 15
80
+ format " " * 0xf, T.fixbin_F, 16
81
+ end
82
+
83
+ it "bin 8" do
84
+ format "a" * 0x10, T.bin8, 3 + 0x10
85
+ format "a" * 0xff, T.bin8, 3 + 0xff
86
+ end
87
+
88
+ it "bin 16" do
89
+ format "a" * 0x100, T.bin16, 5 + 0x100
90
+ format "a" * 0xffff, T.bin16, 5 + 0xffff
74
91
  end
75
92
 
76
- it "str 8" do
77
- format "a" * 0x10, T.str8, 3 + 0x10
78
- format "a" * 0xff, T.str8, 3 + 0xff
93
+ it "bin 32" do
94
+ format "a" * 0x10000, T.bin32, 9 + 0x10000
95
+ # FIXME too late
96
+ # format "a" * 0xffffffff, T.bin32, 9 + 0xffffffff
79
97
  end
80
98
 
81
- it "str 16" do
82
- format "a" * 0x100, T.str16, 5 + 0x100
83
- format "a" * 0xffff, T.str16, 5 + 0xffff
99
+ it "map 4" do
100
+ format_map 0, T.map4
101
+ format_map 0xf, T.map4
84
102
  end
85
103
 
86
- it "str 32" do
87
- format "a" * 0x10000, T.str32, 9 + 0x10000
88
- # too late
89
- # format "a" * 0xffffffff, T.str32, 9 + 0xffffffff
104
+ it "map 8" do
105
+ format_map 0x10, T.map8
106
+ format_map 0xff, T.map8
90
107
  end
91
108
 
92
- it "map" do
93
- format({}, T.map, 2)
94
- format({"hash" => {}}, T.map, 10)
95
- expect(AsciiPack.pack({})).to eq('q0')
109
+ it "map 16" do
110
+ format_map 0x100, T.map16
111
+ format_map 0xffff, T.map16
96
112
  end
97
113
 
98
- it "array" do
99
- format([], T.array, 2)
100
- format([1,2,3], T.array, 8)
101
- expect(AsciiPack.pack([])).to eq('r0')
114
+ it "map 32" do
115
+ format_map 0x10000, T.map32
116
+ # FIXME too late
117
+ # format_map 0xffffffff, T.map32
118
+ end
119
+
120
+ it "array 4" do
121
+ format_array 0, T.array4
122
+ format_array 0xf, T.array4
123
+ end
124
+
125
+ it "array 8" do
126
+ format_array 0x10, T.array8
127
+ format_array 0xff, T.array8
128
+ end
129
+
130
+ it "array 16" do
131
+ format_array 0x100, T.array16
132
+ format_array 0xffff, T.array16
133
+ end
134
+
135
+ it "array 32" do
136
+ format_array 0x10000, T.array32
137
+ # FIXME too late
138
+ # format_array 0xffffffff, T.array32
102
139
  end
103
140
 
104
141
  it "nil" do
@@ -120,3 +157,19 @@ def format (object, first, length)
120
157
  expect(ap.length).to eq(length)
121
158
  expect(AsciiPack.unpack(ap)).to eq(object)
122
159
  end
160
+
161
+ def format_map (count, first)
162
+ map = {}
163
+ count.times{ |i| map[i] = 0 }
164
+ ap = AsciiPack.pack(map)
165
+ expect(ap[0]).to eq(first)
166
+ expect(AsciiPack.unpack(ap)).to eq(map)
167
+ end
168
+
169
+ def format_array (count, first)
170
+ array = []
171
+ count.times{ |i| array[i] = 0 }
172
+ ap = AsciiPack.pack(array)
173
+ expect(ap[0]).to eq(first)
174
+ expect(AsciiPack.unpack(ap)).to eq(array)
175
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciipack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,9 +65,9 @@ files:
65
65
  - Rakefile
66
66
  - asciipack.gemspec
67
67
  - lib/asciipack.rb
68
- - lib/asciipack/pack.rb
68
+ - lib/asciipack/packer.rb
69
69
  - lib/asciipack/typemap.rb
70
- - lib/asciipack/unpack.rb
70
+ - lib/asciipack/unpacker.rb
71
71
  - lib/asciipack/version.rb
72
72
  - spec/bench.rb
73
73
  - spec/format_spec.rb
@@ -100,3 +100,4 @@ test_files:
100
100
  - spec/bench.rb
101
101
  - spec/format_spec.rb
102
102
  - spec/spec_helper.rb
103
+ has_rdoc: