Of course one should handle errors etc. But it works and I don't have to bother about $LOAD_PATH. From command line "facter customxpathversion" will not work because probably it's not in the LOAD_PATH.
Here the whole documentation
Update: you can use this custom fact from the facter command line if you set the FACTERLIB environment variable: