Add basename function

Adds a basename function. 

Mainly lifted from the doorman code, which is very similar. Hopefully should enable the closure of https://tickets.puppetlabs.com/browse/MODULES-671