<commit_before>h1. cash_handler

cash_handler aims to be an intuitive (and useful) set of extensions and utilities to assist in handling money across different currencies for Ruby on Rails.

h2. Requirements and Installation

* Install the hpricot gem  (gem install hpricot)
* Install the cash_handler plugin  (script/plugin install git://github.com/JamesBrooks/cash_handler.git)

h2. Usage

<pre><code>
  c = CashHandler::Base.new
  
  # Get the current exchange rate of the AUD against the USD (currency code strings are case in-sensitive, can also be symbols)
  c.get('AUD')
  => 0.619099
  
  # Get the current exchange rate of the AUD against the GBP
  c.get('AUD', :against => 'GBP')
  => 0.418621272567449
  
  # Convert
  c.convert(10, :aud, :usd)
  => 6.19099
  
  # Force the converstion rates cache to reload currencies
  c.cache.expire
  
  # The CashHandler::Cache has a default cache life of one day, this can be overridden in one of two ways
  # Upon creation
  c = CashHandler::Base.new(30.minutes)
  
  # During operation
  c.cache.ttl = 30.minutes
</code></pre>

h2. Backup rates in case x-rates.com is inaccessible

You may configure cash_handler to create a backup file every time it pulls rates from x-rates.com.  In the event that x-rates.com is inaccessible, the rates stored in the backup file will be used.

<pre><code>
  # Configure cash_handler to persist rates to our app's log directory
  c = CacheHandler::Base.new(1.day, "#{RAILS_ROOT}/log/rates_backup.yml")
</code></pre><commit_msg>Fixed minor typo<commit_after>h1. cash_handler

cash_handler aims to be an intuitive (and useful) set of extensions and utilities to assist in handling money across different currencies for Ruby on Rails.

h2. Requirements and Installation

* Install the hpricot gem  (gem install hpricot)
* Install the cash_handler plugin  (script/plugin install git://github.com/JamesBrooks/cash_handler.git)

h2. Usage

<pre><code>
  c = CashHandler::Base.new
  
  # Get the current exchange rate of the AUD against the USD (currency code strings are case in-sensitive, can also be symbols)
  c.get('AUD')
  => 0.619099
  
  # Get the current exchange rate of the AUD against the GBP
  c.get('AUD', :against => 'GBP')
  => 0.418621272567449
  
  # Convert
  c.convert(10, :aud, :usd)
  => 6.19099
  
  # Force the converstion rates cache to reload currencies
  c.cache.expire
  
  # The CashHandler::Cache has a default cache life of one day, this can be overridden in one of two ways
  # Upon creation
  c = CashHandler::Base.new(30.minutes)
  
  # During operation
  c.cache.ttl = 30.minutes
</code></pre>

h2. Backup rates in case x-rates.com is inaccessible

You may configure cash_handler to create a backup file every time it pulls rates from x-rates.com.  In the event that x-rates.com is inaccessible, the rates stored in the backup file will be used.

<pre><code>
  # Configure cash_handler to persist rates to our app's log directory
  c = CashHandler::Base.new(1.day, "#{RAILS_ROOT}/log/rates_backup.yml")
</code></pre>
{'fraction_non_alphanumeric': 0.08839050131926121, 'fraction_numerical': 0.026385224274406333, 'mean_word_length': 3.8066561014263076, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2703242', 'n_tokens_mistral': 1053, 'n_tokens_neox': 942, 'n_words': 373}