{"id":17766464,"url":"https://github.com/dmitry/proximal_records","last_synced_at":"2025-04-01T14:21:42.413Z","repository":{"id":15776690,"uuid":"18515740","full_name":"dmitry/proximal_records","owner":"dmitry","description":"ActiveRecord extension to find out nearby records (previous and next) from the ActiveRelation scopes (using AREL).","archived":false,"fork":false,"pushed_at":"2014-07-16T13:25:03.000Z","size":248,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T08:49:12.904Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dmitry.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":"2014-04-07T12:11:37.000Z","updated_at":"2014-07-16T12:08:19.000Z","dependencies_parsed_at":"2022-09-24T04:12:02.406Z","dependency_job_id":null,"html_url":"https://github.com/dmitry/proximal_records","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry%2Fproximal_records","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry%2Fproximal_records/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry%2Fproximal_records/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry%2Fproximal_records/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmitry","download_url":"https://codeload.github.com/dmitry/proximal_records/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246651703,"owners_count":20812020,"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-26T20:30:03.770Z","updated_at":"2025-04-01T14:21:42.380Z","avatar_url":"https://github.com/dmitry.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProximalRecords 0.0.2\n\nActiveRecord extension to find out near by (proximal) records (previous and next) from the ActiveRelation scopes (using AREL).\n\nThe benefit of this gem, it can take any scope, and it does subquery for taking previous and next records.\nNext and previous records will be found based on all the clauses used in the scope. ORDER, JOINs, LIMIT and other clauses will be persisted. No manual setup required.\n\n### Supported adapters\n\n* mysql2\n* postgresql\n\n### Impossible to support adapters\n\n* sqlite3\n\n### Tested on\n\n* Ruby: 1.9.3, 2.0.0, 2.1.1\n* ActiveRecord: 3.2, 4.0, 4.1\n\n[![Build Status](https://travis-ci.org/dmitry/proximal_records.svg?branch=master)](https://travis-ci.org/dmitry/proximal_records)\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'proximal_records'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install proximal_records\n\n\n## Usage\n\nSetup ActiveRecord model with including the `ProximalRecords` module.\n\n```ruby\nclass Article \u003c ActiveRecord::Base\n  include ProximalRecords\nend\n```\n\nThen use it with `proximal_records` method, which takes a record that is part of the scope.\nIt returns an array with 2 elements: previous as the first element and next as the second.\nIf previous or next records wasn't found (when the relation record has the first or the last position in the scope), it returns `nil` for this element.\n\n```ruby\nscope = Article.title_like('proximal').order('created_at DESC, title ASC')\ncurrent_record = Article.find(20)\nprevious_record, next_record = current_record.proximal_records(scope)\n```\n\nAfter that you will get `previous` and `next` records, that are proximal (near by) records of current_record.\n\n\n## Alternatives\n\n- https://github.com/charly/nexter\n- https://github.com/glebm/order_query\n\n\n## Contributing\n\n1. Fork it ( http://github.com/dmitry/proximal_records/fork )\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitry%2Fproximal_records","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmitry%2Fproximal_records","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitry%2Fproximal_records/lists"}