Permalink
Browse files

Make Currency class exist by default.

If loaded by lib/iso4217.rb Currency class will be disabled.
  • Loading branch information...
1 parent a87d295 commit 7e36a62202ef22234f658e8fda79c877318c73dc @pr0d1r2 pr0d1r2 committed Feb 3, 2011
Showing with 48 additions and 7 deletions.
  1. +12 −1 README.markdown
  2. +3 −5 lib/currencies.rb
  3. +8 −0 lib/iso4217.rb
  4. +24 −0 spec/currency_spec.rb
  5. +1 −1 spec/spec_helper.rb
View
@@ -10,10 +10,21 @@ Currencies is hosted on GemCutter, so simply run the following:
gem sources -a http://gemcutter.org
sudo gem install currencies
-
+
+Or you can install via bundler Gemfile:
+
+ gem 'currencies'
+
+Or you can install via bundler Gemfile with using only ISO4217::Currency (no Currency class):
+
+ gem 'currencies', :require => 'iso4217'
+
Basic Usage
-----------
+Note that Currency class still exist by default.
+(is inherited from ISO4217::Currency to keep backward compatibility).
+
There are two ways to get a currency object. The first is to simply make it.
ISO4217::Currency.new('USD', :name => 'Dollars', :symbol => '$', :exchange_rate => 1)
View
@@ -1,8 +1,6 @@
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
-require 'YAML' unless defined?(YAML)
-require 'net/http' unless defined?(Net::HTTP)
+require 'iso4217'
-require 'currencies/extentions'
-require 'currencies/currency'
-require 'currencies/exchange_bank'
+class Currency < ISO4217::Currency
+end
View
@@ -0,0 +1,8 @@
+$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
+
+require 'YAML' unless defined?(YAML)
+require 'net/http' unless defined?(Net::HTTP)
+
+require 'currencies/extentions'
+require 'currencies/currency'
+require 'currencies/exchange_bank'
View
@@ -337,4 +337,28 @@
end
end
+ describe "Currency class" do
+ context "when loaded via 'iso4217' existance" do
+ subject { defined?(Currency) }
+
+ it { should be_false }
+ end
+
+ context "when loaded via 'currencies'" do
+ before { require 'currencies' }
+
+ describe "existance" do
+ subject { defined?(Currency) }
+
+ it { should be_true }
+ end
+
+ describe "superclass" do
+ subject { Currency.superclass }
+
+ it { should == ISO4217::Currency }
+ end
+ end
+ end
+
end
View
@@ -1,6 +1,6 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'currencies'
+require 'iso4217'
require 'spec'
require 'spec/autorun'

0 comments on commit 7e36a62

Please sign in to comment.