pjk / libcbor-ruby Goto Github PK
View Code? Open in Web Editor NEWRuby bindings for libcbor
Ruby bindings for libcbor
Hi,
Apparently I can decode tags 0 to 5, but starting from 6 it returns CBOR::DecodingError
. Is this expected?
$ irb
irb(main):001:0> require "libcbor/all"
~/.gem/ruby/2.6.5/gems/libcbor-0.1.0/lib/libcbor.rb:50: warning: constant ::Fixnum is deprecated
=> true
irb(main):002:0> CBOR.decode(CBOR.encode(CBOR::Tag.new(0, "")))
=> #<struct CBOR::Tag value=0, item="">
irb(main):003:0> CBOR.decode(CBOR.encode(CBOR::Tag.new(5, "")))
=> #<struct CBOR::Tag value=5, item="">
irb(main):004:0> CBOR.decode(CBOR.encode(CBOR::Tag.new(6, "")))
Traceback (most recent call last):
7: from ~/.rubies/ruby-2.6.5/bin/irb:23:in `<main>'
6: from ~/.rubies/ruby-2.6.5/bin/irb:23:in `load'
5: from ~/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
4: from (irb):4
3: from ~/.gem/ruby/2.6.5/gems/libcbor-0.1.0/lib/libcbor.rb:65:in `decode'
2: from ~/.gem/ruby/2.6.5/gems/libcbor-0.1.0/lib/libcbor.rb:65:in `tap'
1: from ~/.gem/ruby/2.6.5/gems/libcbor-0.1.0/lib/libcbor.rb:65:in `block in decode'
CBOR::DecodingError (CBOR::DecodingError)
Possibly by using a refinement, or by calling internally-defined encoding methods directly.
$ irb
irb(main):002:0> require "libcbor/all"
.../.gem/ruby/2.6.0/gems/libcbor-0.1.0/lib/libcbor.rb:50: warning: constant ::Fixnum is deprecated
=> true
irb(main):004:0> CBOR.decode(CBOR.encode("\x7F".b))
=> "\x7F"
irb(main):005:0> CBOR.decode(CBOR.encode("\x80".b))
Traceback (most recent call last):
7: from ../ruby-2.6.0/bin/irb:23:in `<main>'
6: from ../ruby-2.6.0/bin/irb:23:in `load'
5: from ../ruby-2.6.0/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
4: from (irb):5
3: from ../.gem/ruby/2.6.0/gems/libcbor-0.1.0/lib/libcbor.rb:65:in `decode'
2: from ../.gem/ruby/2.6.0/gems/libcbor-0.1.0/lib/libcbor.rb:65:in `tap'
1: from ../.gem/ruby/2.6.0/gems/libcbor-0.1.0/lib/libcbor.rb:65:in `block in decode'
CBOR::DecodingError (CBOR::DecodingError)
From the discussion over at cedarcode/webauthn-ruby#88 (comment)
It breaks the "just run bundle install and you're done" workflow we have now. It would be nice if we can package the library with the gem or provide pre-installed binaries like https://github.com/cowboyd/libv8
As provided by the libcbor0
Debian package
Hi,
Is the following expected?
$ irb
irb(main):001:0> require "libcbor/all"
.gem/ruby/2.6.5/gems/libcbor-0.1.0/lib/libcbor.rb:50: warning: constant ::Fixnum is deprecated
=> true
irb(main):002:0> CBOR.decode("C\x01\x02\x03")
=> "\x01\x02\x03"
irb(main):003:0> CBOR.decode("C\x01\x00\x03")
=> "\x01"
irb(main):004:0> CBOR.decode("A\x00")
=> ""
I mean the last two decode return values.
Prevent confusion in cases like #5 where possible by checking the encoding.
This will probably mean a breaking change in the API
Someone hasn't been paying attention for three years :)
https://www.ruby-lang.org/en/news/2018/06/20/support-of-ruby-2-2-has-ended/
Apparently CI script go out of date after the following changes in libcbor
PJK/libcbor#20
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.