Provide better hash reproduction

Sometimes parameters contain hashes, these hashes may be randomly ordered by
Ruby before they hit PuppetDB. This patch ensures those structures are sorted
recursively first to ensure the duplicates that are just suffering from
different ordering are matched properly.

This patch achieves this by provided a new function 'sort-nested-maps' into
utils that is utilised by a set of functions now provide for generically
preparing strings for hashing and an all in one that uses the string
function and hashes it: 'generic-identity-hash' and 'generic-identity-string'.

Now all the -hash and -string functions use those methodologies we have
hopefully centralised our logic and cleaned it up at the same time. We also
have good tests around these generic methods to prove (at least somewhat)
ordering is preserved so we can avoid this issue going forward.

I've also added tests to the other hash functions so we can preserve their
individual hash generation methodologies in unit test form.

Beyond this, we have converted the methodology for serialization before
hash generation to use the cheshire JSON encoding library. This should increase
performance and has been shown that this patch is almost twice as fast
while being more correct even though more work in ensuring correctness is
occuring purely due to the conversion to JSON.

Signed-off-by: Ken Barber <ken@bob.sh>
Attempt to move the memoize to one place

Signed-off-by: Ken Barber <ken@bob.sh>