README.md in cborb-0.1.0 vs README.md in cborb-0.2.0

- old
+ new

@@ -1,7 +1,8 @@ # Cborb +[![Gem Version](https://badge.fury.io/rb/cborb.svg)](https://badge.fury.io/rb/cborb) [![CircleCI](https://circleci.com/gh/murakmii/cborb/tree/master.svg?style=svg)](https://circleci.com/gh/murakmii/cborb/tree/master) Cborb is a pure ruby decoder for CBOR([RFC 7049](https://tools.ietf.org/html/rfc7049)) ```rb @@ -10,14 +11,15 @@ decoder = Cborb::Decoding::Decoder.new decoder.decode("\x83\x01") decoder.finished? # => false -decoder.decode("\x02\x03") +decoder.decode("\x02\x03\x04") decoder.finished? # => true decoder.result # => [1, 2, 3] +decoder.remaining_bytes # => "\x04" # Shorthand Cborb.decode("\x83\x01\x02\x03") # => [1, 2, 3] ``` @@ -59,5 +61,43 @@ ```rb Cborb.decode "\xEF" # => #<struct Cborb::Decoding::UnassignedSimpleValue number=15> ``` + +## Handling concatenated CBOR + +By default, when decoder received concatenated CBOR, that raises error. + +```rb +Cborb.decode("\x83\x01\x02\x03\x04") # => Cborb::InvalidByteSequenceError +``` + +If you want to decode concatenated CBOR, set `concatenated` option to `true`. +Decoder decodes whole of concatenated CBOR and returns instance of `Cborb::Decoding::Concatenated`. + +```rb +results = Cborb.decode("\x83\x01\x02\x03\x04", concatenated: true) +# => #<Cborb::Decoding::Concatenated:0x00007fcb1b8b2e30 @decoded=[[1, 2, 3], 4]> + +results.first # => [1, 2, 3] +results.last # => 4 +``` + +## Development + +```bash +# Clone +git clone git@github.com:murakmii/cborb && cd cborb + +# Setup +bin/setup + +# Edit code... + +# Run test +bundle exec rspec +``` + +## Contribution + +Contributions are always welcome :kissing_heart: