Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make Currency class exist by default.

If loaded by lib/iso4217.rb Currency class will be disabled.
  • Loading branch information...
commit 7e36a62202ef22234f658e8fda79c877318c73dc 1 parent a87d295
@pr0d1r2 pr0d1r2 authored
View
13 README.markdown
@@ -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
8 lib/currencies.rb
@@ -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
8 lib/iso4217.rb
@@ -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
24 spec/currency_spec.rb
@@ -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
2  spec/spec_helper.rb
@@ -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'
Please sign in to comment.
Something went wrong with that request. Please try again.