From 550c7c27446bb2381dba82fb6355363a29504a75 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sun, 18 Nov 2012 15:22:33 +0000 Subject: Ensure that the job we pull from the queue is a non-empty hash. --- lib/custodian.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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'] ) -- cgit v1.2.1