Refactor handling of ensure and version options

This also fixes a bug when 'present' was handled as a gem version.