{"id":17942663,"url":"https://github.com/fnordfish/gdbmish","last_synced_at":"2025-04-03T13:27:46.382Z","repository":{"id":37859901,"uuid":"503318037","full_name":"fnordfish/gdbmish","owner":"fnordfish","description":"Convert crystal data structures into a `gdbm_dump` ASCII format and back.","archived":false,"fork":false,"pushed_at":"2023-05-23T14:04:25.000Z","size":103,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-09T02:31:16.626Z","etag":null,"topics":["crystal","gdbm"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/fnordfish.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}},"created_at":"2022-06-14T10:49:00.000Z","updated_at":"2025-01-30T05:33:28.000Z","dependencies_parsed_at":"2023-02-12T22:30:58.090Z","dependency_job_id":null,"html_url":"https://github.com/fnordfish/gdbmish","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/fnordfish%2Fgdbmish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fgdbmish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fgdbmish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fgdbmish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnordfish","download_url":"https://codeload.github.com/fnordfish/gdbmish/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247008846,"owners_count":20868430,"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":["crystal","gdbm"],"created_at":"2024-10-29T03:06:43.228Z","updated_at":"2025-04-03T13:27:46.366Z","avatar_url":"https://github.com/fnordfish.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDBMish\n\nConvert crystal data structures into a `gdbm_dump` ASCII format.\n\nCiting [gdbm](https://git.gnu.org.ua/gdbm.git/tree/NOTE-WARNING):\n\u003e Gdbm files have never been `portable' between different operating systems,\n\u003e system architectures, or potentially even different compilers.  Differences\n\u003e in byte order, the size of file offsets, and even structure packing make\n\u003e gdbm files non-portable.\n\u003e \n\u003e Therefore, if you intend to send your database to somebody over the wire,\n\u003e please dump it into a portable format using gdbm_dump and send the resulting\n\u003e file instead. The receiving party will be able to recreate the database from\n\u003e the dump using the gdbm_load command.\n\nGDBMish does that by reimplementing the `gdbm_dump` ASCII format without compiling against `gdbm`\n\n[![GitHub release](https://img.shields.io/github/release/fnordfish/gdbmish.svg)](https://github.com/fnordfish/gdbmish/releases)\n[![Docs](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://fnordfish.github.io/gdbmish/)\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     gdbmish:\n       github: fnordfish/gdbmish\n   ```\n\n2. Run `shards install`\n\n## Usage\n\nCreate a GDBM Dump:\n\n```crystal\nrequire \"gdbmish\"\n\n# Get dump as String\nstring = Gdbmish::Dump.ascii({\"key1\" =\u003e \"value\", \"key2\" =\u003e \"value2\"})\n\n# Write directly into File (or any other IO)\nFile.open(\"my_db.dump\", \"w\") do |file|\n  Gdbmish::Dump.ascii({\"key1\" =\u003e \"value\", \"key2\" =\u003e \"value2\"}, file)\nend\n\n# Provide an original filename\nGdbmish::Dump.ascii(data, file: \"my.db\")\n\n# Provide an original filename and file permissions\nGdbmish::Dump.ascii(data, file: \"my.db\", uid: \"1000\", gid: \"1000\", mode: 0o600)\n\n# Iterate over a data source and push onto an IO\nfileoptions = {file: \"my.db\", uid: \"1000\", user: \"ziggy\", gid: \"1000\", group: \"staff\", mode: 0o600}\nFile.open(\"my.dump\", \"w\") do |file|\n  Gdbmish::Dump::Ascii.new(**fileoptions).dump(io) do |appender|\n    MyDataSource.each do |key, value|\n      appender \u003c\u003c {key.to_s, value.to_s}\n    end\n  end\nend\n```\n\nOn the target host, use a tool like `gdbm_load` to convert the dump into a db that works with that hosts gdbm.\n\nRead a GDBM Dump:\n\n```crystal\nreader = Gdbmish::Read::Ascii.new(File.open(\"my.dump\"))\n\n# get meta data\nreader.meta.file # =\u003e \"my.db\"\n\n# either iterate over data:\nreader.data do |key, value|\n  puts \"#{key.inspect} =\u003e #{value.inspect}\"\nend\n\n# or use the Iterator to transform into Hash\nreader.data.to_h\n```\n\n## Development\n\n* Run specs using `crystal spec`\n* Format files using `crystal tool format`\n\n## Limitations\n\n* Currently only supports the ASCII format and not the Binary format\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/fnordfish/gdbmish/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Robert Schulze](https://github.com/fnordfish) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnordfish%2Fgdbmish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnordfish%2Fgdbmish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnordfish%2Fgdbmish/lists"}