{"id":13879864,"url":"https://github.com/jacobsmith/queryable_pstore","last_synced_at":"2025-07-16T16:30:29.771Z","repository":{"id":56889869,"uuid":"83139876","full_name":"jacobsmith/queryable_pstore","owner":"jacobsmith","description":"Adds a small wrapper to allow for easily querying a PStore in Ruby.","archived":false,"fork":false,"pushed_at":"2017-03-16T01:57:22.000Z","size":17,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T13:49:21.667Z","etag":null,"topics":["pstore","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-25T15:12:53.000Z","updated_at":"2017-03-21T00:00:54.000Z","dependencies_parsed_at":"2022-08-20T23:40:55.454Z","dependency_job_id":null,"html_url":"https://github.com/jacobsmith/queryable_pstore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsmith%2Fqueryable_pstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsmith%2Fqueryable_pstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsmith%2Fqueryable_pstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsmith%2Fqueryable_pstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobsmith","download_url":"https://codeload.github.com/jacobsmith/queryable_pstore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"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":["pstore","ruby","ruby-gem"],"created_at":"2024-08-06T08:02:36.544Z","updated_at":"2024-11-24T08:31:54.501Z","avatar_url":"https://github.com/jacobsmith.png","language":"Ruby","readme":"# QueryablePStore\nQueryablePStore is a quick and easy way to query a PStore file. It's syntax is inspired by ActiveRecord, but is more simplified. Of note, appending `.results` is required to actually execute the query and return the results.\n\n## Examples:\n\nAssuming a `testing.pstore` file that has the following hash saved:\n\n```ruby\n{\n  1: { name: \"John Doe\", age: 28, weight: 150.0, email: \"john_doe@example.com\" },\n  2: { name: \"Alpha Bet\", age: 18, weight: 170.0, email: \"alpha_bet@example.com\" },\n  3: { name: \"Charlie Dog\", age: 46, weight: 182.9, email: \"charlie_dog@example2.com\" },\n  4: { name: \"Eddy Foobar\", age: 72, weight: 200.0, email: \"eddy_foobar@example2.com\" },\n  5: { name: \"George Hallo\", age: 50, weight: 246.0, email: \"george_hallo@example2.com\" },\n}\n```\n\n- All users older than 30:\n\n```ruby\nq = QueryablePStore.new(\"testing.pstore\")\nq.age_gt(30).results\n```\n\n- All Users younger than 60 with a weight greater than 100:\n\n```ruby\nq = QueryablePStore.new(\"testing.pstore\")\nq.age_lt(60).weight_gt(100.0).results\n```\n\nThe `attributes_lambda` function recieves the entire record wrapped in an OpenStruct, so both `[]` and dot-notation access methods are supported.\n- All Users with an email ending with `example.com`:\n\n```ruby\nq = QueryablePStore.new(\"testing.pstore\")\nq.attributes_lambda { |row| row.email.end_with?(\"example.com\") }.results\n# OR\nq.attributes_lambda { |row| row[:email].end_with?(\"example.com\") }.results\n```\n\n## CSV Import\n\nThe library also supports importing a CSV that is already written to disk. It will then create a PStore at the location `#{filename}.pstore` and return an instance of a QueryablePStore loaded for you to use.\n\n```ruby\nq = QueryablePStore.import_csv(\"test.csv\")\nq.name_eq(\"John Doe\").results\n```\n\nIt will normalize all headers by downcasing all alpha characters (`[a-zA-Z]`) and replacing any other characters with `_`.\n\nExample:\n\n```\n\"Hello World\" =\u003e :hello_world\n\"$/yr\" =\u003e :__yr\n\"Test-Header\" =\u003e :test_header\n```\n\n\nAdditionally, you can let QueryablePStore know how to convert integer and float fields so that `gt` and `lt` queries can use numbers rather than strings for comparisons.\n\n```ruby\nq = QueryablePStore.import_csv(\"test.csv\", convert: [age: :integer])\nq.age_gt(20).results\n```\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobsmith%2Fqueryable_pstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobsmith%2Fqueryable_pstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobsmith%2Fqueryable_pstore/lists"}