cbor 0.5.6.2 → 0.5.6.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +8 -0
- data/ChangeLog +5 -0
- data/Gemfile +11 -0
- data/README.rdoc +18 -9
- data/ext/cbor/unpacker.c +4 -0
- data/lib/cbor/version.rb +1 -1
- data/spec/format_spec.rb +19 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbd9f75a0950815388c8f87da0acab19c6227e5a
|
4
|
+
data.tar.gz: 0d7d54f3811162926eff2af8d1a56a36ceaac85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a51ccc3cf050a569b3be7a80bdc848b04cd80b9a31338c485e0fce3277c1c7d2b37c21eebcbd054b11c8c911c81937c634bdd1acd3c7f82a1e15b9438957b8a1
|
7
|
+
data.tar.gz: 8c3a923d73a8539b576a8e63c8c5e7bf1b11f88b26386880e57af55a19c75b39bb18aa46ced3bd3583f2ea99032d210046731fbcc143d01fbc04b5711cb3dc7d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
data/Gemfile
ADDED
data/README.rdoc
CHANGED
@@ -4,13 +4,21 @@ This is an initial Ruby implementation of the CBOR 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
|
7
|
-
and msgpack with CBOR and cbor in the
|
8
|
-
track.
|
7
|
+
and msgpack with CBOR and cbor in the text cited from MessagePack
|
8
|
+
below, you will be on the right track. For a starter:
|
9
|
+
|
10
|
+
require 'cbor'
|
11
|
+
s = [1, 2, 33.5, 4].to_cbor #=> "\x84\x01\x02\xF9P0\x04"
|
12
|
+
CBOR.decode(s) #=> [1, 2, 33.5, 4]
|
13
|
+
|
14
|
+
Use RubyGems to install:
|
15
|
+
|
16
|
+
gem install cbor
|
9
17
|
|
10
18
|
CBOR is an object representation format defined by the IETF[http://ietf.org].
|
11
|
-
The specification[http://tools.ietf.org/html/
|
19
|
+
The specification[http://tools.ietf.org/html/rfc7049]
|
12
20
|
has recently been approved as an IETF Standards-Track specification
|
13
|
-
and
|
21
|
+
and has been published as RFC 7049.
|
14
22
|
|
15
23
|
This is all based on wonderful work by frsyuki, and I have no idea how
|
16
24
|
to acknowledge him appropriately. This gem is not intended to fork or
|
@@ -25,12 +33,13 @@ Todos:
|
|
25
33
|
percent slower than msgpack-ruby.
|
26
34
|
|
27
35
|
* Properly document things, in particular the classes CBOR::Simple and
|
28
|
-
CBOR::Tagged. If you check out the source, you can +rake doc+ to
|
36
|
+
CBOR::Tagged. If you check out the source, you can +rake+ +doc+ to
|
29
37
|
get some documentation in the directory +doc+ (see +index.html+ there).
|
30
38
|
|
31
|
-
*
|
32
|
-
*
|
33
|
-
*
|
39
|
+
* Cover more rubies.
|
40
|
+
* \[✔✔✔] tested on MRI (1.9.3, 2.0.0, 2.1.0-preview1).
|
41
|
+
* \[(✔)] 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
|
+
* \[_] Publish the pure-ruby version and make it work the same way on JRuby.
|
34
43
|
|
35
44
|
* Find and implement good ways to offer CBOR's indefinite length
|
36
45
|
("streaming") capability at the Ruby API level.
|
@@ -47,7 +56,7 @@ Author:: Carsten Bormann <cabo@tzi.org>
|
|
47
56
|
Copyright:: Copyright (c) 2013 Carsten Bormann
|
48
57
|
License:: Apache License, Version 2.0
|
49
58
|
|
50
|
-
{<img src="https://travis-ci.org/cabo/cbor-ruby.png?branch=master" />}[https://travis-ci.org/cabo/cbor-ruby]
|
59
|
+
{<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]
|
51
60
|
|
52
61
|
For the original, see below.
|
53
62
|
|
data/ext/cbor/unpacker.c
CHANGED
@@ -583,6 +583,8 @@ int msgpack_unpacker_read(msgpack_unpacker_t* uk, size_t target_stack_depth)
|
|
583
583
|
/* PRIMITIVE_OBJECT_COMPLETE */
|
584
584
|
|
585
585
|
if(msgpack_unpacker_stack_is_empty(uk)) {
|
586
|
+
if (r == PRIMITIVE_BREAK)
|
587
|
+
return PRIMITIVE_INVALID_BYTE;
|
586
588
|
return PRIMITIVE_OBJECT_COMPLETE;
|
587
589
|
}
|
588
590
|
|
@@ -627,6 +629,8 @@ int msgpack_unpacker_read(msgpack_unpacker_t* uk, size_t target_stack_depth)
|
|
627
629
|
object_complete_string(uk, top->object, top->count); /* use count as textflag */
|
628
630
|
goto done;
|
629
631
|
}
|
632
|
+
if (!RB_TYPE_P(uk->last_object, T_STRING))
|
633
|
+
return PRIMITIVE_INVALID_BYTE;
|
630
634
|
#ifdef COMPAT_HAVE_ENCODING /* XXX */
|
631
635
|
if (ENCODING_GET(top->object) != ENCODING_GET(uk->last_object))
|
632
636
|
return PRIMITIVE_INVALID_BYTE;
|
data/lib/cbor/version.rb
CHANGED
data/spec/format_spec.rb
CHANGED
@@ -342,13 +342,31 @@ describe MessagePack do
|
|
342
342
|
end
|
343
343
|
end
|
344
344
|
|
345
|
+
it "(_ not-a-string)" do
|
346
|
+
lambda {
|
347
|
+
check_decode "\x5f\x00\xff", "".b
|
348
|
+
}.should raise_error(MessagePack::MalformedFormatError)
|
349
|
+
end
|
350
|
+
|
351
|
+
it "bare break" do
|
352
|
+
lambda {
|
353
|
+
check_decode "\xff", "".b
|
354
|
+
}.should raise_error(MessagePack::MalformedFormatError)
|
355
|
+
lambda {
|
356
|
+
check_decode "\x82\xff\x00\x00", "".b
|
357
|
+
}.should raise_error(MessagePack::MalformedFormatError)
|
358
|
+
lambda {
|
359
|
+
check_decode "\x82\x9f\xff\xff", "".b
|
360
|
+
}.should raise_error(MessagePack::MalformedFormatError)
|
361
|
+
end
|
362
|
+
|
345
363
|
it "Time" do
|
346
364
|
check_decode "\xc1\x19\x12\x67", Time.at(4711)
|
347
365
|
check 6, Time.at(Time.now.to_i)
|
348
366
|
end
|
349
367
|
|
350
368
|
it "URI" do
|
351
|
-
check_decode "\xd8\x20\x78\x13http://www.ietf.org", CBOR::Tagged.new(32, "http://www.ietf.org")
|
369
|
+
# check_decode "\xd8\x20\x78\x13http://www.ietf.org", CBOR::Tagged.new(32, "http://www.ietf.org")
|
352
370
|
require 'uri'
|
353
371
|
check_decode "\xd8\x20\x78\x13http://www.ietf.org", URI.parse("http://www.ietf.org")
|
354
372
|
# This doesn't work yet if 'uri' is not required before 'cbor':
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.6.
|
4
|
+
version: 0.5.6.4
|
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:
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|