wr0ngway/rubber — pull request #229 by peterson (2012-10-27 00:31:57+00:00)
Title: Moved validation for creation of image

When I ran "cap rubber:bundle", I saw the following error:

```
/Users/peterson/.rvm/gems/ruby-1.9.3-p286@test/gems/rubber-2.1.2/lib/rubber/cloud/aws.rb:35:in `basename': can't convert nil into String (TypeError)
from /Users/peterson/.rvm/gems/ruby-1.9.3-p286@test/gems/rubber-2.1.2/lib/rubber/cloud/aws.rb:35:in `create_image'
from /Users/peterson/.rvm/gems/ruby-1.9.3-p286@test/gems/rubber-2.1.2/lib/rubber/thread_safe_proxy.rb:13:in `method_missing'
from /Users/peterson/.rvm/gems/ruby-1.9.3-p286@test/gems/rubber-2.1.2/lib/rubber/recipes/rubber/bundles.rb:9:in `block (2 levels) in
...
```

On closer inspection, validation code is present in this method, but was not being applied before the first call (basename) that relied on the valid data. I have moved the validation to the top of the method.

Now, when the method is called without the required parameters, an exception is raised as expected:

```
peterson@rutan:~/code/test$ RUBBER_ENV=staging FILTER=staging-t1micro cap rubber:bundle
Respawning with 'bundle exec'
triggering load callbacks
* 2012-10-27 11:16:53 executing `rubber:init'
...
* 2012-10-27 11:16:54 executing `rubber:bundle'
The image name for the bundle [20121027_1116]: staging-t1micro_20121027_1116
/Users/peterson/.rvm/gems/ruby-1.9.3-p286@test/bundler/gems/rubber-39c3d4ebb24b/lib/rubber/cloud/aws.rb:34:in `block in create_image': Set pk_file in rubber.yml (RuntimeError)
from /Users/peterson/.rvm/gems/ruby-1.9.3-p286@test/bundler/gems/rubber-39c3d4ebb24b/lib/rubber/cloud/aws.rb:33:in `each'
...
```