{"id":15406765,"url":"https://github.com/dannyben/active_cabinet","last_synced_at":"2025-07-20T13:36:18.655Z","repository":{"id":43379916,"uuid":"293714699","full_name":"DannyBen/active_cabinet","owner":"DannyBen","description":"ActiveRecord-inspired interface for HashCabinet, the file-based key-object store","archived":false,"fork":false,"pushed_at":"2024-01-28T14:15:44.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-07T01:37:45.637Z","etag":null,"topics":["gem","key-value","ruby","ruby-gem","sdbm"],"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/DannyBen.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":"2020-09-08T05:56:42.000Z","updated_at":"2021-09-30T07:03:14.000Z","dependencies_parsed_at":"2024-01-28T15:32:23.682Z","dependency_job_id":"639cdba1-d816-46a0-b6f6-dea10536bb64","html_url":"https://github.com/DannyBen/active_cabinet","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"364ce9d8e47bcb5169a85f8f28f50bf9639dcabb"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/DannyBen/active_cabinet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Factive_cabinet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Factive_cabinet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Factive_cabinet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Factive_cabinet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/active_cabinet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Factive_cabinet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266135014,"owners_count":23881774,"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":["gem","key-value","ruby","ruby-gem","sdbm"],"created_at":"2024-10-01T16:25:17.924Z","updated_at":"2025-07-20T13:36:18.630Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"ActiveCabinet\n==================================================\n\n[![Gem Version](https://badge.fury.io/rb/active_cabinet.svg)](https://badge.fury.io/rb/active_cabinet)\n[![Build Status](https://github.com/DannyBen/active_cabinet/workflows/Test/badge.svg)](https://github.com/DannyBen/active_cabinet/actions?query=workflow%3ATest)\n[![Maintainability](https://api.codeclimate.com/v1/badges/a4302349baf2d20e2af8/maintainability)](https://codeclimate.com/github/DannyBen/active_cabinet/maintainability)\n\n---\n\nAn ActiveRecord-inspired interface for [HashCabinet], the\nfile-based key-object store.\n\nIt allows you to create models that are stored in a file-based key-value\nstore, backed by Ruby's built in [SDBM].\n\nActiveCabinet is a tiny library, with only [HashCabinet] as a dependency.\n\n---\n\nInstallation\n--------------------------------------------------\n\n    $ gem install active_cabinet\n\n\n\nUsage\n--------------------------------------------------\n\nBefore trying these examples, create a directory named `db` - this is the \ndefault directory where the cabinet files are stored.\n\n```ruby\nrequire 'active_cabinet'\n\n# Define a model\nclass Song \u003c ActiveCabinet\nend\n\n# Create the model, and store it in the cabinet\n# Each object must have at least an `id` and can have any number of\n# attributes\nsong = Song.create id: 1, title: 'Moonchild', artist: 'Iron Maiden'\np song\n#=\u003e #\u003cSong @attributes={:id=\u003e1, :title=\u003e\"Moonchild\", :artist=\u003e\"Iron Maiden\"}\u003e\n\n# Get all records\nSong.all     #=\u003e Array of Song objects\nSong.count   #=\u003e 1\n\n# Retrieve a specific record\nSong[1]\nSong.find 1\n\n# Read one attribute or all attributes from a record\nsong.album\nsong.attributes\n\n# Update a single attribute\nsong.year = 1988\nsong.save\n\n# Update multiple attributes\nsong.update year: 1988, artist: 'Metallica'\nsong.update! year: 1988, artist: 'Metallica'  # this variant also saves\n```\n\n### Restricting / allowing certain attributes\n\nYou may specify required attributes. Records without these attributes will\nnot be saved. Note that `id` is always required.\n\n```ruby\nclass Song \u003c ActiveCabinet\n  required_attributes :title, :artist\nend\n\nsong = Song.new title: \"Moonchild\"\nsong.valid?   # =\u003e false\nsong.error    # =\u003e \"missing required attributes: [:artist, :id]\"\n\nsong = Song.new id: 1, title: \"Moonchild\", artist: 'Iron Maiden'\nsong.valid?   # =\u003e true\n\n# Additional attributes are still allowed\nsong.year = 1988\nsong.valid?   # =\u003e true\n```\n\nYou can also restrict the allowed optional attributes\n\n```ruby\nclass Song \u003c ActiveCabinet\n  required_attributes :title\n  optional_attributes :artist\nend\n\nsong = Song.new id: 1, title: 'Moonchild', album: 'Seventh Son of a Seventh Son'\nsong.valid?  # =\u003e false\nsong.error   # =\u003e \"invalid attributes: [:album]\"\n```\n\nIn order to enforce only the required attributes, without optional ones, set\nthe value of `optional_attributes` to `false`\n\n```ruby\nclass Song \u003c ActiveCabinet\n  required_attributes :title\n  optional_attributes false\nend\n\nsong = Song.new id: 1, title: 'Moonchild', artist: 'Iron Maiden'\nsong.valid?  # =\u003e false\nsong.error   # =\u003e \"invalid attributes: [:artist]\"\n```\n\n### Declaring default attribute values\n\nYou may specify default values for some attributes. These attrributes will\nbe merged into newly created record instances.\n\n```ruby\nclass Song \u003c ActiveCabinet\n  required_attributes :title\n  default_attributes format: :mp3\nend\n\nsong = Song.new title: \"Moonchild\"\nsong.format   # =\u003e :mp3\n```\n\n\n### Configuring storage path\n\nBy default, `ActiveCabinet` stores all its files (two files per model) in the\n`./db` directory. The file name is determined by the name of the class.\n\nYou can override both of these values:\n\n```ruby\n# Set the base directory for all cabinets\nActiveCabinet::Config.dir = \"cabinets\"\n\n# Set the filename of your model\nclass Song \u003c ActiveCabinet\n  cabinet_name \"songs_collection\"\nend\n```\n\n## Documentation\n\n[Documentation on RubyDoc][docs]\n\n## Contributing / Support\n\nIf you experience any issue, have a question or a suggestion, or if you wish\nto contribute, feel free to [open an issue][issues].\n\n---\n\n[SDBM]: https://ruby-doc.org/stdlib-2.7.1/libdoc/sdbm/rdoc/SDBM.html\n[docs]: https://rubydoc.info/gems/active_cabinet\n[issues]: https://github.com/DannyBen/active_cabinet/issues\n[HashCabinet]: https://github.com/DannyBen/hash_cabinet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Factive_cabinet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Factive_cabinet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Factive_cabinet/lists"}