{"id":23857368,"url":"https://github.com/murakmii/cborb","last_synced_at":"2026-02-12T23:04:22.258Z","repository":{"id":62555419,"uuid":"140089689","full_name":"murakmii/cborb","owner":"murakmii","description":"Pure ruby decoder for CBOR(RFC 7049)","archived":false,"fork":false,"pushed_at":"2018-11-10T12:56:51.000Z","size":81,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-18T02:17:11.971Z","etag":null,"topics":["cbor","gem","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/murakmii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-07T14:09:24.000Z","updated_at":"2021-08-26T00:16:06.000Z","dependencies_parsed_at":"2022-11-03T05:31:01.433Z","dependency_job_id":null,"html_url":"https://github.com/murakmii/cborb","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murakmii%2Fcborb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murakmii%2Fcborb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murakmii%2Fcborb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murakmii%2Fcborb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/murakmii","download_url":"https://codeload.github.com/murakmii/cborb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232282733,"owners_count":18499327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cbor","gem","ruby"],"created_at":"2025-01-03T02:53:39.408Z","updated_at":"2026-02-12T23:04:17.240Z","avatar_url":"https://github.com/murakmii.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cborb\n\n[![Gem Version](https://badge.fury.io/rb/cborb.svg)](https://badge.fury.io/rb/cborb)\n[![CircleCI](https://circleci.com/gh/murakmii/cborb/tree/master.svg?style=svg)](https://circleci.com/gh/murakmii/cborb/tree/master)\n\nCborb is a pure ruby decoder for CBOR([RFC 7049](https://tools.ietf.org/html/rfc7049))\n\n```rb\nrequire \"cborb\"\n\ndecoder = Cborb::Decoding::Decoder.new\n\ndecoder.decode(\"\\x83\\x01\")\ndecoder.finished? # =\u003e false\n\ndecoder.decode(\"\\x02\\x03\\x04\")\ndecoder.finished? # =\u003e true\n\ndecoder.result # =\u003e [1, 2, 3]\ndecoder.remaining_bytes # =\u003e \"\\x04\"\n\n# Shorthand\nCborb.decode(\"\\x83\\x01\\x02\\x03\") # =\u003e [1, 2, 3]\n```\n\n## Handling indefinite-length data\n\nCborb can handle indefinite-length data(array, map, byte string, unicode string).\n\n```rb\nCborb.decode(\"\\x9F\\x01\\x82\\x02\\x03\\x9F\\x04\\x05\\xFF\\xFF\") # =\u003e [1, [2, 3], [4, 5]]\n```\n\n## Handling tags\n\nIf Cborb encounters a tag, generates instance of `Cborb::Decoding::TaggedValue`.  \nThat contains tag number and original value.\n\n```rb\nCborb.decode \"\\xC0\" + \"\\x71\" + \"1970-01-01T00:00Z\"\n# =\u003e #\u003cstruct Cborb::Decoding::TaggedValue tag=0, value=\"1970-01-01T00:00Z\"\u003e\n```\n\n## Handling simple values\n\nCborb can handle simple values(true, false, nil, undefined).\n\n```rb\nCborb.decode \"\\xF5\" # =\u003e true\n```\n\n\"Undefined\" doesn't exist in Ruby.\nSo, Cborb converts \"undefined\" to `nil`.\n\n```rb\nCborb.decode \"\\xF7\" # =\u003e nil\n```\n\nIf Cborb encounters unassigned simple value, generates instance of `Cborb::Decoding::UnassignedSimpleValue`.  \nThat contains simple value number.\n\n```rb\nCborb.decode \"\\xEF\"\n# =\u003e #\u003cstruct Cborb::Decoding::UnassignedSimpleValue number=15\u003e\n```\n\n## Handling concatenated CBOR\n\nBy default, when decoder received concatenated CBOR, that raises error.\n\n```rb\nCborb.decode(\"\\x83\\x01\\x02\\x03\\x04\") # =\u003e Cborb::InvalidByteSequenceError\n```\n\nIf you want to decode concatenated CBOR, set `concatenated` option to `true`.  \nDecoder decodes whole of concatenated CBOR and returns instance of `Cborb::Decoding::Concatenated`.\n\n```rb\nresults = Cborb.decode(\"\\x83\\x01\\x02\\x03\\x04\", concatenated: true)\n# =\u003e #\u003cCborb::Decoding::Concatenated:0x00007fcb1b8b2e30 @decoded=[[1, 2, 3], 4]\u003e\n\nresults.first # =\u003e [1, 2, 3]\nresults.last  # =\u003e 4\n```\n\n## Development\n\n```bash\n# Clone\ngit clone git@github.com:murakmii/cborb \u0026\u0026 cd cborb\n\n# Setup\nbin/setup\n\n# Edit code...\n\n# Run test\nbundle exec rspec\n```\n\n## Contribution\n\nContributions are always welcome :kissing_heart:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurakmii%2Fcborb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurakmii%2Fcborb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurakmii%2Fcborb/lists"}