README.md in money-open-exchange-rates-0.6.1 vs README.md in money-open-exchange-rates-0.7.0
- old
+ new
@@ -1,10 +1,21 @@
# Money Open Exchange Rates
A gem that calculates the exchange rate using published rates from
[open-exchange-rates](https://openexchangerates.org/)
+Check [api documentation](https://docs.openexchangerates.org/)
+
+* [Live](https://docs.openexchangerates.org/docs/latest-json) and
+ [historical](https://docs.openexchangerates.org/docs/historical-json)
+ exchange rates for
+ [180 currencies](https://docs.openexchangerates.org/docs/supported-currencies).
+* [Free plan](https://openexchangerates.org/signup) hourly updates, with USD
+ base and up to 1,000 requests/month.
+* Currency caching.
+* Calculate pair rates.
+
## Installation
Add this line to your application's Gemfile:
~~~ ruby
@@ -25,45 +36,47 @@
## Usage
~~~ ruby
require 'money/bank/open_exchange_rates_bank'
-moe = Money::Bank::OpenExchangeRatesBank.new
-moe.cache = 'path/to/file/cache'
-moe.app_id = 'your app id from https://openexchangerates.org/signup'
-moe.update_rates
+oxr = Money::Bank::OpenExchangeRatesBank.new
+oxr.cache = 'path/to/file/cache.json'
+oxr.app_id = 'your app id from https://openexchangerates.org/signup'
+oxr.update_rates
# (optional)
# set the seconds after than the current rates are automatically expired
# by default, they never expire, in this example 1 day.
-moe.ttl_in_seconds = 86400
+oxr.ttl_in_seconds = 86400
# (optional)
# use https to fetch rates from Open Exchange Rates
# disabled by default to support free-tier users
# see https://openexchangerates.org/documentation#https
-moe.secure_connection = true
+oxr.secure_connection = true
# (optional)
# set historical date of the rate
# see https://openexchangerates.org/documentation#historical-data
-moe.date = '2015-01-01'
+oxr.date = '2015-01-01'
# (optional)
# Set the base currency for all rates. By default, USD is used.
# OpenExchangeRates only allows USD as base currency
# for the free plan users.
-moe.source = 'USD'
+oxr.source = 'USD'
# Store in cache
-moe.save_rates
+oxr.save_rates
-Money.default_bank = moe
+Money.default_bank = oxr
+
+Money.default_bank.get_rate('USD', 'CAD')
~~~
You can also provide a Proc as a cache to provide your own caching mechanism
perhaps with Redis or just a thread safe `Hash` (global). For example:
~~~ ruby
-moe.cache = Proc.new do |v|
+oxr.cache = Proc.new do |v|
key = 'money:exchange_rates'
if v
Thread.current[key] = v
else
Thread.current[key]
@@ -80,11 +93,11 @@
bundle exec rake
~~~
## Refs
-* <https://github.com/currencybot/open-exchange-rates>
+* <https://github.com/josscrowcroft/open-exchange-rates>
* <https://github.com/RubyMoney/money>
* <https://github.com/RubyMoney/eu_central_bank>
* <https://github.com/RubyMoney/google_currency>
## Contributors
@@ -100,7 +113,7 @@
---
[![Build](https://img.shields.io/travis-ci/spk/money-open-exchange-rates.svg)](https://travis-ci.org/spk/money-open-exchange-rates)
[![Version](https://img.shields.io/gem/v/money-open-exchange-rates.svg)](https://rubygems.org/gems/money-open-exchange-rates)
[![Documentation](https://img.shields.io/badge/doc-rubydoc-blue.svg)](http://www.rubydoc.info/gems/money-open-exchange-rates)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT "MIT")
-[![Code Climate](http://img.shields.io/codeclimate/github/spk/money-open-exchange-rates.svg)](https://codeclimate.com/github/spk/money-open-exchange-rates)
-[![Inline docs](http://inch-ci.org/github/spk/money-open-exchange-rates.svg?branch=master)](http://inch-ci.org/github/spk/money-open-exchange-rates)
+[![Code Climate](https://img.shields.io/codeclimate/github/spk/money-open-exchange-rates.svg)](https://codeclimate.com/github/spk/money-open-exchange-rates)
+[![Inline docs](https://inch-ci.org/github/spk/money-open-exchange-rates.svg?branch=master)](http://inch-ci.org/github/spk/money-open-exchange-rates)