jondot/sneakers — pull request #52 by norman (2014-06-27 17:06:40+00:00)
Title: Respect RABBITMQ_URL if its set.

This change makes Sneakers respect the `RABBITMQ_URL` environment variable. This is the same variable that Bunny will look for.

Since the RabbitMQ virtual host can be set in the URL, this change makes makes it look for the virtualhost there rather than defaulting to '/'.

At present in Sneakers, it's possible to set the amqp_url to a value that includes a virtual host, but unless you explicitly set the virtualhost value as well, Sneakers will still use "/". This caused me a bit of confusion at first, as I was wondering why my URL with a virtual host wasn't sufficient to set that value in Sneakers.

Note that there are no tests in place for this, since at present the DEFAULTS hash is initialized at compile-time and frozen, which means it's too late to set the ENV var in the tests. I think it would be a good idea to implement a Sneakers::Configuration class with accessor methods for the config variables Sneakers uses; I've done something similar [in friendly_id](https://github.com/norman/friendly_id/blob/master/lib/friendly_id/configuration.rb), but didn't want to send you too large a pull request unless you agreed with the idea.