{"id":19885668,"url":"https://github.com/asmod4n/mruby-tnetstrings","last_synced_at":"2026-06-08T02:32:40.601Z","repository":{"id":35890097,"uuid":"40176280","full_name":"Asmod4n/mruby-tnetstrings","owner":"Asmod4n","description":"mruby implementation of the newer TNetStrings specification with support for Hashes and Arrays","archived":false,"fork":false,"pushed_at":"2024-04-02T09:29:44.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T03:47:05.520Z","etag":null,"topics":["mruby","tnetstrings"],"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/Asmod4n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-04T09:43:08.000Z","updated_at":"2024-03-30T12:53:41.000Z","dependencies_parsed_at":"2024-04-02T10:41:04.336Z","dependency_job_id":null,"html_url":"https://github.com/Asmod4n/mruby-tnetstrings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Asmod4n/mruby-tnetstrings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-tnetstrings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-tnetstrings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-tnetstrings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-tnetstrings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asmod4n","download_url":"https://codeload.github.com/Asmod4n/mruby-tnetstrings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-tnetstrings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34046003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["mruby","tnetstrings"],"created_at":"2024-11-12T17:35:15.943Z","updated_at":"2026-06-08T02:32:40.585Z","avatar_url":"https://github.com/Asmod4n.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"mruby-tnetstrings\n===================\n\n\nInstallation\n============\n\nFirst get a working copy of [mruby](https://github.com/mruby/mruby) then add\n\n```ruby\n  conf.gem mgem: 'mruby-tnetstrings'\n```\n\nto your build_conf.rb\n\nExamples\n-------\n\nObjects can be packed with `Object#to_tnetstring` or `TNetStrings.dump`:\n\n```ruby\npacked_hash = { 'a': 'hash', 'with': [1, 'embedded', 'array'] }.to_tnetstring\npacked_string = TNetStrings.dump('bye')\n\npacked_hash   # =\u003e \"45:1:a,4:hash,4:with,23:1:1#8:embedded,5:array,]}\"\npacked_string # =\u003e \"3:bye,\"\n```\n\nThey are unpacked with `TNetStrings.parse`:\n\n```ruby\nTNetStrings.parse(packed_hash)   # =\u003e [{\"a\"=\u003e\"hash\", \"with\"=\u003e[1, \"embedded\", \"array\"]}, \"\"]\nTNetStrings.parse(packed_string) # =\u003e [\"bye\", \"\"]\n```\n\nA string with multiple packed values can be unpacked by checking if there is a non empty remainder\n`TNetStrings.parse`:\n\n```ruby\npacked = packed_string + packed_hash\n\nunpacked_string, extra = TNetStrings.parse(packed) # =\u003e [\"bye\", \"45:1:a,4:hash,4:with,23:1:1#8:embedded,5:array,]}\"]\nif extra.bytesize != 0\n  unpacked_hash, _ = TNetStrings.parse(extra) # =\u003e [{\"a\"=\u003e\"hash\", \"with\"=\u003e[1, \"embedded\", \"array\"]}, \"\"]\nend\n```\nOverriding `to_tnetstring`\n---------------------\n\nIt's not supported to override `to_tnetstring`, `TNetStrings.dump` ignores it, same when that object is included in a Hash or Array.\nThis gem treats objects like ruby does, if you want to change the way your custom Class gets handled you can add `to_hash`, `to_ary`, `to_int` or `to_str` methods so it will be packed like a Hash, Array, Integer or String (in that order) then.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-tnetstrings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmod4n%2Fmruby-tnetstrings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-tnetstrings/lists"}