flogic/whiskey_disk — pull request #43 by BattleBrisket (2014-11-05 16:11:39+00:00)
Title: Add helpers for deployments without roles

No matter how my deployment roles lay out for production and staging, I always have one or two environments (development, and occasionally a demo server) that put all the roles on a single instance. In those cases, roles are effectively meaningless.

Initially I would handle those situations by writing conditionals in my rake tasks that look like this...

``` ruby
if role? :www || ENV['WD_ROLES'] == ''
```

...but that exposes WhiskeyDisk internals within my rake tasks. The conditionals also get a bit uglier when trying to watch for interesting file changes...

``` ruby
if (role?(:db) || ENV['WD_ROLES'] == '') and changed?('db/migrate')
```

So I added some helpers that encapsulate the notion, "Is this a deployment without any roles at all?"

`no_roles?` returns true if the `ENV['WD_ROLES']` definition is empty.

`nothing_or_role?(role)` returns true if the current deployment domain in the specified role, or if the `ENV['WD_ROLES']` definition is empty.