diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-18 15:22:33 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-18 15:22:33 +0000 |
commit | 0ed05e3cb2ff25266429d1b4fbcefbe907093077 (patch) | |
tree | 83cbfca252d1f1300a9c4603e2b178325011c791 | |
parent | 55fcf4f783f170e6a1cc8ab7ec173b274be3199d (diff) |
Ensure that the job we pull from the queue is a non-empty hash.
-rw-r--r-- | lib/custodian.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/custodian.rb b/lib/custodian.rb index 821bf6d..6c0ec81 100644 --- a/lib/custodian.rb +++ b/lib/custodian.rb @@ -111,10 +111,26 @@ class Custodian # - # Parse the JSON of the job body. + # Get the job body # json = job.body + raise ArgumentError, "Body doesn't look like JSON" unless( json =~ /[{}]/ ) + + + # + # Decode the JSON body - it should return a non-empty hash. + # hash = JSON.parse( json ) + + # + # Ensure we got a non-empty hash. + # + raise ArgumentError, "JSON didn't decode to a hash" unless hash.kind_of?(Hash) + raise ArgumentError, "JSON hash is empty" if (hash.empty?) + + # + # Are we being verbose? + # hash['verbose'] = 1 if ( ENV['VERBOSE'] ) |