RubyMoney/money — pull request #221 by mikaelwikman (2012-10-11 10:59:53+00:00)
Title: Currency extensions

I have added alternate symbols for all currencies in the system, added symbols where they were missing, and updated where they were wrong. Please see CHANGELOG.md for a list.

Furthermore, I have written algorithms for detecting possible currencies within a given string (extremly efficient, using search trees). For example, many currencies match the dollar ($) symbol, but only one would match US$, USD, or United States Dollar. For this I have added a simple API endpoint Money::Currency.analyze().

Example of usage:
```
Money::Currency.analyze('It would be nice to have 10000 Albanian lek by tomorrow!')
# == ['ALL']

Money::Currency.analyze("10EUR is less than 100:- but really, I want US$1")
# == ['EUR', 'SEK', 'USD']

Money::Currency.analyze('$400')
# == ["ARS", "AUD", "BBD", "BMD", "BND", "BSD", "BZD", "CAD", "CLP", "COP", "CUC", "CUP", "CVE", "DOP", "FJD", "GYD", "HKD", "JMD", "KYD", "LRD", "MXN", "NAD", "NZD", "SBD", "SGD", "SRD", "TTD", "TWD", "USD", "UYU", "XCD", "ZWD", "ZWL", "ZWN", "ZWR"]
```

Please see the spec/currency/heuristics_spec for an exhaustive list of supported variations.

This code is currently being used in a live system which is repeatedly processing 3rd party sources with big variation in price notations and currencies. So far results are good and most bugs have been found.

For Money gem I could see this as useful for a quirks-mode Money.new(), or simply as an added tool for developer to decide action. For example, my project currently falls back to main currency of the country if .analyze returns more than 1 possible currency.

Cheers.