cbor 0.5.6.4 → 0.5.8.0

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: fbd9f75a0950815388c8f87da0acab19c6227e5a
4
- data.tar.gz: 0d7d54f3811162926eff2af8d1a56a36ceaac85f
3
+ metadata.gz: f05161e936a40f076ec1389e1c2e0b3c780603b4
4
+ data.tar.gz: 73ee9389cd9fdd7c826caef32f8730340c29a019
5
5
  SHA512:
6
- metadata.gz: a51ccc3cf050a569b3be7a80bdc848b04cd80b9a31338c485e0fce3277c1c7d2b37c21eebcbd054b11c8c911c81937c634bdd1acd3c7f82a1e15b9438957b8a1
7
- data.tar.gz: 8c3a923d73a8539b576a8e63c8c5e7bf1b11f88b26386880e57af55a19c75b39bb18aa46ced3bd3583f2ea99032d210046731fbcc143d01fbc04b5711cb3dc7d
6
+ metadata.gz: dc63dfca2f83dfba9fabaffed1b9142df775dbd05c47f541b5127428545dc1c5700148326662e57b1a0f5572af56367cf0a522d91bc52cea8d621730542942f8
7
+ data.tar.gz: ca747d537cdd17c53f060819c45c22309859295a958d919a086e52496ef7a484f641e0e5f67c0da45bdb24e8013a4ce06cdb8a1a30d6e449e22614f445a206ff
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  # - rbx-19mode
6
+ - 2.1.0
6
7
  - ruby-head
7
8
  matrix:
8
9
  allow_failures:
@@ -1,6 +1,6 @@
1
1
  = CBOR for Ruby
2
2
 
3
- This is an initial Ruby implementation of the CBOR encoding, based on
3
+ This is a Ruby implementation of the CBOR[http://cbor.io] encoding, based on
4
4
  the (polished) high-performance msgpack-ruby code.
5
5
 
6
6
  Documentation will follow, but generally, if you replace MessagePack
@@ -37,12 +37,14 @@ Todos:
37
37
  get some documentation in the directory +doc+ (see +index.html+ there).
38
38
 
39
39
  * Cover more rubies.
40
- * \[✔✔✔] tested on MRI (1.9.3, 2.0.0, 2.1.0-preview1).
40
+ * \[✔✔✔] tested on MRI (1.9.3, 2.0.0, 2.1.0, head).
41
+ * (\[✔] There now also is some basic MRI 1.8.7 compatibility, however 1.8.7 does not support differentiation between byte and text strings.)
41
42
  * \[(✔)] tested on Rubinius 2.1.1. Mostly works, but runs into a few Rubinius bugs, which have since been fixed on the Rubinius side. Need to retest on the next release.
42
43
  * \[_] Publish the pure-ruby version and make it work the same way on JRuby.
43
44
 
44
45
  * Find and implement good ways to offer CBOR's indefinite length
45
- ("streaming") capability at the Ruby API level.
46
+ ("streaming") capability at the Ruby API level. (Decoding is fully
47
+ supported, just no streaming or indefinite length encoding.)
46
48
 
47
49
  * Rename some of the internals from msgpack to cbor. Right now, much
48
50
  of the code still uses the name msgpack in its identifiers, to
@@ -53,7 +55,7 @@ Same Apache 2.0 License applies to the changes as to the original.
53
55
  For the changes:
54
56
 
55
57
  Author:: Carsten Bormann <cabo@tzi.org>
56
- Copyright:: Copyright (c) 2013 Carsten Bormann
58
+ Copyright:: Copyright (c) 2013, 2014 Carsten Bormann
57
59
  License:: Apache License, Version 2.0
58
60
 
59
61
  {<img src="https://travis-ci.org/cabo/cbor-ruby.png?branch=master" />}[https://travis-ci.org/cabo/cbor-ruby] {<img src="https://badge.fury.io/rb/cbor.png" alt="Gem Version" />}[http://badge.fury.io/rb/cbor]
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.author = "Carsten Bormann, standing on the tall shoulders of Sadayuki Furuhashi"
10
10
  s.email = "cabo@tzi.org"
11
11
  s.license = "Apache 2.0"
12
- # s.homepage = "http://msgpack.org/"
12
+ s.homepage = "http://cbor.io/"
13
13
  # s.rubyforge_project = "msgpack"
14
14
  s.has_rdoc = false
15
15
  s.files = `git ls-files`.split("\n")
@@ -454,7 +454,17 @@ static inline VALUE msgpack_buffer_read_top_as_string(msgpack_buffer_t* b, size_
454
454
 
455
455
  VALUE result;
456
456
  if (as_symbol) {
457
+ #ifndef HAVE_RB_INTERN_STR
458
+ /* MRI 1.8 doesn't have rb_intern_str or rb_intern2, hack it... */
459
+ char *tmp = xmalloc(length+1);
460
+ memcpy(tmp, b->read_buffer, length);
461
+ tmp[length] = 0;
462
+ result = ID2SYM(rb_intern(tmp));
463
+ xfree(tmp);
464
+ #else
457
465
  result = ID2SYM(rb_intern2(b->read_buffer, length));
466
+ /* FIXME: This is stuck at ASCII encoding */
467
+ #endif
458
468
  /* todo: rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc) */
459
469
  } else {
460
470
  result = rb_str_new(b->read_buffer, length);
@@ -116,10 +116,16 @@
116
116
  #define RBIGNUM_DIGITS(b) (RBIGNUM(b)->digits)
117
117
  #endif
118
118
  #ifndef HAVE_RB_BIG_NEW
119
+ /* not really worth fixing any more... */
120
+ #define CANT_DO_BIGNUMS_FAST_ON_THIS_PLATFORM
119
121
  /* gross 1.8.7 hack thanks to Mathieu Bouchard <matju@artengine.ca> */
120
122
  #define rb_big_new(len, sign) rb_funcall(INT2FIX(1),rb_intern("<<"),1,INT2FIX(len > 0 ? ((len) * SIZEOF_BDIGITS * 8) - 1 : 0));
121
123
  #endif
122
124
 
125
+ #ifndef RB_TYPE_P
126
+ #define RB_TYPE_P(obj, type) (TYPE(obj) == (type))
127
+ #endif
128
+
123
129
  /*
124
130
  * RSTRING_PTR, RSTRING_LEN
125
131
  */
@@ -4,6 +4,7 @@ have_header("ruby/st.h")
4
4
  have_header("st.h")
5
5
  have_func("rb_str_replace", ["ruby.h"])
6
6
  have_func("rb_big_new", ["ruby.h"])
7
+ have_func("rb_intern_str", ["ruby.h"])
7
8
 
8
9
  $CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
9
10
  #$CFLAGS << %[ -DDISABLE_RMEM]
@@ -87,7 +87,7 @@ static VALUE Unpacker_initialize(int argc, VALUE* argv, VALUE self)
87
87
  io = argv[0];
88
88
  options = argv[1];
89
89
  if(rb_type(options) != T_HASH) {
90
- rb_raise(rb_eArgError, "expected Hash but found %s.", rb_obj_classname(io));
90
+ rb_raise(rb_eArgError, "expected Hash but found %s.", rb_obj_classname(options));
91
91
  }
92
92
 
93
93
  } else {
@@ -97,6 +97,11 @@ static VALUE Unpacker_initialize(int argc, VALUE* argv, VALUE self)
97
97
  UNPACKER(self, uk);
98
98
  if(io != Qnil || options != Qnil) {
99
99
  MessagePack_Buffer_initialize(UNPACKER_BUFFER_(uk), io, options);
100
+ if (options != Qnil) {
101
+ VALUE v;
102
+ v = rb_hash_aref(options, ID2SYM(rb_intern("symbolize_keys")));
103
+ uk->keys_as_symbols = RTEST(v);
104
+ }
100
105
  }
101
106
 
102
107
  // TODO options
@@ -305,10 +310,16 @@ VALUE MessagePack_unpack(int argc, VALUE* argv)
305
310
  switch(argc) {
306
311
  case 2:
307
312
  options = argv[1]; /* Experimental! */
308
- if (options == ID2SYM(rb_intern("keys_as_symbols")))
313
+ if (options == ID2SYM(rb_intern("keys_as_symbols"))) /* backward compat */
309
314
  keys_as_symbols = true;
310
- else
311
- rb_raise(rb_eArgError, "unknown option");
315
+ else if (options != Qnil) {
316
+ VALUE v;
317
+ if (!RB_TYPE_P(options, T_HASH)) {
318
+ rb_raise(rb_eArgError, "expected Hash but found %s.", rb_obj_classname(options));
319
+ }
320
+ v = rb_hash_aref(options, ID2SYM(rb_intern("symbolize_keys")));
321
+ keys_as_symbols = RTEST(v);
322
+ }
312
323
  /* fall through */
313
324
  case 1:
314
325
  src = argv[0];
@@ -1,9 +1,6 @@
1
- here = File.expand_path(File.dirname(__FILE__))
2
- require File.join(here, 'cbor', 'version')
1
+ require "cbor/version"
3
2
  begin
4
- m = /(\d+.\d+)/.match(RUBY_VERSION)
5
- ver = m[1]
6
- require File.join(here, 'cbor', ver, 'cbor')
3
+ require "cbor/#{RUBY_VERSION[/\d+.\d+/]}/cbor"
7
4
  rescue LoadError
8
- require File.join(here, 'cbor', 'cbor')
5
+ require "cbor/cbor"
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module CBOR
2
- VERSION = "0.5.6.4"
2
+ VERSION = "0.5.8.0"
3
3
  end
@@ -390,11 +390,23 @@ describe MessagePack do
390
390
  end
391
391
 
392
392
  it "Keys as Symbols" do # Experimental!
393
- CBOR.decode(CBOR.encode({a: 1}), :keys_as_symbols).should == {a: 1}
394
- CBOR.decode(CBOR.encode({a: 1})).should == {"a" => 1}
393
+ CBOR.decode(CBOR.encode({:a => 1}), :keys_as_symbols).should == {:a => 1}
394
+ CBOR.decode(CBOR.encode({:a => 1})).should == {"a" => 1}
395
395
  expect { CBOR.decode("\x00", :foobar) }.to raise_error(ArgumentError)
396
396
  end
397
397
 
398
+ it 'CBOR.decode symbolize_keys' do
399
+ symbolized_hash = {:a => 'b', :c => 'd'}
400
+ CBOR.decode(CBOR.encode(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
401
+ end
402
+
403
+ it 'Unpacker#read symbolize_keys' do
404
+ unpacker = Unpacker.new(:symbolize_keys => true)
405
+ symbolized_hash = {:a => 'b', :c => 'd'}
406
+ unpacker.feed(CBOR.encode(symbolized_hash)).read.should == symbolized_hash
407
+ end
408
+
409
+
398
410
  ## FIXME
399
411
  # it "{0=>0, 1=>1, ..., 14=>14}" do
400
412
  # a = (0..14).to_a;
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.4
4
+ version: 0.5.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann, standing on the tall shoulders of Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-08 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.9.2
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.9.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake-compiler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.8.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.8.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.11'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.11'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.7'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.7'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: yard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.8.2
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.8.2
97
97
  description: CBOR is a library for the CBOR binary object representation format, based
@@ -102,8 +102,8 @@ extensions:
102
102
  - ext/cbor/extconf.rb
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - .gitignore
106
- - .travis.yml
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
107
  - ChangeLog
108
108
  - Gemfile
109
109
  - README.rdoc
@@ -156,7 +156,7 @@ files:
156
156
  - spec/random_compat.rb
157
157
  - spec/spec_helper.rb
158
158
  - spec/unpacker_spec.rb
159
- homepage:
159
+ homepage: http://cbor.io/
160
160
  licenses:
161
161
  - Apache 2.0
162
162
  metadata: {}
@@ -166,17 +166,17 @@ require_paths:
166
166
  - lib
167
167
  required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - '>='
169
+ - - ">="
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - '>='
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.0.3
179
+ rubygems_version: 2.2.2
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: CBOR, Concise Binary Object Representation.
@@ -194,3 +194,4 @@ test_files:
194
194
  - spec/random_compat.rb
195
195
  - spec/spec_helper.rb
196
196
  - spec/unpacker_spec.rb
197
+ has_rdoc: false