Skip to content
Simple Immutable Ruby URI builder
Branch: master
Clone or download
Latest commit ecb898b May 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib #6 more fixes May 3, 2019
test #1 coverage May 4, 2019
.0pdd.yml #1 skeleton Apr 17, 2019
.gitignore #1 coverage May 4, 2019
.pdd #1 skeleton Apr 17, 2019
.rubocop.yml #7 ruby 2.2 May 8, 2019
.rultor.yml #1 skeleton Apr 17, 2019
.travis.yml #2 badges Apr 21, 2019
Gemfile #7 ruby 2.2 May 8, 2019
LICENSE.txt license May 22, 2019
README.md typo May 22, 2019
Rakefile #1 skeleton Apr 17, 2019
appveyor.yml #1 skeleton Apr 17, 2019
iri.gemspec #7 ruby 2.2 May 8, 2019
logo.svg new logo May 4, 2019

README.md

EO principles respected here DevOps By Rultor.com We recommend RubyMine

Build Status Build status Gem Version Maintainability Yard Docs

Test Coverage Hits-of-Code

Class Iri helps you build a URI and then modify its parts via a simple fluent interface:

require 'iri'
url = Iri.new('http://google.com/')
  .append('find').append('me') # -> http://google.com/find/me
  .add(q: 'books about OOP', limit: 50) # -> ?q=books+about+OOP&limit=50
  .del(:q) # remove this query parameter
  .del('limit') # remove this one too
  .over(q: 'books about tennis', limit: 10) # replace these params
  .scheme('https') # replace 'http' with 'https'
  .host('localhost') # replace the host name
  .port('443') # replace the port
  .to_s # convert it to a string

The full list of methods is here.

Install it:

$ gem install iri

Or add this to your Gemfile:

gem 'iri'

Pay attention, it is not a parser. The only functionality this gem provides is building URIs.

It is very convenient to use inside HAML, for example:

- iri = Iri.new(request.url)
%a{href: iri.over(offset: offset + 10)} Next Page
%a{href: iri.over(offset: offset - 10)} Previous Page

That's it.

PS. See how I use it in this Sinatra web app: yegor256/0rsk.

How to contribute

Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:

$ bundle update
$ bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.

You can’t perform that action at this time.