{"id":13878740,"url":"https://github.com/astroband/ruby-xdr","last_synced_at":"2025-04-05T10:31:16.237Z","repository":{"id":26540695,"uuid":"29994081","full_name":"astroband/ruby-xdr","owner":"astroband","description":"Read/write XDR encoded data structures (RFC 4506)","archived":false,"fork":false,"pushed_at":"2024-04-26T08:37:29.000Z","size":187,"stargazers_count":12,"open_issues_count":4,"forks_count":10,"subscribers_count":20,"default_branch":"main","last_synced_at":"2024-04-26T09:44:11.386Z","etag":null,"topics":["data-structures","deserialization","ruby","serialization","xdr"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astroband.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-28T23:42:16.000Z","updated_at":"2024-06-02T18:36:49.975Z","dependencies_parsed_at":"2024-06-02T18:36:49.060Z","dependency_job_id":"76325edf-ac37-4344-bf57-0904f7c1451c","html_url":"https://github.com/astroband/ruby-xdr","commit_stats":{"total_commits":133,"total_committers":7,"mean_commits":19.0,"dds":"0.18796992481203012","last_synced_commit":"a8075580af9a729e8a65d4043cca9d38b4f9884a"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astroband%2Fruby-xdr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astroband%2Fruby-xdr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astroband%2Fruby-xdr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astroband%2Fruby-xdr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astroband","download_url":"https://codeload.github.com/astroband/ruby-xdr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247324647,"owners_count":20920692,"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":["data-structures","deserialization","ruby","serialization","xdr"],"created_at":"2024-08-06T08:01:58.422Z","updated_at":"2025-04-05T10:31:15.571Z","avatar_url":"https://github.com/astroband.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# XDR, for Ruby\n\n[![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/gems/xdr)\n[![Gem Version](https://badge.fury.io/rb/xdr.svg)](https://badge.fury.io/rb/xdr)\n[![CI](https://github.com/astroband/ruby-xdr/actions/workflows/ci.yml/badge.svg)](https://github.com/astroband/ruby-xdr/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/astroband/ruby-xdr/badge.svg?branch=main)](https://coveralls.io/github/astroband/ruby-xdr?branch=main)\n[![Code Climate](https://codeclimate.com/github/stellar/ruby-xdr/badges/gpa.svg)](https://codeclimate.com/github/stellar/ruby-xdr)\n\nXDR is an open data format, specified in [RFC 4506](http://tools.ietf.org/html/rfc4506.html). This library provides a\nway to read and write XDR data from ruby. It can read/write all of the primitive XDR types and also provides facilities\nto define readers for the compound XDR types (enums, structs and unions)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'xdr'\n```\n\nAnd then execute:\n\n    bundle\n\nOr install it yourself as:\n\n    gem install xdr\n\n## Usage\n\n```ruby\n# Reading/writing a primitive values\nXDR::Bool.to_xdr(false) # =\u003e \"\\x00\\x00\\x00\\x00\"\nXDR::Bool.from_xdr(\"\\x00\\x00\\x00\\x01\") # =\u003e true\n\n# Reading/writing arrays\nXDR::Array[XDR::Int, 2].to_xdr([1, 2]) # =\u003e \"\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\"\nXDR::Array[XDR::Int, 2].from_xdr(\"\\x00\\x00\\x00\\x03\\x00\\x00\\x00\\x04\") # =\u003e [3,4]\n\n# Defining an enum\n\nclass ResultType \u003c XDR::Enum\n  member :ok, 0\n  member :error, 1\n  seal\nend\n\n# Using enums\n\nResultType.ok == ResultType.error # =\u003e false\nResultType.to_xdr(ResultType.error) # =\u003e \"\\x00\\x00\\x00\\x01\"\nResultType.from_xdr(\"\\x00\\x00\\x00\\x00\") # =\u003e ResultType.ok(0)\n\n# Defining structs\n\nclass MessageWithHash \u003c XDR::Struct\n  attribute :message, XDR::String[]\n  attribute :hash, XDR::Opaque[20]\nend\n\n# Using structs\n\ns = MessageWithHash.new\ns.message = \"Hello world\"\ns.hash = Digest::SHA1.digest(s.message)\nxdr = s.to_xdr # =\u003e \"...\"\n\ns2 = MessageWithHash.from_xdr(xdr)\n\n# Defining unions\n\nclass Result \u003c XDR::Union\n  switch_on ResultType, :type\n\n  switch :ok\n  switch :error, :message\n\n  attribute :message, XDR::String[]\nend\n\n# Constructing unions\nResult.ok\nResult.error(\"You didn't say please\")\n\n# Using unions\n\nResult.ok.to_xdr # =\u003e \"\\x00\\x00\\x00\\x00\"\nResult.error(\"boom\").to_xdr # =\u003e \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x04boom\"\n\nResult.from_xdr(\"\\x00\\x00\\x00\\x00\") # =\u003e #\u003cResult ...\u003e\n\n```\n\n## Thread safety\n\nCode generated by `xdrgen`, which targets this library, uses autoload extensively. Since autoloading is not thread-safe,\nneither is code generated from xdrgen. To work around this, any module including `XDR::Namespace` can be forced to load\nall of it's children by calling `load_all!` on the module.\n\n## Code generation\n\nruby-xdr by itself does not have any ability to parse XDR IDL files and produce a parser for your custom data types.\nInstead, that is the responsibility of [xdrgen](http://github.com/stellar/xdrgen). `xdrgen` will take your `.x` files\nand produce a set of ruby files that target this library to allow for your own custom types.\n\nSee [ruby-stellar-base](http://github.com/astroband/ruby-stellar-sdk/tree/master/base/generated) for an example.\n\n## Contributing\n\n1. Fork the repo ( https://github.com/astroband/ruby-xdr/fork )\n1. Create your feature branch (`git checkout -b my-new-feature`)\n1. Commit your changes (`git commit -am 'Add some feature'`)\n1. Push to the branch (`git push origin my-new-feature`)\n1. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastroband%2Fruby-xdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastroband%2Fruby-xdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastroband%2Fruby-xdr/lists"}