Introducing Addressable
So, after 3 months, I’m back from my excursion to Africa. Don’t worry, I’m not coming back empty-handed.
I thought my fellow rubyists might benefit from the URI implementation I’ve been using in various projects, so I’ve extracted it out into its own library. In the process, I improved a few things here and there, added support for URI Templates, and fleshed out the specifications a bit more.
I introduce to you the Addressable library.
It has about a 2:1 spec to code ratio, 100.0% code coverage, and it has gone through plenty of code heckling. It ought to be pretty reliable.
Hope you like it. Let me know how it works.
Update:
I’ve added URI Template variable extraction and I updated the documentation. The extract_mapping method should be useful for template-based routing systems for frameworks.
seriously, chief, that’s the most beautiful spec I’ve ever seen. Well done.
Why thank you!
Hi, is this a drop-in replacement for URI? I’m thinking of doing either
choonkeat:
Neither of those will work with
open-uriI’m afraid.The best immediate option is not to rely on the interface similarity between URI and Addressable::URI and code directly to Addressable::URI. If that doesn’t work because you need to rely on some other piece of software, then patch that software to use Addressable instead, and submit the patch to the author of the library in question.
It is my intention to eventually go to ruby-core and ask for Addressable to replace URI, but I wanted to make sure Addressable was bullet-proof first. I’m currently quite satisfied with it, so that will likely happen soon, but there’s no guarantees that URI will be going away anytime soon.
Hey, I’m using Addressable and it’s really nice!
Just one thing about the heuristic parser, if I do something like:
Addressable::URI.heuristic_parse(‘mailto:jose.valim@gmail.com’), it replaces the mailto scheme for http.
I looked into Your code, did some changes, but, obviously, a few specs started to fail! =)
Any idea?
Thanks, José Valim!
Leave a Response