msgpack 0.5.12-x86-mingw32 → 0.6.0pre1-x86-mingw32

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: 0d89cc8aeefbce6468c2ddbd690bb2ccb4e5213b
4
- data.tar.gz: 44a0cfdf2427fc3c6d52f30cc740cb8d80e9f8e9
3
+ metadata.gz: 5b8cb2059cf2c97ba89464da38b62e22bcdcf68e
4
+ data.tar.gz: c12418e80eac7d2a7a6a501abe1cb7cc4a168fa5
5
5
  SHA512:
6
- metadata.gz: cf586cd027ce0da5948cac89665853ff8a408c14dd225d1399f5dbbc53343241eb8bee54971c3486374da73e9a1a7861cf9b08a3572431ddd7ded41a2060ce93
7
- data.tar.gz: 5e7679948efc387bd4511c80b490e6a743ae5e87701aec36d9ff2f9307ea34a09ca41651a60dc7f762b5ad9914ccd9ea3d93251708723e6113aa88d698dde0ea
6
+ metadata.gz: 2899ded84deadd0e46365efaa7464cd6a5ee7fd8a92362eeaa60db9f360ccdaba58d59d6f1682d1e050dc010b7380e33ac470943a3c4c276437e48440e4079d7
7
+ data.tar.gz: 3c46b4d61e045a6a2ccd52415152b32d8f29460f90d279f5edb5a6c86f7a1f9c890c19ab71a1f20642aa8743d0278d63e79f119e4f7f1ab2f80d2922cb308bbe
data/.gitignore CHANGED
@@ -4,6 +4,8 @@
4
4
  *.gem
5
5
  *.class
6
6
  *.jar
7
+ doc
8
+ .yardoc
7
9
  .bundle
8
10
  Gemfile*
9
11
  pkg
@@ -1,10 +1,9 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- # - 1.8.7
5
- - 1.9.3
6
4
  - 2.0.0
7
- - 2.1
5
+ - 2.1.6
6
+ - 2.2.2
8
7
  - ruby-head
9
8
  - rbx-2
10
9
  - jruby-19mode
@@ -0,0 +1,30 @@
1
+ FROM ubuntu:14.04
2
+ MAINTAINER TAGOMORI Satoshi <tagomoris@gmail.com>
3
+ LABEL Description="Host image to cross-compile msgpack.gem for mingw32" Vendor="MessagePack Organization" Version="1.0"
4
+
5
+ USER ubuntu
6
+
7
+ RUN apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
8
+ RUN apt-get install gcc-mingw32 mingw-w64
9
+ # RUN git?
10
+ RUN git clone https://github.com/tagomoris/xbuild.git /home/ubuntu/.xbuild
11
+ RUN /home/ubuntu/.xbuild/ruby-install 2.2.2 /home/ubuntu/local/ruby-2.2
12
+ RUN PATH=/home/ubuntu/local/ruby-2.2/bin:$PATH /home/ubuntu/local/ruby-2.2/bin/gem install rake-compiler
13
+ RUN PATH=/home/ubuntu/local/ruby-2.2/bin:$PATH rake-compiler cross-ruby VERSION=2.2.2 EXTS=--without-extensions
14
+ RUN /home/ubuntu/.xbuild/ruby-install 2.1.5 /home/ubuntu/local/ruby-2.1
15
+ RUN PATH=/home/ubuntu/local/ruby-2.1/bin:$PATH /home/ubuntu/local/ruby-2.1/bin/gem install rake-compiler
16
+ RUN PATH=/home/ubuntu/local/ruby-2.1/bin:$PATH rake-compiler cross-ruby VERSION=2.1.5 EXTS=--without-extensions
17
+ RUN /home/ubuntu/.xbuild/ruby-install 2.0.0-p643 /home/ubuntu/local/ruby-2.0
18
+ RUN PATH=/home/ubuntu/local/ruby-2.0/bin:$PATH /home/ubuntu/local/ruby-2.0/bin/gem install rake-compiler
19
+ RUN PATH=/home/ubuntu/local/ruby-2.0/bin:$PATH rake-compiler cross-ruby VERSION=2.0.0-p643 EXTS=--without-extensions
20
+
21
+ RUN git clone https://github.com/msgpack/msgpack-ruby.git /home/ubuntu/msgpack-ruby
22
+
23
+ WORKDIR /home/ubuntu/msgpack-ruby
24
+
25
+ ENV MSGPACK_REPO https://github.com/msgpack/msgpack-ruby.git
26
+ ENV BUILD_BRANCH master
27
+ ENV BUILD_POSITION HEAD
28
+
29
+ ENTRYPOINT ["/home/ubuntu/msgpack-ruby/cross-build.sh", "/home/ubuntu/local/ruby-2.2", "2.0.0-p643:2.1.5:2.2.2"]
30
+
data/Rakefile CHANGED
@@ -52,6 +52,7 @@ else
52
52
  ext.ext_dir = 'ext/msgpack'
53
53
  ext.cross_compile = true
54
54
  ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
55
+ ext.config_options << '--with-out-ext=fiddle'
55
56
  #ext.cross_platform = 'i386-mswin32'
56
57
  end
57
58
 
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ cd /home/ubuntu/msgpack-ruby
4
+ git remote add onetime $MSGPACK_REPO
5
+ git checkout master
6
+ git pull onetime $BUILD_BRANCH
7
+ git reset --hard $BUILD_POSITION
8
+ bundle install
9
+ bundle rake cross native gem
@@ -199,11 +199,10 @@ public class Encoder {
199
199
  if (length < 32 && !binary) {
200
200
  ensureRemainingCapacity(1 + length);
201
201
  buffer.put((byte) (length | FIXSTR));
202
- //TODO: msgpack-ruby original does encode this value as RAW16 (currently should be BIN8/STR8)
203
- // } else if (length <= 0xff) {
204
- // ensureRemainingCapacity(2 + length);
205
- // buffer.put(binary ? BIN8 : STR8);
206
- // buffer.put((byte) length);
202
+ } else if (length <= 0xff) {
203
+ ensureRemainingCapacity(2 + length);
204
+ buffer.put(binary ? BIN8 : STR8);
205
+ buffer.put((byte) length);
207
206
  } else if (length <= 0xffff) {
208
207
  ensureRemainingCapacity(3 + length);
209
208
  buffer.put(binary ? BIN16 : STR16);
@@ -19,30 +19,35 @@
19
19
  #include "buffer.h"
20
20
  #include "rmem.h"
21
21
 
22
- #ifdef COMPAT_HAVE_ENCODING /* see compat.h*/
23
- int s_enc_ascii8bit;
24
- #endif
25
-
26
22
  #ifndef HAVE_RB_STR_REPLACE
27
23
  static ID s_replace;
28
24
  #endif
29
25
 
26
+ #ifdef COMPAT_HAVE_ENCODING /* see compat.h*/
27
+ int msgpack_rb_encindex_utf8;
28
+ int msgpack_rb_encindex_usascii;
29
+ int msgpack_rb_encindex_ascii8bit;
30
+ #endif
31
+
30
32
  #ifndef DISABLE_RMEM
31
33
  static msgpack_rmem_t s_rmem;
32
34
  #endif
33
35
 
34
36
  void msgpack_buffer_static_init()
35
37
  {
38
+ #ifdef COMPAT_HAVE_ENCODING
39
+ msgpack_rb_encindex_utf8 = rb_utf8_encindex();
40
+ msgpack_rb_encindex_usascii = rb_usascii_encindex();
41
+ msgpack_rb_encindex_ascii8bit = rb_ascii8bit_encindex();
42
+ #endif
43
+
36
44
  #ifndef DISABLE_RMEM
37
45
  msgpack_rmem_init(&s_rmem);
38
46
  #endif
47
+
39
48
  #ifndef HAVE_RB_STR_REPLACE
40
49
  s_replace = rb_intern("replace");
41
50
  #endif
42
-
43
- #ifdef COMPAT_HAVE_ENCODING
44
- s_enc_ascii8bit = rb_ascii8bit_encindex();
45
- #endif
46
51
  }
47
52
 
48
53
  void msgpack_buffer_static_destroy()
@@ -304,7 +309,7 @@ static inline void _msgpack_buffer_append_reference(msgpack_buffer_t* b, VALUE s
304
309
  {
305
310
  VALUE mapped_string = rb_str_dup(string);
306
311
  #ifdef COMPAT_HAVE_ENCODING
307
- ENCODING_SET(mapped_string, s_enc_ascii8bit);
312
+ ENCODING_SET(mapped_string, msgpack_rb_encindex_ascii8bit);
308
313
  #endif
309
314
 
310
315
  _msgpack_buffer_add_new_chunk(b);
@@ -333,11 +338,11 @@ void _msgpack_buffer_append_long_string(msgpack_buffer_t* b, VALUE string)
333
338
  if(b->io != Qnil) {
334
339
  msgpack_buffer_flush(b);
335
340
  #ifdef COMPAT_HAVE_ENCODING
336
- if (ENCODING_GET(string) == s_enc_ascii8bit) {
341
+ if (ENCODING_GET(string) == msgpack_rb_encindex_ascii8bit) {
337
342
  rb_funcall(b->io, b->io_write_all_method, 1, string);
338
343
  } else if(!STR_DUP_LIKELY_DOES_COPY(string)) {
339
344
  VALUE s = rb_str_dup(string);
340
- ENCODING_SET(s, s_enc_ascii8bit);
345
+ ENCODING_SET(s, msgpack_rb_encindex_ascii8bit);
341
346
  rb_funcall(b->io, b->io_write_all_method, 1, s);
342
347
  } else {
343
348
  msgpack_buffer_append(b, RSTRING_PTR(string), length);
@@ -49,6 +49,12 @@
49
49
 
50
50
  #define NO_MAPPED_STRING ((VALUE)0)
51
51
 
52
+ #ifdef COMPAT_HAVE_ENCODING /* see compat.h*/
53
+ extern int msgpack_rb_encindex_utf8;
54
+ extern int msgpack_rb_encindex_usascii;
55
+ extern int msgpack_rb_encindex_ascii8bit;
56
+ #endif
57
+
52
58
  struct msgpack_buffer_chunk_t;
53
59
  typedef struct msgpack_buffer_chunk_t msgpack_buffer_chunk_t;
54
60
 
@@ -66,7 +66,6 @@ static inline void msgpack_packer_set_io(msgpack_packer_t* pk, VALUE io, ID io_w
66
66
 
67
67
  void msgpack_packer_reset(msgpack_packer_t* pk);
68
68
 
69
-
70
69
  static inline void msgpack_packer_write_nil(msgpack_packer_t* pk)
71
70
  {
72
71
  msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 1);
@@ -271,6 +270,10 @@ static inline void msgpack_packer_write_raw_header(msgpack_packer_t* pk, unsigne
271
270
  msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 1);
272
271
  unsigned char h = 0xa0 | (uint8_t) n;
273
272
  msgpack_buffer_write_1(PACKER_BUFFER_(pk), h);
273
+ } else if(n < 256) {
274
+ msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 2);
275
+ unsigned char be = (uint8_t) n;
276
+ msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xd9, (const void*)&be, 1);
274
277
  } else if(n < 65536) {
275
278
  msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 3);
276
279
  uint16_t be = _msgpack_be16(n);
@@ -282,6 +285,23 @@ static inline void msgpack_packer_write_raw_header(msgpack_packer_t* pk, unsigne
282
285
  }
283
286
  }
284
287
 
288
+ static inline void msgpack_packer_write_bin_header(msgpack_packer_t* pk, unsigned int n)
289
+ {
290
+ if(n < 256) {
291
+ msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 1);
292
+ unsigned char be = (uint8_t) n;
293
+ msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xc4, (const void*)&be, 1);
294
+ } else if(n < 65536) {
295
+ msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 3);
296
+ uint16_t be = _msgpack_be16(n);
297
+ msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xc5, (const void*)&be, 2);
298
+ } else {
299
+ msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 5);
300
+ uint32_t be = _msgpack_be32(n);
301
+ msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xc6, (const void*)&be, 4);
302
+ }
303
+ }
304
+
285
305
  static inline void msgpack_packer_write_array_header(msgpack_packer_t* pk, unsigned int n)
286
306
  {
287
307
  if(n < 16) {
@@ -316,8 +336,25 @@ static inline void msgpack_packer_write_map_header(msgpack_packer_t* pk, unsigne
316
336
  }
317
337
  }
318
338
 
339
+ #ifdef COMPAT_HAVE_ENCODING
340
+ static inline bool msgpack_packer_is_binary(VALUE v, int encindex)
341
+ {
342
+ return encindex == msgpack_rb_encindex_ascii8bit;
343
+ }
319
344
 
320
- void _msgpack_packer_write_string_to_io(msgpack_packer_t* pk, VALUE string);
345
+ static inline bool msgpack_packer_is_utf8_compat_string(VALUE v, int encindex)
346
+ {
347
+ return encindex == msgpack_rb_encindex_utf8
348
+ || encindex == msgpack_rb_encindex_usascii
349
+ #ifdef ENC_CODERANGE_ASCIIONLY
350
+ /* Because ENC_CODERANGE_ASCIIONLY does not scan string, it may return ENC_CODERANGE_UNKNOWN unlike */
351
+ /* rb_enc_str_asciionly_p. It is always faster than rb_str_encode if it is available. */
352
+ /* Very old Rubinius (< v1.3.1) doesn't have ENC_CODERANGE_ASCIIONLY. */
353
+ || (rb_enc_asciicompat(rb_enc_from_index(encindex)) && ENC_CODERANGE_ASCIIONLY(v))
354
+ #endif
355
+ ;
356
+ }
357
+ #endif
321
358
 
322
359
  static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE v)
323
360
  {
@@ -328,8 +365,28 @@ static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE
328
365
  // TODO rb_eArgError?
329
366
  rb_raise(rb_eArgError, "size of string is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
330
367
  }
368
+
369
+ #ifdef COMPAT_HAVE_ENCODING
370
+ int encindex = ENCODING_GET(v);
371
+ if(msgpack_packer_is_binary(v, encindex)) {
372
+ /* write ASCII-8BIT string using Binary type */
373
+ msgpack_packer_write_bin_header(pk, (unsigned int)len);
374
+ msgpack_buffer_append_string(PACKER_BUFFER_(pk), v);
375
+ } else {
376
+ /* write UTF-8, US-ASCII, or 7bit-safe ascii-compatible string using String type directly */
377
+ if(!msgpack_packer_is_utf8_compat_string(v, encindex)) {
378
+ /* transcode other strings to UTF-8 and write using String type */
379
+ VALUE enc = rb_enc_from_encoding(rb_utf8_encoding()); /* rb_enc_from_encoding_index is not extern */
380
+ v = rb_str_encode(v, enc, 0, Qnil);
381
+ len = RSTRING_LEN(v);
382
+ }
383
+ msgpack_packer_write_raw_header(pk, (unsigned int)len);
384
+ msgpack_buffer_append_string(PACKER_BUFFER_(pk), v);
385
+ }
386
+ #else
331
387
  msgpack_packer_write_raw_header(pk, (unsigned int)len);
332
388
  msgpack_buffer_append_string(PACKER_BUFFER_(pk), v);
389
+ #endif
333
390
  }
334
391
 
335
392
  static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE v)
@@ -28,19 +28,11 @@
28
28
  static msgpack_rmem_t s_stack_rmem;
29
29
  #endif
30
30
 
31
- #ifdef COMPAT_HAVE_ENCODING /* see compat.h*/
32
- static int s_enc_utf8;
33
- #endif
34
-
35
31
  void msgpack_unpacker_static_init()
36
32
  {
37
33
  #ifdef UNPACKER_STACK_RMEM
38
34
  msgpack_rmem_init(&s_stack_rmem);
39
35
  #endif
40
-
41
- #ifdef COMPAT_HAVE_ENCODING
42
- s_enc_utf8 = rb_utf8_encindex();
43
- #endif
44
36
  }
45
37
 
46
38
  void msgpack_unpacker_static_destroy()
@@ -149,9 +141,17 @@ static inline int object_complete(msgpack_unpacker_t* uk, VALUE object)
149
141
 
150
142
  static inline int object_complete_string(msgpack_unpacker_t* uk, VALUE str)
151
143
  {
144
+ #ifdef COMPAT_HAVE_ENCODING
145
+ ENCODING_SET(str, msgpack_rb_encindex_utf8);
146
+ #endif
147
+ return object_complete(uk, str);
148
+ }
149
+
150
+ static inline int object_complete_binary(msgpack_unpacker_t* uk, VALUE str)
151
+ {
152
152
  #ifdef COMPAT_HAVE_ENCODING
153
153
  // TODO ruby 2.0 has String#b method
154
- ENCODING_SET(str, s_enc_utf8);
154
+ ENCODING_SET(str, msgpack_rb_encindex_ascii8bit);
155
155
  #endif
156
156
  return object_complete(uk, str);
157
157
  }
@@ -258,7 +258,11 @@ static inline int read_raw_body_begin(msgpack_unpacker_t* uk, bool str)
258
258
  * because rb_hash_aset freezes keys and it causes copying */
259
259
  bool will_freeze = is_reading_map_key(uk);
260
260
  VALUE string = msgpack_buffer_read_top_as_string(UNPACKER_BUFFER_(uk), length, will_freeze);
261
- object_complete_string(uk, string);
261
+ if(str == true) {
262
+ object_complete_string(uk, string);
263
+ } else {
264
+ object_complete_binary(uk, string);
265
+ }
262
266
  if(will_freeze) {
263
267
  rb_obj_freeze(string);
264
268
  }
@@ -427,7 +431,7 @@ static int read_primitive(msgpack_unpacker_t* uk)
427
431
  return read_raw_body_begin(uk, true);
428
432
  }
429
433
 
430
- case 0xdb: // raw 32 / str 16
434
+ case 0xdb: // raw 32 / str 32
431
435
  {
432
436
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 4);
433
437
  uint32_t count = _msgpack_be32(cb->u32);
@@ -444,7 +448,7 @@ static int read_primitive(msgpack_unpacker_t* uk)
444
448
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 1);
445
449
  uint8_t count = cb->u8;
446
450
  if(count == 0) {
447
- return object_complete_string(uk, rb_str_buf_new(0));
451
+ return object_complete_binary(uk, rb_str_buf_new(0));
448
452
  }
449
453
  /* read_raw_body_begin sets uk->reading_raw */
450
454
  uk->reading_raw_remaining = count;
@@ -456,7 +460,7 @@ static int read_primitive(msgpack_unpacker_t* uk)
456
460
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 2);
457
461
  uint16_t count = _msgpack_be16(cb->u16);
458
462
  if(count == 0) {
459
- return object_complete_string(uk, rb_str_buf_new(0));
463
+ return object_complete_binary(uk, rb_str_buf_new(0));
460
464
  }
461
465
  /* read_raw_body_begin sets uk->reading_raw */
462
466
  uk->reading_raw_remaining = count;
@@ -468,7 +472,7 @@ static int read_primitive(msgpack_unpacker_t* uk)
468
472
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 4);
469
473
  uint32_t count = _msgpack_be32(cb->u32);
470
474
  if(count == 0) {
471
- return object_complete_string(uk, rb_str_buf_new(0));
475
+ return object_complete_binary(uk, rb_str_buf_new(0));
472
476
  }
473
477
  /* read_raw_body_begin sets uk->reading_raw */
474
478
  uk->reading_raw_remaining = count;
@@ -1,3 +1,3 @@
1
1
  module MessagePack
2
- VERSION = "0.5.12"
2
+ VERSION = "0.6.0pre1"
3
3
  end
@@ -262,36 +262,42 @@ describe Unpacker do
262
262
 
263
263
  it "msgpack str 8 type" do
264
264
  MessagePack.unpack([0xd9, 0x00].pack('C*')).should == ""
265
+ MessagePack.unpack([0xd9, 0x00].pack('C*')).encoding.should == Encoding::UTF_8
265
266
  MessagePack.unpack([0xd9, 0x01].pack('C*') + 'a').should == "a"
266
267
  MessagePack.unpack([0xd9, 0x02].pack('C*') + 'aa').should == "aa"
267
268
  end
268
269
 
269
270
  it "msgpack str 16 type" do
270
271
  MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).should == ""
272
+ MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).encoding.should == Encoding::UTF_8
271
273
  MessagePack.unpack([0xda, 0x00, 0x01].pack('C*') + 'a').should == "a"
272
274
  MessagePack.unpack([0xda, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
273
275
  end
274
276
 
275
277
  it "msgpack str 32 type" do
276
278
  MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
279
+ MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).encoding.should == Encoding::UTF_8
277
280
  MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
278
281
  MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
279
282
  end
280
283
 
281
284
  it "msgpack bin 8 type" do
282
285
  MessagePack.unpack([0xc4, 0x00].pack('C*')).should == ""
286
+ MessagePack.unpack([0xc4, 0x00].pack('C*')).encoding.should == Encoding::ASCII_8BIT
283
287
  MessagePack.unpack([0xc4, 0x01].pack('C*') + 'a').should == "a"
284
288
  MessagePack.unpack([0xc4, 0x02].pack('C*') + 'aa').should == "aa"
285
289
  end
286
290
 
287
291
  it "msgpack bin 16 type" do
288
292
  MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).should == ""
293
+ MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).encoding.should == Encoding::ASCII_8BIT
289
294
  MessagePack.unpack([0xc5, 0x00, 0x01].pack('C*') + 'a').should == "a"
290
295
  MessagePack.unpack([0xc5, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
291
296
  end
292
297
 
293
298
  it "msgpack bin 32 type" do
294
299
  MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
300
+ MessagePack.unpack([0xc6, 0x0, 0x00, 0x00, 0x000].pack('C*')).encoding.should == Encoding::ASCII_8BIT
295
301
  MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
296
302
  MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
297
303
  end
@@ -83,8 +83,13 @@ describe MessagePack do
83
83
  check_raw 1, (1 << 5)-1
84
84
  end
85
85
 
86
+ it "raw 8" do
87
+ check_raw 2, (1 << 5)
88
+ check_raw 2, (1 << 8)-1
89
+ end
90
+
86
91
  it "raw 16" do
87
- check_raw 3, (1 << 5)
92
+ check_raw 3, (1 << 8)
88
93
  check_raw 3, (1 << 16)-1
89
94
  end
90
95
 
@@ -93,6 +98,50 @@ describe MessagePack do
93
98
  #check_raw 5, (1 << 32)-1 # memory error
94
99
  end
95
100
 
101
+ it "str encoding is UTF_8" do
102
+ v = pack_unpack('string'.force_encoding(Encoding::UTF_8))
103
+ v.encoding.should == Encoding::UTF_8
104
+ end
105
+
106
+ it "str transcode US-ASCII" do
107
+ v = pack_unpack('string'.force_encoding(Encoding::US_ASCII))
108
+ v.encoding.should == Encoding::UTF_8
109
+ end
110
+
111
+ it "str transcode UTF-16" do
112
+ v = pack_unpack('string'.encode(Encoding::UTF_16))
113
+ v.encoding.should == Encoding::UTF_8
114
+ v.should == 'string'
115
+ end
116
+
117
+ it "str transcode EUC-JP 7bit safe" do
118
+ v = pack_unpack('string'.force_encoding(Encoding::EUC_JP))
119
+ v.encoding.should == Encoding::UTF_8
120
+ v.should == 'string'
121
+ end
122
+
123
+ it "str transcode EUC-JP 7bit unsafe" do
124
+ v = pack_unpack([0xa4, 0xa2].pack('C*').force_encoding(Encoding::EUC_JP))
125
+ v.encoding.should == Encoding::UTF_8
126
+ v.should == "\xE3\x81\x82".force_encoding('UTF-8')
127
+ end
128
+
129
+ it "bin 8" do
130
+ check_bin 2, (1<<8)-1
131
+ end
132
+
133
+ it "bin 16" do
134
+ check_bin 3, (1<<16)-1
135
+ end
136
+
137
+ it "bin 32" do
138
+ check_bin 5, (1<<16)
139
+ end
140
+
141
+ it "bin encoding is ASCII_8BIT" do
142
+ pack_unpack('string'.force_encoding(Encoding::ASCII_8BIT)).encoding.should == Encoding::ASCII_8BIT
143
+ end
144
+
96
145
  it "fixarray" do
97
146
  check_array 1, 0
98
147
  check_array 1, (1 << 4)-1
@@ -210,9 +259,11 @@ describe MessagePack do
210
259
  end
211
260
 
212
261
  def check_raw(overhead, num)
213
- rawstr = " "*num
214
- rawstr.force_encoding("UTF-8")
215
- check num+overhead, rawstr
262
+ check num+overhead, (" "*num).force_encoding(Encoding::UTF_8)
263
+ end
264
+
265
+ def check_bin(overhead, num)
266
+ check num+overhead, (" "*num).force_encoding(Encoding::ASCII_8BIT)
216
267
  end
217
268
 
218
269
  def check_array(overhead, num)
@@ -223,5 +274,9 @@ describe MessagePack do
223
274
  raw = obj.to_msgpack.to_s
224
275
  raw.should == buf
225
276
  end
277
+
278
+ def pack_unpack(obj)
279
+ MessagePack.unpack(obj.to_msgpack)
280
+ end
226
281
  end
227
282
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.12
4
+ version: 0.6.0pre1
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Sadayuki Furuhashi
@@ -108,6 +108,7 @@ files:
108
108
  - ".gitignore"
109
109
  - ".travis.yml"
110
110
  - ChangeLog
111
+ - Dockerfile
111
112
  - Gemfile
112
113
  - LICENSE
113
114
  - README.rdoc
@@ -120,6 +121,7 @@ files:
120
121
  - bench/unpack.rb
121
122
  - bench/unpack_log.rb
122
123
  - bench/unpack_log_long.rb
124
+ - cross-build.sh
123
125
  - doclib/msgpack.rb
124
126
  - doclib/msgpack/buffer.rb
125
127
  - doclib/msgpack/core_ext.rb
@@ -195,9 +197,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
197
  version: '0'
196
198
  required_rubygems_version: !ruby/object:Gem::Requirement
197
199
  requirements:
198
- - - ">="
200
+ - - ">"
199
201
  - !ruby/object:Gem::Version
200
- version: '0'
202
+ version: 1.3.1
201
203
  requirements: []
202
204
  rubyforge_project: msgpack
203
205
  rubygems_version: 2.4.5