{"id":15405596,"url":"https://github.com/krisleech/simple_store","last_synced_at":"2025-03-24T21:41:16.370Z","repository":{"id":5736355,"uuid":"6948498","full_name":"krisleech/simple_store","owner":"krisleech","description":"Store buckets of keyed hashes in memory or to disk, useful for testing without a real database.","archived":false,"fork":false,"pushed_at":"2013-04-04T15:49:53.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T04:44:47.113Z","etag":null,"topics":[],"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/krisleech.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":"2012-12-01T01:02:50.000Z","updated_at":"2014-01-18T23:53:00.000Z","dependencies_parsed_at":"2022-08-24T21:31:38.858Z","dependency_job_id":null,"html_url":"https://github.com/krisleech/simple_store","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fsimple_store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fsimple_store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fsimple_store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fsimple_store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krisleech","download_url":"https://codeload.github.com/krisleech/simple_store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245359248,"owners_count":20602322,"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":[],"created_at":"2024-10-01T16:17:25.494Z","updated_at":"2025-03-24T21:41:16.343Z","avatar_url":"https://github.com/krisleech.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleStore\n\nStore buckets of keyed hashes in memory or to disk, useful for testing without a real database.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'simple_store'\n```\n\n## Usage\n\n### Memory Store\n\n```ruby\nperson = { :id =\u003e 1, :first_name =\u003e 'Kris', :last_name =\u003e 'Leech' }\nstore = SimpleStore::Memory.new(:people)\nstore.put(person)\n\n# some seconds later...\n\nstore.get(1) # =\u003e { ... }\n```\n\n### Disk Store\n\n```ruby\nperson = { :id =\u003e 1, :first_name =\u003e 'Kris', :last_name =\u003e 'Leech' }\nstore = SimpleStore::Disk.new(:people)\nstore.put(person)\n\n# some days later...\n\nstore = SimpleStore::Disk.new(:people)\nstore.get(1) # =\u003e { ... }\n```\n\n### Example\n\n```ruby\nrequire 'virtus'\nrequire 'guid'\n\nclass Person\n  include Virtus\n\n  attribute :id, String, :default =\u003e Guid.new.to_s\n  attribute :first_name\n  attribute :last_name\n\n  def ==(person)\n    id == person.id\n  end\nend\n\nclass PeopleTable \u003c SimpleStore::Disk\n  def initialize\n    super(:people)\n  end\n\n  def put(person)\n    super(person.attributes)\n  end\n\n  def get(id)\n    Person.new(super(id))\n  end\nend\n\ndescribe 'storing a domain object to disk' do\n  it 'domain objects can be stored and retrieved from the store' do\n    person = Person.new\n    person.first_name = 'Kris'\n    person.last_name = 'Leech'\n\n    table = PeopleTable.new\n    table.put person\n    table.get(person.id).should == person\n  end\nend\n```\n\n## Contributing\n\n1. Fork it\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 new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fsimple_store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrisleech%2Fsimple_store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fsimple_store/lists"}