wmoxam/phonie — pull request #10 by cainlevy (2013-04-30 02:52:40+00:00)
Title: cleanup and refactoring pass

I did a full pass through phonie for cleanup and refactoring, so the diff here is fairly large. Given the history of the repo I'm reluctant to splinter off yet another gem, and I'd prefer to contribute back upstream. Please let me know if you're interested in some or all of the included changes.

Notable improvements:
* Test suite is over 10x faster, mostly from memoizing the country format regexs. Easy win.
* The data file is now an array. The hash keys were left over from some previous version that assumed only one country per dialing prefix.
* I couldn't take the cognitive dissonance with the ```char_3_code``` and renamed it to ```iso_3166_code```.
* The ```Phonie::Phone``` class now uses ```ActiveModel::Validations``` to check validity instead of raising ```RuntimeError``` exceptions.
* The country data is now loaded during initialization, which fixes a thread safety issue and also fixes scripts that might try to search countries without triggering ```Phonie::Phone.parse```.
* The tests for Guam and Greece were messing with each other due to some copy+paste bug.
* In general I tried for more idiomatic Ruby, while remaining compatible with 1.8.7 (for the couple of months it has left to live).