{"id":18026829,"url":"https://github.com/yegor256/iri","last_synced_at":"2026-02-02T16:16:00.966Z","repository":{"id":39420220,"uuid":"181819422","full_name":"yegor256/iri","owner":"yegor256","description":"Simple Immutable URI/URL Builder in Ruby","archived":false,"fork":false,"pushed_at":"2024-05-23T07:35:58.000Z","size":155,"stargazers_count":109,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-23T07:45:36.324Z","etag":null,"topics":["ruby","ruby-gem","ruby-lib","uri","uri-builder"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/iri","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/yegor256.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-17T04:53:31.000Z","updated_at":"2024-05-27T11:21:59.319Z","dependencies_parsed_at":"2022-07-04T08:01:55.458Z","dependency_job_id":"e299dc32-ee75-4e8a-8eb5-5be6ad30c0d2","html_url":"https://github.com/yegor256/iri","commit_stats":{"total_commits":49,"total_committers":2,"mean_commits":24.5,"dds":"0.061224489795918324","last_synced_commit":"206c9023e474be232688d29a74b3d237275c6ddc"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Firi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Firi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Firi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Firi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/iri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457801,"owners_count":20941906,"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","ruby-gem","ruby-lib","uri","uri-builder"],"created_at":"2024-10-30T08:08:12.443Z","updated_at":"2026-02-02T16:16:00.959Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Immutable URI Builder for Ruby\n\n[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/iri)](https://www.rultor.com/p/yegor256/iri)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/iri/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/iri/actions/workflows/rake.yml)\n[![Gem Version](https://badge.fury.io/rb/iri.svg)](https://badge.fury.io/rb/iri)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/iri/master/frames)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/iri/blob/master/LICENSE.txt)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/iri.svg)](https://codecov.io/github/yegor256/iri?branch=master)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/iri)](https://hitsofcode.com/view/github/yegor256/iri)\n\nThe class [Iri] helps you build a URI and then modify its\n  parts via a simple [fluent interface]:\n\n```ruby\nrequire 'iri'\nurl = Iri.new('http://google.com/')\n  .append('find').append('me') # -\u003e http://google.com/find/me\n  .with(q: 'books about OOP', limit: 50) # -\u003e ?q=books+about+OOP\u0026limit=50\n  .without(:q) # remove this query parameter\n  .without('limit', 'speed') # also remove these two\n  .over(q: 'books about tennis', limit: 10) # replace these params\n  .scheme('https') # replace 'http' with 'https'\n  .host('localhost') # replace the host name\n  .port('443') # replace the port\n  .fragment('page-4') # replaces the fragment part of the URI, after the '#'\n  .query('a=1\u0026b=2') # replaces the entire query part of the URI\n  .path('/new/path') # replace the path of the URI, leaving the query untouched\n  .cut('/q') # replace everything after the host and port\n  .to_s # convert it to a string\n```\n\nSee the\n[full list of methods](https://www.rubydoc.info/github/yegor256/iri/master/Iri).\n\nInstall it:\n\n```bash\ngem install iri\n```\n\nOr add this to your `Gemfile`:\n\n```ruby\ngem 'iri'\n```\n\nPay attention, it is not a parser. The only functionality this gem provides\nis _building_ URIs.\n\nIt is very convenient to use inside\n[HAML](http://haml.info/tutorial.html), for example:\n\n```haml\n- iri = Iri.new(request.url)\n%a{href: iri.over(offset: offset + 10)} Next Page\n%a{href: iri.over(offset: offset - 10)} Previous Page\n```\n\nOf course, it's better to create the `iri` object only once per request\nand re-use it where you need. It's _immutable_, so you won't have any\nside-effects.\n\nPS. See how I use it in this Sinatra web app:\n[yegor256/0rsk](https://github.com/yegor256/0rsk).\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 2.3+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n\n[Iri]: https://www.rubydoc.info/github/yegor256/iri/master/Iri\n[fluent interface]: https://en.wikipedia.org/wiki/Fluent_interface\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Firi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Firi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Firi/lists"}