{"id":13878125,"url":"https://github.com/ruby/pstore","last_synced_at":"2025-05-15T06:03:02.167Z","repository":{"id":37971246,"uuid":"200769818","full_name":"ruby/pstore","owner":"ruby","description":"PStore implements a file based persistence mechanism based on a Hash.","archived":false,"fork":false,"pushed_at":"2025-04-30T01:34:16.000Z","size":167,"stargazers_count":76,"open_issues_count":1,"forks_count":8,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-30T02:34:18.051Z","etag":null,"topics":["ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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,"zenodo":null}},"created_at":"2019-08-06T03:30:41.000Z","updated_at":"2025-04-30T01:34:18.000Z","dependencies_parsed_at":"2024-06-18T20:03:30.805Z","dependency_job_id":"5e62232a-caf4-4ef1-a811-df6eff7ae92c","html_url":"https://github.com/ruby/pstore","commit_stats":{"total_commits":118,"total_committers":22,"mean_commits":5.363636363636363,"dds":0.7457627118644068,"last_synced_commit":"b902dd58918625b91e78d5247d8d4184f7a87224"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fpstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fpstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fpstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fpstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby","download_url":"https://codeload.github.com/ruby/pstore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254283336,"owners_count":22045140,"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":["ruby"],"created_at":"2024-08-06T08:01:40.533Z","updated_at":"2025-05-15T06:03:02.073Z","avatar_url":"https://github.com/ruby.png","language":"Ruby","readme":"# Pstore\n\nPStore implements a file based persistence mechanism based on a Hash.  User\ncode can store hierarchies of Ruby objects (values) into the data store file\nby name (keys).  An object hierarchy may be just a single object.  User code\nmay later read values back from the data store or even update data, as needed.\n\nThe transactional behavior ensures that any changes succeed or fail together.\nThis can be used to ensure that the data store is not left in a transitory\nstate, where some values were updated but others were not.\n\nBehind the scenes, Ruby objects are stored to the data store file with\nMarshal.  That carries the usual limitations.  Proc objects cannot be\nmarshalled, for example.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'pstore'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install pstore\n\n## Usage\n\n```ruby\nrequire \"pstore\"\n\n# a mock wiki object...\nclass WikiPage\n  def initialize( page_name, author, contents )\n    @page_name = page_name\n    @revisions = Array.new\n\n    add_revision(author, contents)\n  end\n\n  attr_reader :page_name\n\n  def add_revision( author, contents )\n    @revisions \u003c\u003c { :created  =\u003e Time.now,\n                    :author   =\u003e author,\n                    :contents =\u003e contents }\n  end\n\n   def wiki_page_references\n    [@page_name] + @revisions.last[:contents].scan(/\\b(?:[A-Z]+[a-z]+){2,}/)\n  end\n\n   # ...\nend\n\n# create a new page...\nhome_page = WikiPage.new( \"HomePage\", \"James Edward Gray II\",\n                          \"A page about the JoysOfDocumentation...\" )\n\n # then we want to update page data and the index together, or not at all...\nwiki = PStore.new(\"wiki_pages.pstore\")\nwiki.transaction do  # begin transaction; do all of this or none of it\n  # store page...\n  wiki[home_page.page_name] = home_page\n  # ensure that an index has been created...\n  wiki[:wiki_index] ||= Array.new\n  # update wiki index...\n  wiki[:wiki_index].push(*home_page.wiki_page_references)\nend                   # commit changes to wiki data store file\n\n ### Some time later... ###\n\n # read wiki data...\nwiki.transaction(true) do  # begin read-only transaction, no changes allowed\n  wiki.roots.each do |data_root_name|\n    p data_root_name\n    p wiki[data_root_name]\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/ruby/pstore.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby%2Fpstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby%2Fpstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby%2Fpstore/lists"}