{"id":16882439,"url":"https://github.com/matthutchinson/ecb_exchange","last_synced_at":"2025-04-11T11:50:56.587Z","repository":{"id":62557709,"uuid":"68831800","full_name":"matthutchinson/ecb_exchange","owner":"matthutchinson","description":"ECB Exchange 💷 💵 💴 💶 ","archived":false,"fork":false,"pushed_at":"2021-02-09T10:03:06.000Z","size":83,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T08:11:14.467Z","etag":null,"topics":["currency","currency-converter","currency-exchange-rates","ecb","ecb-rates","exchange","exchange-rate","money"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthutchinson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-21T15:36:07.000Z","updated_at":"2021-02-09T10:03:11.000Z","dependencies_parsed_at":"2022-11-03T06:45:39.530Z","dependency_job_id":null,"html_url":"https://github.com/matthutchinson/ecb_exchange","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthutchinson%2Fecb_exchange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthutchinson%2Fecb_exchange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthutchinson%2Fecb_exchange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthutchinson%2Fecb_exchange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthutchinson","download_url":"https://codeload.github.com/matthutchinson/ecb_exchange/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994108,"owners_count":21030049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["currency","currency-converter","currency-exchange-rates","ecb","ecb-rates","exchange","exchange-rate","money"],"created_at":"2024-10-13T16:07:15.997Z","updated_at":"2025-04-11T11:50:56.566Z","avatar_url":"https://github.com/matthutchinson.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ECB Exchange\n\n[![Gem](https://img.shields.io/gem/v/ecb_exchange.svg?style=flat)](http://rubygems.org/gems/ecb_exchange)\n[![Travis](https://img.shields.io/travis/com/matthutchinson/ecb_exchange/master.svg?style=flat)](https://travis-ci.com/matthutchinson/ecb_exchange)\n[![Depfu](https://img.shields.io/depfu/matthutchinson/ecb_exchange.svg?style=flat)](https://depfu.com/github/matthutchinson/ecb_exchange)\n[![Maintainability](https://api.codeclimate.com/v1/badges/c67969dd7b921477bdcc/maintainability)](https://codeclimate.com/github/matthutchinson/ecb_exchange/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/c67969dd7b921477bdcc/test_coverage)](https://codeclimate.com/github/matthutchinson/ecb_exchange/test_coverage)\n\nCurrency conversion using the European Central Bank's foreign [exchange\nrates](https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml). Rates\nfor the last 90 days are fetched and cached on demand. All calculations are\n  performed and returned as `BigDecimal` (usually a [good\n  idea](https://makandracards.com/makandra/1178-bigdecimal-arithmetic-in-ruby)\n  when dealing with money).\n\n## Requirements\n\n* [Ruby](http://ruby-lang.org/) \u003e= 2.3\n\n## Installation\n\nAdd this line to your Gemfile and run `bundle install`:\n\n```ruby\ngem 'ecb_exchange'\n```\n\n## Usage\n\nConvert an amount from one currency to another:\n\n```ruby\nECB::Exchange.convert(100, from: 'EUR', to: 'GBP')\n=\u003e 0.88235e2\n```\n\nThe converted amount (using today's current rate) will be returned as\n`BigDecimal`. In doing this, the gem will fetch and cache ECB rates for the last\n90 days.\n\nConvert an amount on a specific date:\n\n```ruby\nECB::Exchange.convert(100, from: 'EUR', to: 'GBP', date: Date.parse('2017-01-11'))\n=\u003e 0.87235e2\n```\n\nTo fetch the exchange rate multiplier between two currencies:\n\n```ruby\nECB::Exchange.rate(from: 'EUR', to: 'USD') # pass an optional `date` arg here too\n=\u003e 0.11969e1\n```\n\nYou can ask for an array of all supported currencies with:\n\n```ruby\nECB::Exchange.currencies\n=\u003e [\"USD\", \"JPY\", \"BGN\", \"CZK\", \"DKK\", \"GBP\", \"HUF\" ... ]\n```\n\nFinally, you can adjust the rates endpoint by setting your own\n`XMLFeed.endpoint` (e.g. in an initializer):\n\n```ruby\nECB::Exchange::XMLFeed.endpoint = \"http://my-awesome-service.com/feed.xml\"\n```\n\nThe XML feed at this endpoint must conform to the [ECB\nrates](https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml)\nstructure.\n\n## Handling Errors\n\nNot all dates, rates or currencies may be available, or the remote endpoint\ncould be unresponsive. For these cases consider handling these errors:\n\n* `ECB::Exchange::DateNotFoundError`\n* `ECB::Exchange::CurrencyNotFoundError`\n* `ECB::Exchange::ResponseError`\n* `ECB::Exchange::ParseError`\n\nOr rescue `ECB::Exchange::Error` to catch any of them.\n\n## Caching\n\nBy default rates will be cached to one of the following backend stores (in this\norder of preference).\n\n* Your own backend cache store (see below)\n* `Rails.cache`\n* An `ECB::Exchange::MemoryCache` instance (a simple in memory cache store)\n\nTo configure your own backend store (e.g. in an initializer):\n\n```ruby\nECB::Exchange::Cache.backend =  MyAwesomeCache.new\n# this cache must implement public `read(key)` and `write(key, value)` methods\n```\n\nAll keys in the cache are name-spaced with a `ecb_exchange_rates_for_date-`\nprefix.\n\n## Development\n\nCheck out this repo and run `bin/setup`, this will install gem dependencies and\ngenerate docs. Use `bundle exec rake` to run tests and generate a coverage\nreport.\n\nYou can also run `bin/console` for an interactive prompt to experiment with the\ncode.\n\n## Tests\n\nMiniTest is used for testing. Run the test suite with:\n\n    $ rake test\n\n## Docs\n\nGenerate docs for this gem with:\n\n    $ rake rdoc\n\n## Troubles?\n\nIf you think something is broken or missing, please raise a new\n[issue](https://github.com/matthutchinson/ecb_exchange/issues). Please remember\nto check it hasn't already been raised.\n\n## Contributing\n\nBug [reports](https://github.com/matthutchinson/ecb_exchange/issues) and [pull\nrequests](https://github.com/matthutchinson/ecb_exchange/pulls) are welcome on\nGitHub. When submitting pull requests, remember to add tests covering any new\nbehaviour, and ensure all tests are passing on\n[Travis](https://travis-ci.com/matthutchinson/ecb_exchange). Read the\n[contributing\nguidelines](https://github.com/matthutchinson/ecb_exchange/blob/master/CONTRIBUTING.md)\nfor more details.\n\nThis project is intended to be a safe, welcoming space for collaboration, and\ncontributors are expected to adhere to the [Contributor\nCovenant](http://contributor-covenant.org) code of conduct. See\n[here](https://github.com/matthutchinson/ecb_exchange/blob/master/CODE_OF_CONDUCT.md)\nfor more details.\n\n## Todo\n\n* Better RDoc documentation.\n* A Rails app to demo this gem (e.g. with a one-click Heroku install).\n\n## License\n\nThe code is available as open source under the terms of\n[LGPL-3](https://opensource.org/licenses/LGPL-3.0).\n\n## Links\n\n* [Gem](http://rubygems.org/gems/ecb_exchange)\n* [Travis CI](https://travis-ci.com/matthutchinson/ecb_exchange)\n* [Maintainability](https://codeclimate.com/github/matthutchinson/ecb_exchange/maintainability)\n* [Test Coverage](https://codeclimate.com/github/matthutchinson/ecb_exchange/test_coverage)\n* [RDoc](http://rdoc.info/projects/matthutchinson/ecb_exchange)\n* [Issues](http://github.com/matthutchinson/ecb_exchange/issues)\n* [Report a bug](http://github.com/matthutchinson/ecb_exchange/issues/new)\n* [GitHub](https://github.com/matthutchinson/ecb_exchange)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthutchinson%2Fecb_exchange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthutchinson%2Fecb_exchange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthutchinson%2Fecb_exchange/lists"}