All Projects → yegor256 → Iri

yegor256 / Iri

Licence: mit
Simple Immutable URI/URL Builder in Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Iri

Creds
Encrypted & plain text credentials for multiple environments
Stars: ✭ 38 (-57.78%)
Mutual labels:  ruby-gem
Sttp
The Scala HTTP client you always wanted!
Stars: ✭ 1,078 (+1097.78%)
Mutual labels:  uri
Verse
[DEPRECATED] Text transformations
Stars: ✭ 71 (-21.11%)
Mutual labels:  ruby-gem
Ruby Kafka
A Ruby client library for Apache Kafka
Stars: ✭ 1,039 (+1054.44%)
Mutual labels:  ruby-gem
Ofstruct
OpenFastStruct is a data structure, similar to an OpenStruct but faster.
Stars: ✭ 53 (-41.11%)
Mutual labels:  ruby-gem
Jekyll Minibundle
A minimalistic asset bundling plugin for Jekyll
Stars: ✭ 65 (-27.78%)
Mutual labels:  ruby-gem
Handle Path Oz
Android Library to handle multiple Uri's(paths) received through Intents.
Stars: ✭ 36 (-60%)
Mutual labels:  uri
Tty Prompt
A beautiful and powerful interactive command line prompt
Stars: ✭ 1,210 (+1244.44%)
Mutual labels:  ruby-gem
Unscoped associations
🔦 Skip the default_scope in your associations (ActiveRecord)
Stars: ✭ 53 (-41.11%)
Mutual labels:  ruby-gem
Merkle tree
A merkle tree is a data structure used for efficiently summarizing sets of data, often one-time signatures.
Stars: ✭ 68 (-24.44%)
Mutual labels:  ruby-gem
Power trace
Buff exception backtrace with local variables, passed in arguments and instance variables!
Stars: ✭ 48 (-46.67%)
Mutual labels:  ruby-gem
Cucumber Api
API validator in BBD style with Cucumber
Stars: ✭ 50 (-44.44%)
Mutual labels:  ruby-gem
Ruby Statistics
Ruby gem for some statistical operations without any statistical language dependency
Stars: ✭ 67 (-25.56%)
Mutual labels:  ruby-gem
Dalli Rate limiter
Arbitrary Memcached-backed rate limiting for Ruby
Stars: ✭ 38 (-57.78%)
Mutual labels:  ruby-gem
System tester
A Development Tool for creating and managing system tests for Ruby on Rails >= 5.1 Applications
Stars: ✭ 73 (-18.89%)
Mutual labels:  ruby-gem
Tty Pager
Terminal output paging - cross-platform, major ruby interpreters
Stars: ✭ 37 (-58.89%)
Mutual labels:  ruby-gem
Github
Ruby interface to GitHub API
Stars: ✭ 1,081 (+1101.11%)
Mutual labels:  ruby-gem
Garth
🥁 A really basic theme for Jekyll
Stars: ✭ 85 (-5.56%)
Mutual labels:  ruby-gem
Request via
RequestVia: A Functional HTTP Client That Wraps Net::HTTP
Stars: ✭ 74 (-17.78%)
Mutual labels:  uri
Str metrics
Ruby gem (native extension in Rust) providing implementations of various string metrics
Stars: ✭ 68 (-24.44%)
Mutual labels:  ruby-gem

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

Build Status Build status Gem Version Maintainability Yard Docs

License Test Coverage Hits-of-Code

The 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
  .path('/new/path') # replace the path of the URI, leaving the query untouched
  .cut('/q') # replace everything after the host and 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

Of course, it's better to create the iri object only once per request and re-use it where you need. It's immutable, so you won't have any side-effects.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].