{"id":19483267,"url":"https://github.com/rubymoney/eu_central_bank","last_synced_at":"2025-05-14T12:10:50.818Z","repository":{"id":43209655,"uuid":"619281","full_name":"RubyMoney/eu_central_bank","owner":"RubyMoney","description":"A gem that calculates the exchange rate using published rates from European Central Bank. Compatible with the money gem","archived":false,"fork":false,"pushed_at":"2025-02-03T14:44:01.000Z","size":202,"stargazers_count":218,"open_issues_count":1,"forks_count":131,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-15T00:38:19.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubyMoney.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-04-20T09:28:45.000Z","updated_at":"2025-02-03T14:44:04.000Z","dependencies_parsed_at":"2025-02-24T11:00:30.215Z","dependency_job_id":"ebd0a899-d78a-4b14-a7ac-dd91144ec9fa","html_url":"https://github.com/RubyMoney/eu_central_bank","commit_stats":{"total_commits":221,"total_committers":43,"mean_commits":"5.1395348837209305","dds":0.7330316742081449,"last_synced_commit":"22414037be24b7b3caaed43e235dd68c4fbe9b6b"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Feu_central_bank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Feu_central_bank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Feu_central_bank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Feu_central_bank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyMoney","download_url":"https://codeload.github.com/RubyMoney/eu_central_bank/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140766,"owners_count":22021220,"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":[],"created_at":"2024-11-10T20:14:14.503Z","updated_at":"2025-05-14T12:10:50.795Z","avatar_url":"https://github.com/RubyMoney.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eu_central_bank\n\n[![Build Status](https://travis-ci.org/RubyMoney/eu_central_bank.svg?branch=master)](https://travis-ci.org/RubyMoney/eu_central_bank)\n\n## Introduction\n\nThis gem downloads the exchange rates from the European Central Bank. You can calculate exchange rates with it. It is compatible with the money gem.\n\n## Installation\n\n```\ngem install eu_central_bank\n```\n\nIn case you're using older ruby (\u003c 2.1) you need nokogiri \u003c 1.6.8, so add this to your `Gemfile`:\n\n```\ngem 'nokogiri', '1.6.8'\n```\n\n## Dependencies\n\n- nokogiri\n- money\n\n## Usage\n\nWith the gem, you do not need to manually add exchange rates. Calling `update_rates` will download the rates from the European Central Bank. The API is the same as the money gem. Feel free to use Money objects with the bank.\n\n``` ruby\nrequire 'eu_central_bank'\neu_bank = EuCentralBank.new\nMoney.default_bank = eu_bank\nmoney1 = Money.new(10)\nmoney1.bank # eu_bank\n\n# call this before calculating exchange rates\n# this will download the rates from ECB\neu_bank.update_rates\n\n# exchange 100 CAD to USD\n# API is the same as the money gem\neu_bank.exchange(100, \"CAD\", \"USD\") # Money.new(80, \"USD\")\nMoney.us_dollar(100).exchange_to(\"CAD\")  # Money.new(124, \"CAD\")\n\n# using the new exchange_with method\neu_bank.exchange_with(Money.new(100, \"CAD\"), \"USD\") # Money.new(80, \"USD\")\n```\n\nFor performance reasons, you may prefer to read from a file instead. Furthermore, ECB publishes their rates daily. It makes sense to save the rates in a file to read from. It also adds an `updated_at` field so that you can manage the update.\n\n``` ruby\n# cached location\ncache = \"/some/file/location/exchange_rates.xml\"\n\n# saves the rates in a specified location\neu_bank.save_rates(cache)\n\n# reads the rates from the specified location\neu_bank.update_rates(cache)\n\nif !eu_bank.rates_updated_at || eu_bank.rates_updated_at \u003c Time.now - 1.days\n  eu_bank.save_rates(cache)\n  eu_bank.update_rates(cache)\nend\n\n# exchange 100 CAD to USD as usual\neu_bank.exchange_with(Money.new(100, \"CAD\"), \"USD\") # Money.new(80, \"USD\")\n```\n\n## Note on Patches/Pull Requests\n\n- Fork the project.\n- Make your feature addition or bug fix.\n- Add tests for it. This is important so I don't break it in a  future version unintentionally.\n- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)\n\n## Copyright\n\nCopyright (c) 2010-2016 RubyMoney. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubymoney%2Feu_central_bank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubymoney%2Feu_central_bank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubymoney%2Feu_central_bank/lists"}