currencies 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.markdown +105 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/currencies.rb +8 -0
- data/lib/currencies/currency.rb +54 -0
- data/lib/currencies/exchange_bank.rb +46 -0
- data/lib/currencies/extentions.rb +4 -0
- data/lib/data/iso4217.yaml +779 -0
- data/spec/currency_spec.rb +55 -0
- data/spec/exchange_bank_spec.rb +49 -0
- data/spec/spec_helper.rb +9 -0
- metadata +90 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 hexorx
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
Currencies
|
2
|
+
==========
|
3
|
+
|
4
|
+
If you are tracking any kind of assets the currencies gem is for you. It contains every currency in the ISO 4217 standard and allows you to add your own as well. So if you decide to take sparkly buttons as a form of payment you can use currencies to display the shiny button unicode symbol ☼ (disclaimer: ☼ may not look like a shiny button to everyone.) when used with something like the money gem. Speaking of the money gem, currencies gives you an ExchangeBank that the money gem can use to convert from one currency to another. There are plans to have ExchangeRate provider plugin system. Right now the rates are either set manually or pulled from Yahoo Finance.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
Countries is hosted on GemCutter, so simply run the following:
|
10
|
+
|
11
|
+
gem sources -a http://gemcutter.org
|
12
|
+
sudo gem install currencies
|
13
|
+
|
14
|
+
Basic Usage
|
15
|
+
-----------
|
16
|
+
|
17
|
+
There are two ways to get a currency object. The first is to simply make it.
|
18
|
+
|
19
|
+
Currency.new('USD', :name => 'Dollars', :symbol => '$', :exchange_rate => 1)
|
20
|
+
|
21
|
+
Or you can lookup a currency by its ISO 4217 code using the *from_code* method.
|
22
|
+
|
23
|
+
Currency.from_code('USD')
|
24
|
+
|
25
|
+
Once you have a Currency instance you can get basic information about it.
|
26
|
+
|
27
|
+
currency = Currency.from_code('USD')
|
28
|
+
currency.code #=> "USD"
|
29
|
+
currency.name #=> "Dollars"
|
30
|
+
currency.symbol #=> "$"
|
31
|
+
currency.exchange_rate #=> 1.0
|
32
|
+
currency.exchange_currency #=> "USD"
|
33
|
+
|
34
|
+
Adding Currencies
|
35
|
+
-----------------
|
36
|
+
|
37
|
+
Currencies keeps an internal list of currencies for use in the ExchangeBank and to be looked up with the *from_code* method. By default this list contains all the currencies in the ISO 4217 standard. A custom currency can be added using the *add* class method.
|
38
|
+
|
39
|
+
shiny_button = Currency.new('SBTTN', :name => 'Buttons', :symbol => '☼', :exchange_rate => 1000)
|
40
|
+
Currency.add(shiny_button)
|
41
|
+
|
42
|
+
To do a massive addition of currencies you can load a yaml file using the *load_file* class method.
|
43
|
+
|
44
|
+
Currency.load_file('custom_currency.yaml')
|
45
|
+
|
46
|
+
And the yaml file should look like ...
|
47
|
+
|
48
|
+
SBTTN:
|
49
|
+
name: Buttons
|
50
|
+
symbol: ☼
|
51
|
+
|
52
|
+
Defaults
|
53
|
+
--------
|
54
|
+
|
55
|
+
You can set the base currency by using the *base_currency* class method. This defaults to 'USD'.
|
56
|
+
|
57
|
+
Currency.base_currency => 'GBP'
|
58
|
+
|
59
|
+
The exchange rate is either set manually or if nil looked up on Yahoo Finance and cached. If you want to disable looking up the currency set the *import_exchange_rates* class method to false.
|
60
|
+
|
61
|
+
Currency.import_exchange_rates = false
|
62
|
+
|
63
|
+
|
64
|
+
Money Gem
|
65
|
+
---------
|
66
|
+
|
67
|
+
To use with the money gem you just set the default bank to the currencies bank.
|
68
|
+
|
69
|
+
Money.default_bank = Currency::ExchangeBank.new
|
70
|
+
|
71
|
+
The Currencies ExchangeBank works the same as the one in the money gem except that if an exchange rate isn't set by default it uses what is set in the currencies gem.
|
72
|
+
|
73
|
+
ToDo
|
74
|
+
----
|
75
|
+
|
76
|
+
* Plugin exchange rate things
|
77
|
+
* Add some to_currency methods
|
78
|
+
* Add more ways to find a currency
|
79
|
+
* Make the ExchangeBank accept Currency objects
|
80
|
+
|
81
|
+
Sponsored By
|
82
|
+
------------
|
83
|
+
|
84
|
+
This gem is sponsored by [Teliax][]. [Teliax][] makes business class Voice, [Centrex][](Including Hosted: IVRs, Ring Groups, Extensions and Day Night Mode) and Data services accessible to anyone. You don't have to be a fortune 500 to sound big!
|
85
|
+
|
86
|
+
Note on Patches/Pull Requests
|
87
|
+
-----------------------------
|
88
|
+
|
89
|
+
* Fork the project.
|
90
|
+
* Make your feature addition or bug fix.
|
91
|
+
* Add tests for it. This is important so I don't break it in a
|
92
|
+
future version unintentionally.
|
93
|
+
* Commit, do not mess with rakefile, version, or history.
|
94
|
+
(if you want to have your own version, that is fine but
|
95
|
+
bump version in a commit by itself I can ignore when I pull)
|
96
|
+
* Send me a pull request. Bonus points for topic branches.
|
97
|
+
|
98
|
+
Copyright
|
99
|
+
---------
|
100
|
+
|
101
|
+
Copyright (c) 2010 hexorx. See LICENSE for details.
|
102
|
+
|
103
|
+
|
104
|
+
[Teliax]: http://teliax.com
|
105
|
+
[Centrex]: http://en.wikipedia.org/wiki/Centrex
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "currencies"
|
8
|
+
gem.summary = %Q{Simple gem for working with currencies. It is extracted from the countries gem and contains all the currency information in the ISO 4217 standard.}
|
9
|
+
gem.description = %Q{If you are tracking any kind of assets the currencies gem is for you. It contains every currency in the ISO 4217 standard and allows you to add your own as well. So if you decide to take sparkly buttons as a form of payment you can use currencies to display the shiny button unicode symbol ☼ (disclaimer: ☼ may not look like a shiny button to everyone.) when used with something like the money gem. Speaking of the money gem, currencies gives you an ExchangeBank that the money gem can use to convert from one currency to another. There are plans to have ExchangeRate provider plugin system. Right now the rates are either set manually or pulled from Yahoo Finance.}
|
10
|
+
gem.email = "hexorx@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/hexorx/currencies"
|
12
|
+
gem.authors = ["hexorx"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
gem.add_development_dependency "yard"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'yard'
|
40
|
+
YARD::Rake::YardocTask.new
|
41
|
+
rescue LoadError
|
42
|
+
task :yardoc do
|
43
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
44
|
+
end
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/currencies.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class Currency
|
2
|
+
class << self
|
3
|
+
attr_accessor :currencies
|
4
|
+
attr_accessor :base_currency
|
5
|
+
attr_accessor :import_exchange_rates
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :code, :symbol, :name, :exchange_currency
|
9
|
+
|
10
|
+
def initialize(iso_code,opts={})
|
11
|
+
@code = iso_code.to_s.upcase
|
12
|
+
@name = opts['name']
|
13
|
+
@symbol = opts['symbol']
|
14
|
+
@exchange_currency = opts['exchange_currency'] || Currency.base_currency
|
15
|
+
@exchange_rate = opts['exchange_rate'].to_f
|
16
|
+
end
|
17
|
+
|
18
|
+
def exchange_rate
|
19
|
+
@exchange_rate = nil unless @exchange_currency == Currency.base_currency
|
20
|
+
@exchange_rate ||= load_exchange_rate
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_exchange_rate
|
24
|
+
@exchange_currency = Currency.base_currency
|
25
|
+
return 1.0 if @code == @exchange_currency
|
26
|
+
if Currency.import_exchange_rates
|
27
|
+
http = Net::HTTP.new('download.finance.yahoo.com', 80)
|
28
|
+
response = http.get("/d/quotes.csv?e=.csv&f=sl1d1t1&s=#{@code}#{@exchange_currency}=X")
|
29
|
+
rate = response.body.split(',')[1]
|
30
|
+
rate == '0.0' ? nil : rate.to_f
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.load_file(file)
|
37
|
+
YAML.load_file(file).each do |code,options|
|
38
|
+
self.add(self.new(code,options))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.from_code(code)
|
43
|
+
self.currencies[code.to_s.upcase]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.add(new_currency)
|
47
|
+
self.currencies ||= {}
|
48
|
+
self.currencies[new_currency.code] = new_currency
|
49
|
+
end
|
50
|
+
|
51
|
+
load_file(File.join(File.dirname(__FILE__), '..', 'data', 'iso4217.yaml'))
|
52
|
+
self.base_currency = 'USD'
|
53
|
+
self.import_exchange_rates = true
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Currency
|
2
|
+
class ExchangeBank
|
3
|
+
def self.instance
|
4
|
+
@@singleton
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@rates = {}
|
9
|
+
@mutex = Mutex.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_rate(from, to, rate)
|
13
|
+
@mutex.synchronize do
|
14
|
+
@rates["#{from}_TO_#{to}".upcase] = rate
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_rate(from, to)
|
19
|
+
@mutex.synchronize do
|
20
|
+
@rates["#{from}_TO_#{to}".upcase]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def same_currency?(currency1, currency2)
|
25
|
+
currency1.upcase == currency2.upcase
|
26
|
+
end
|
27
|
+
|
28
|
+
def exchange(cents, from_currency, to_currency)
|
29
|
+
rate = get_rate(from_currency, to_currency)
|
30
|
+
if rate
|
31
|
+
(cents * rate).floor
|
32
|
+
else
|
33
|
+
from_currency = Currency.from_code(from_currency)
|
34
|
+
to_currency = Currency.from_code(to_currency)
|
35
|
+
|
36
|
+
if from_currency && to_currency && from_currency.exchange_rate && to_currency.exchange_rate && (from_currency.exchange_currency == to_currency.exchange_currency)
|
37
|
+
((cents * from_currency.exchange_rate) / to_currency.exchange_rate).floor
|
38
|
+
else
|
39
|
+
raise Money::UnknownRate, "No conversion rate known for '#{from_currency}' -> '#{to_currency}'"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
@@singleton = ExchangeBank.new
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,779 @@
|
|
1
|
+
---
|
2
|
+
AED:
|
3
|
+
code: AED
|
4
|
+
name: Dirhams
|
5
|
+
AFN:
|
6
|
+
code: AFN
|
7
|
+
name: Afghanis
|
8
|
+
symbol: ؋
|
9
|
+
unicode_hex: 1547
|
10
|
+
ALL:
|
11
|
+
code: ALL
|
12
|
+
name: Leke
|
13
|
+
symbol: LEK
|
14
|
+
unicode_hex:
|
15
|
+
- 76
|
16
|
+
- 101
|
17
|
+
- 107
|
18
|
+
AMD:
|
19
|
+
code: AMD
|
20
|
+
name: Drams
|
21
|
+
ANG:
|
22
|
+
code: ANG
|
23
|
+
name: Guilders
|
24
|
+
symbol: ƒ
|
25
|
+
unicode_hex: 402
|
26
|
+
AOA:
|
27
|
+
code: AOA
|
28
|
+
name: Kwanza
|
29
|
+
ARS:
|
30
|
+
code: ARS
|
31
|
+
name: Pesos
|
32
|
+
symbol: $
|
33
|
+
unicode_hex: 36
|
34
|
+
AUD:
|
35
|
+
code: AUD
|
36
|
+
name: Dollars
|
37
|
+
symbol: $
|
38
|
+
unicode_hex: 36
|
39
|
+
AWG:
|
40
|
+
alt_name: Florins
|
41
|
+
code: AWG
|
42
|
+
name: Guilders
|
43
|
+
symbol: ƒ
|
44
|
+
unicode_hex: 402
|
45
|
+
AZN:
|
46
|
+
code: AZN
|
47
|
+
name: "New Manats"
|
48
|
+
symbol: ман
|
49
|
+
unicode_hex:
|
50
|
+
- 1084
|
51
|
+
- 1072
|
52
|
+
- 1085
|
53
|
+
BAM:
|
54
|
+
code: BAM
|
55
|
+
name: "Convertible Marka"
|
56
|
+
symbol: KM
|
57
|
+
unicode_hex:
|
58
|
+
- 75
|
59
|
+
- 77
|
60
|
+
BBD:
|
61
|
+
code: BBD
|
62
|
+
name: Dollars
|
63
|
+
symbol: $
|
64
|
+
unicode_hex: 36
|
65
|
+
BGN:
|
66
|
+
code: BGN
|
67
|
+
name: Leva
|
68
|
+
symbol: лв
|
69
|
+
unicode_hex:
|
70
|
+
- 82
|
71
|
+
- 1074
|
72
|
+
BHD:
|
73
|
+
code: BHD
|
74
|
+
name: Dinars
|
75
|
+
BIF:
|
76
|
+
code: BIF
|
77
|
+
name: Francs
|
78
|
+
BMD:
|
79
|
+
code: BMD
|
80
|
+
name: Dollars
|
81
|
+
symbol: $
|
82
|
+
unicode_hex: 36
|
83
|
+
BND:
|
84
|
+
code: BND
|
85
|
+
name: Dollars
|
86
|
+
symbol: $
|
87
|
+
unicode_hex: 36
|
88
|
+
BOB:
|
89
|
+
code: BOB
|
90
|
+
name: Bolivianos
|
91
|
+
symbol: $b
|
92
|
+
unicode_hex:
|
93
|
+
- 36
|
94
|
+
- 98
|
95
|
+
BRL:
|
96
|
+
code: BRL
|
97
|
+
name: Real
|
98
|
+
symbol: R$
|
99
|
+
unicode_hex:
|
100
|
+
- 82
|
101
|
+
- 36
|
102
|
+
BSD:
|
103
|
+
code: BSD
|
104
|
+
name: Dollars
|
105
|
+
symbol: $
|
106
|
+
unicode_hex: 36
|
107
|
+
BTD:
|
108
|
+
code: BTD
|
109
|
+
name: Taka
|
110
|
+
BTN:
|
111
|
+
code: BTN
|
112
|
+
name: Ngultrum
|
113
|
+
BWP:
|
114
|
+
code: BWP
|
115
|
+
name: Pulas
|
116
|
+
symbol: P
|
117
|
+
unicode_hex: 80
|
118
|
+
BYR:
|
119
|
+
code: BYR
|
120
|
+
name: Rubles
|
121
|
+
symbol: p.
|
122
|
+
unicode_hex:
|
123
|
+
- 112
|
124
|
+
- 46
|
125
|
+
BZD:
|
126
|
+
code: BZD
|
127
|
+
name: Dollars
|
128
|
+
symbol: BZ$
|
129
|
+
unicode_hex:
|
130
|
+
- 66
|
131
|
+
- 90
|
132
|
+
- 36
|
133
|
+
CAD:
|
134
|
+
code: CAD
|
135
|
+
name: Dollars
|
136
|
+
symbol: $
|
137
|
+
unicode_hex: 36
|
138
|
+
CHF:
|
139
|
+
code: CHF
|
140
|
+
name: "Switzerland Francs"
|
141
|
+
symbol: CHF
|
142
|
+
unicode_hex:
|
143
|
+
- 67
|
144
|
+
- 72
|
145
|
+
- 70
|
146
|
+
CLP:
|
147
|
+
code: CLP
|
148
|
+
name: Pesos
|
149
|
+
symbol: $
|
150
|
+
unicode_hex: 36
|
151
|
+
CNY:
|
152
|
+
code: CNY
|
153
|
+
name: "Yuan Renminbi"
|
154
|
+
symbol: ¥
|
155
|
+
unicode_hex: 165
|
156
|
+
COP:
|
157
|
+
code: COP
|
158
|
+
name: Pesos
|
159
|
+
symbol: $
|
160
|
+
unicode_hex: 36
|
161
|
+
CRC:
|
162
|
+
code: CRC
|
163
|
+
name: Colones
|
164
|
+
symbol: ₡
|
165
|
+
unicode_hex: 8353
|
166
|
+
CUP:
|
167
|
+
code: CUP
|
168
|
+
name: Pesos
|
169
|
+
symbol: ₱
|
170
|
+
unicode_hex: 8369
|
171
|
+
CVE:
|
172
|
+
code: CVE
|
173
|
+
name: Escudos
|
174
|
+
CZK:
|
175
|
+
code: CZK
|
176
|
+
name: Koruny
|
177
|
+
symbol: Kč
|
178
|
+
unicode_hex:
|
179
|
+
- 75
|
180
|
+
- 269
|
181
|
+
DJF:
|
182
|
+
code: DJF
|
183
|
+
name: Francs
|
184
|
+
DKK:
|
185
|
+
code: DKK
|
186
|
+
name: Kroner
|
187
|
+
symbol: kr
|
188
|
+
unicode_hex:
|
189
|
+
- 107
|
190
|
+
- 114
|
191
|
+
DOP:
|
192
|
+
code: DOP
|
193
|
+
name: Pesos
|
194
|
+
symbol: RD$
|
195
|
+
unicode_hex:
|
196
|
+
- 82
|
197
|
+
- 68
|
198
|
+
- 36
|
199
|
+
DZD:
|
200
|
+
code: DZD
|
201
|
+
name: Dinars
|
202
|
+
EEK:
|
203
|
+
code: EEK
|
204
|
+
name: Krooni
|
205
|
+
symbol: kr
|
206
|
+
unicode_hex:
|
207
|
+
- 107
|
208
|
+
- 114
|
209
|
+
EGP:
|
210
|
+
code: EGP
|
211
|
+
name: Pounds
|
212
|
+
symbol: £
|
213
|
+
unicode_hex: 163
|
214
|
+
ETB:
|
215
|
+
code: ETB
|
216
|
+
name: "Ethopia Birr"
|
217
|
+
EUR:
|
218
|
+
code: EUR
|
219
|
+
name: Euro
|
220
|
+
symbol: €
|
221
|
+
unicode_hex: 8364
|
222
|
+
FKP:
|
223
|
+
code: FKP
|
224
|
+
name: Pounds
|
225
|
+
symbol: £
|
226
|
+
unicode_hex: 163
|
227
|
+
GBP:
|
228
|
+
code: GBP
|
229
|
+
name: Pounds
|
230
|
+
symbol: £
|
231
|
+
unicode_hex: 163
|
232
|
+
GEL:
|
233
|
+
code: GEL
|
234
|
+
name: Lari
|
235
|
+
GGP:
|
236
|
+
code: GGP
|
237
|
+
name: Pounds
|
238
|
+
symbol: £
|
239
|
+
unicode_hex: 163
|
240
|
+
GHS:
|
241
|
+
code: GHS
|
242
|
+
name: Cedis
|
243
|
+
symbol: ¢
|
244
|
+
unicode_hex: 162
|
245
|
+
GIP:
|
246
|
+
code: GIP
|
247
|
+
name: Pounds
|
248
|
+
symbol: £
|
249
|
+
unicode_hex: 163
|
250
|
+
GMD:
|
251
|
+
code: GMD
|
252
|
+
name: Lari
|
253
|
+
GNF:
|
254
|
+
code: GNF
|
255
|
+
name: Francs
|
256
|
+
GTQ:
|
257
|
+
code: GTQ
|
258
|
+
name: Quetzales
|
259
|
+
symbol: Q
|
260
|
+
unicode_hex: 81
|
261
|
+
GYD:
|
262
|
+
code: GYD
|
263
|
+
name: Dollars
|
264
|
+
HKD:
|
265
|
+
code: HKD
|
266
|
+
name: Dollars
|
267
|
+
symbol: $
|
268
|
+
unicode_hex: 36
|
269
|
+
HNL:
|
270
|
+
code: HNL
|
271
|
+
name: Lempiras
|
272
|
+
symbol: L
|
273
|
+
unicode_hex: 76
|
274
|
+
HRK:
|
275
|
+
code: HRK
|
276
|
+
name: Kuna
|
277
|
+
symbol: kn
|
278
|
+
unicode_hex:
|
279
|
+
- 107
|
280
|
+
- 110
|
281
|
+
HUF:
|
282
|
+
code: HUF
|
283
|
+
name: Forint
|
284
|
+
symbol: Ft
|
285
|
+
unicode_hex:
|
286
|
+
- 70
|
287
|
+
- 116
|
288
|
+
IDR:
|
289
|
+
code: IDR
|
290
|
+
name: "Indonesian Rupiahs"
|
291
|
+
symbol: Rp
|
292
|
+
unicode_hex:
|
293
|
+
- 82
|
294
|
+
- 112
|
295
|
+
ILS:
|
296
|
+
code: ILS
|
297
|
+
name: "New Shekels"
|
298
|
+
symbol: ₪
|
299
|
+
unicode_hex: 8362
|
300
|
+
IMP:
|
301
|
+
code: IMP
|
302
|
+
name: Pounds
|
303
|
+
symbol: £
|
304
|
+
unicode_hex: 163
|
305
|
+
INR:
|
306
|
+
code: INR
|
307
|
+
name: Rupees
|
308
|
+
symbol: ₨
|
309
|
+
unicode_hex: 8360
|
310
|
+
IQD:
|
311
|
+
code: IQD
|
312
|
+
name: Dinars
|
313
|
+
IRR:
|
314
|
+
code: IRR
|
315
|
+
name: Riais
|
316
|
+
symbol: ﷼
|
317
|
+
unicode_hex: 65020
|
318
|
+
ISK:
|
319
|
+
code: ISK
|
320
|
+
name: Kronur
|
321
|
+
symbol: kr
|
322
|
+
unicode_hex:
|
323
|
+
- 107
|
324
|
+
- 114
|
325
|
+
JEP:
|
326
|
+
code: JEP
|
327
|
+
name: Pounds
|
328
|
+
symbol: £
|
329
|
+
unicode_hex: 163
|
330
|
+
JMD:
|
331
|
+
code: JMD
|
332
|
+
name: Dollars
|
333
|
+
JOD:
|
334
|
+
code: JOD
|
335
|
+
name: Dinars
|
336
|
+
JPY:
|
337
|
+
code: JPY
|
338
|
+
name: Yen
|
339
|
+
symbol: ¥
|
340
|
+
unicode_hex: 165
|
341
|
+
KES:
|
342
|
+
code: KES
|
343
|
+
name: Shillings
|
344
|
+
KGS:
|
345
|
+
code: KGS
|
346
|
+
name: Soms
|
347
|
+
symbol: лв
|
348
|
+
unicode_hex:
|
349
|
+
- 1083
|
350
|
+
- 1074
|
351
|
+
KHR:
|
352
|
+
code: KHR
|
353
|
+
name: Rieis
|
354
|
+
KMF:
|
355
|
+
code: KMF
|
356
|
+
name: Francs
|
357
|
+
KPW:
|
358
|
+
code: KPW
|
359
|
+
name: Won
|
360
|
+
symbol: ₩
|
361
|
+
unicode_hex: 8361
|
362
|
+
KRW:
|
363
|
+
code: KRW
|
364
|
+
name: Won
|
365
|
+
symbol: ₩
|
366
|
+
unicode_hex: 8361
|
367
|
+
KWD:
|
368
|
+
code: KWD
|
369
|
+
name: Dinars
|
370
|
+
KYD:
|
371
|
+
code: KYD
|
372
|
+
name: Dollars
|
373
|
+
symbol: $
|
374
|
+
unicode_hex: 36
|
375
|
+
KZT:
|
376
|
+
code: KZT
|
377
|
+
name: Tenege
|
378
|
+
symbol: лв
|
379
|
+
unicode_hex:
|
380
|
+
- 1083
|
381
|
+
- 1074
|
382
|
+
LAK:
|
383
|
+
code: LAK
|
384
|
+
name: Kips
|
385
|
+
symbol: ₭
|
386
|
+
unicode_hex: 8365
|
387
|
+
LBP:
|
388
|
+
code: LBP
|
389
|
+
name: Pounds
|
390
|
+
symbol: £
|
391
|
+
unicode_hex: 163
|
392
|
+
LKR:
|
393
|
+
code: LKR
|
394
|
+
name: Rupees
|
395
|
+
symbol: ₨
|
396
|
+
unicode_hex: 8360
|
397
|
+
LRD:
|
398
|
+
code: LRD
|
399
|
+
name: Dollars
|
400
|
+
symbol: $
|
401
|
+
unicode_hex: 36
|
402
|
+
LSL:
|
403
|
+
alt_currency:
|
404
|
+
code: ZAR
|
405
|
+
name: Rand
|
406
|
+
symbol: R
|
407
|
+
unicode_hex: 82
|
408
|
+
code: LSL
|
409
|
+
name: Maloti
|
410
|
+
LTL:
|
411
|
+
code: LTL
|
412
|
+
name: Litai
|
413
|
+
symbol: Lt
|
414
|
+
unicode_hex:
|
415
|
+
- 76
|
416
|
+
- 116
|
417
|
+
LVL:
|
418
|
+
code: LVL
|
419
|
+
name: Lati
|
420
|
+
symbol: Ls
|
421
|
+
unicode_hex:
|
422
|
+
- 76
|
423
|
+
- 115
|
424
|
+
LYD:
|
425
|
+
code: LYD
|
426
|
+
name: Dinars
|
427
|
+
MAD:
|
428
|
+
code: MAD
|
429
|
+
name: Dirhams
|
430
|
+
MDL:
|
431
|
+
code: MDL
|
432
|
+
name: Lei
|
433
|
+
MNK:
|
434
|
+
code: MNK
|
435
|
+
name: Kyats
|
436
|
+
MNT:
|
437
|
+
code: MNT
|
438
|
+
name: Tugriks
|
439
|
+
symbol: ₮
|
440
|
+
unicode_hex: 8366
|
441
|
+
MRO:
|
442
|
+
code: MRO
|
443
|
+
name: Ouguiyas
|
444
|
+
MUR:
|
445
|
+
code: MUR
|
446
|
+
name: Rupees
|
447
|
+
symbol: ₨
|
448
|
+
unicode_hex: 8360
|
449
|
+
MVR:
|
450
|
+
code: MVR
|
451
|
+
name: Rufiyaa
|
452
|
+
MWK:
|
453
|
+
code: MWK
|
454
|
+
name: Kwachas
|
455
|
+
MXN:
|
456
|
+
code: MXN
|
457
|
+
name: Pesos
|
458
|
+
symbol: $
|
459
|
+
unicode_hex: 36
|
460
|
+
MYR:
|
461
|
+
code: MYR
|
462
|
+
name: Ringgits
|
463
|
+
symbol: RM
|
464
|
+
unicode_hex:
|
465
|
+
- 82
|
466
|
+
- 77
|
467
|
+
MZN:
|
468
|
+
code: MZN
|
469
|
+
name: Meticals
|
470
|
+
symbol: MT
|
471
|
+
unicode_hex:
|
472
|
+
- 77
|
473
|
+
- 84
|
474
|
+
NAD:
|
475
|
+
alt_currency:
|
476
|
+
code: ZAR
|
477
|
+
name: Rand
|
478
|
+
symbol: R
|
479
|
+
unicode_hex: 82
|
480
|
+
code: NAD
|
481
|
+
name: Dollars
|
482
|
+
symbol: $
|
483
|
+
unicode_hex: 36
|
484
|
+
NGN:
|
485
|
+
code: NGN
|
486
|
+
name: Nairas
|
487
|
+
symbol: ₦
|
488
|
+
unicode_hex: 8358
|
489
|
+
NIO:
|
490
|
+
code: NIO
|
491
|
+
name: Cordobas
|
492
|
+
symbol: C$
|
493
|
+
unicode_hex:
|
494
|
+
- 67
|
495
|
+
- 36
|
496
|
+
NOK:
|
497
|
+
code: NOK
|
498
|
+
name: Kroner
|
499
|
+
symbol: kr
|
500
|
+
unicode_hex:
|
501
|
+
- 123
|
502
|
+
- 114
|
503
|
+
NPR:
|
504
|
+
code: NPR
|
505
|
+
name: Rupees
|
506
|
+
symbol: ₨
|
507
|
+
unicode_hex: 8360
|
508
|
+
NZD:
|
509
|
+
code: NZD
|
510
|
+
name: "New Zealand Dollars"
|
511
|
+
symbol: $
|
512
|
+
unicode_hex: 36
|
513
|
+
OMR:
|
514
|
+
code: OMR
|
515
|
+
name: Riais
|
516
|
+
symbol: ﷼
|
517
|
+
unicode_hex: 65020
|
518
|
+
PAB:
|
519
|
+
alt_currency:
|
520
|
+
code: USD
|
521
|
+
name: Dollars
|
522
|
+
symbol: $
|
523
|
+
unicode_hex: 36
|
524
|
+
code: PAB
|
525
|
+
name: Balboa
|
526
|
+
symbol: B/.
|
527
|
+
unicode_hex:
|
528
|
+
- 66
|
529
|
+
- 47
|
530
|
+
- 46
|
531
|
+
PEN:
|
532
|
+
code: PEN
|
533
|
+
name: "Nuevos Soles"
|
534
|
+
symbol: S/.
|
535
|
+
unicode_hex:
|
536
|
+
- "0x50,0x2f,0x2e"
|
537
|
+
PGK:
|
538
|
+
code: PGK
|
539
|
+
name: Kina
|
540
|
+
PHP:
|
541
|
+
code: PHP
|
542
|
+
name: Pesos
|
543
|
+
symbol: Php
|
544
|
+
unicode_hex:
|
545
|
+
- 80
|
546
|
+
- 104
|
547
|
+
- 112
|
548
|
+
PKR:
|
549
|
+
code: PKR
|
550
|
+
name: Rupees
|
551
|
+
symbol: ₨
|
552
|
+
unicode_hex: 8360
|
553
|
+
PLN:
|
554
|
+
code: PLN
|
555
|
+
name: Zlotych
|
556
|
+
symbol: zł
|
557
|
+
unicode_hex:
|
558
|
+
- 122
|
559
|
+
- 322
|
560
|
+
PYG:
|
561
|
+
code: PYG
|
562
|
+
name: Guarani
|
563
|
+
symbol: Gs
|
564
|
+
unicode_hex:
|
565
|
+
- 71
|
566
|
+
- 115
|
567
|
+
QAR:
|
568
|
+
code: QAR
|
569
|
+
name: Rials
|
570
|
+
symbol: ﷼
|
571
|
+
unicode_hex: 65020
|
572
|
+
RON:
|
573
|
+
code: RON
|
574
|
+
name: "New Lei"
|
575
|
+
symbol: lei
|
576
|
+
unicode_hex:
|
577
|
+
- 108
|
578
|
+
- 101
|
579
|
+
- 105
|
580
|
+
RSD:
|
581
|
+
code: RSD
|
582
|
+
name: Dinars
|
583
|
+
symbol: Дин.
|
584
|
+
unicode_hex:
|
585
|
+
- 1044
|
586
|
+
- 1080
|
587
|
+
- 1085
|
588
|
+
- 46
|
589
|
+
RUB:
|
590
|
+
code: RUB
|
591
|
+
name: Rubles
|
592
|
+
symbol: руб
|
593
|
+
unicode_hex:
|
594
|
+
- 1088
|
595
|
+
- 1091
|
596
|
+
- 1073
|
597
|
+
RWF:
|
598
|
+
code: RWF
|
599
|
+
name: Francs
|
600
|
+
SAR:
|
601
|
+
code: SAR
|
602
|
+
name: Riyals
|
603
|
+
symbol: ﷼
|
604
|
+
unicode_hex: 65020
|
605
|
+
SBD:
|
606
|
+
code: SBD
|
607
|
+
name: Dollars
|
608
|
+
symbol: $
|
609
|
+
unicode_hex: 36
|
610
|
+
SCR:
|
611
|
+
code: SCR
|
612
|
+
name: Rupees
|
613
|
+
symbol: ₨
|
614
|
+
unicode_hex: 8360
|
615
|
+
SDG:
|
616
|
+
code: SDG
|
617
|
+
name: Pounds
|
618
|
+
SEK:
|
619
|
+
code: SEK
|
620
|
+
name: Kronor
|
621
|
+
symbol: kr
|
622
|
+
unicode_hex:
|
623
|
+
- 107
|
624
|
+
- 114
|
625
|
+
SGD:
|
626
|
+
code: SGD
|
627
|
+
name: Dollars
|
628
|
+
symbol: $
|
629
|
+
unicode_hex: 36
|
630
|
+
SHP:
|
631
|
+
code: SHP
|
632
|
+
name: Pounds
|
633
|
+
symbol: £
|
634
|
+
unicode_hex: 163
|
635
|
+
SLL:
|
636
|
+
code: SLL
|
637
|
+
name: Leones
|
638
|
+
SOS:
|
639
|
+
code: SOS
|
640
|
+
name: Shillings
|
641
|
+
symbol: S
|
642
|
+
unicode_hex: 83
|
643
|
+
SRD:
|
644
|
+
code: SRD
|
645
|
+
name: Dollars
|
646
|
+
symbol: $
|
647
|
+
unicode_hex: 36
|
648
|
+
STD:
|
649
|
+
code: STD
|
650
|
+
name: Dobras
|
651
|
+
SYP:
|
652
|
+
code: SYP
|
653
|
+
name: Pounds
|
654
|
+
symbol: £
|
655
|
+
unicode_hex: 163
|
656
|
+
SZL:
|
657
|
+
code: SZL
|
658
|
+
name: Emalangeni
|
659
|
+
THB:
|
660
|
+
code: THB
|
661
|
+
name: Baht
|
662
|
+
symbol: ฿
|
663
|
+
unicode_hex: 3647
|
664
|
+
TJS:
|
665
|
+
alt_currency:
|
666
|
+
code: RUB
|
667
|
+
name: Rubles
|
668
|
+
symbol: руб
|
669
|
+
unicode_hex:
|
670
|
+
- 1088
|
671
|
+
- 1091
|
672
|
+
- 1073
|
673
|
+
code: TJS
|
674
|
+
name: Somoni
|
675
|
+
TND:
|
676
|
+
code: TND
|
677
|
+
name: Dollars
|
678
|
+
TOP:
|
679
|
+
code: TOP
|
680
|
+
name: Pa'anga
|
681
|
+
TRY:
|
682
|
+
code: TRY
|
683
|
+
name: Lira
|
684
|
+
symbol: TL
|
685
|
+
unicode_hex:
|
686
|
+
- 84
|
687
|
+
- 76
|
688
|
+
TTD:
|
689
|
+
code: TTD
|
690
|
+
name: Dollars
|
691
|
+
symbol: $
|
692
|
+
unicode_hex: 36
|
693
|
+
TVD:
|
694
|
+
code: TVD
|
695
|
+
name: "Tuvalu Dollars"
|
696
|
+
TWD:
|
697
|
+
code: TWD
|
698
|
+
name: "New Dollars"
|
699
|
+
symbol: NT$
|
700
|
+
unicode_hex:
|
701
|
+
- 78
|
702
|
+
- 84
|
703
|
+
- 36
|
704
|
+
TZS:
|
705
|
+
code: TZS
|
706
|
+
name: Shillings
|
707
|
+
UAH:
|
708
|
+
code: UAH
|
709
|
+
name: Hryvnia
|
710
|
+
symbol: ₴
|
711
|
+
unicode_hex: 8372
|
712
|
+
UGX:
|
713
|
+
code: UGX
|
714
|
+
name: Shillings
|
715
|
+
USD:
|
716
|
+
code: USD
|
717
|
+
name: Dollars
|
718
|
+
symbol: $
|
719
|
+
unicode_hex: 36
|
720
|
+
UYU:
|
721
|
+
code: UYU
|
722
|
+
name: Pesos
|
723
|
+
symbol: $U
|
724
|
+
unicode_hex:
|
725
|
+
- 36
|
726
|
+
- 85
|
727
|
+
UZS:
|
728
|
+
code: UZS
|
729
|
+
name: Sums
|
730
|
+
symbol: лв
|
731
|
+
unicode_hex:
|
732
|
+
- 1083
|
733
|
+
- 1074
|
734
|
+
VEF:
|
735
|
+
code: VEF
|
736
|
+
name: "Bolivares Fuertes"
|
737
|
+
symbol: Bs
|
738
|
+
unicode_hex:
|
739
|
+
- 1083
|
740
|
+
- 1074
|
741
|
+
VND:
|
742
|
+
code: VND
|
743
|
+
name: Dong
|
744
|
+
symbol: ₫
|
745
|
+
unicode_hex: 8363
|
746
|
+
XAF:
|
747
|
+
code: XAF
|
748
|
+
name: "Communauté Financière Africaine Francs"
|
749
|
+
XCD:
|
750
|
+
code: XCD
|
751
|
+
name: "East Caribbean Dollars"
|
752
|
+
symbol: $
|
753
|
+
unicode_hex: 36
|
754
|
+
XOF:
|
755
|
+
code: XOF
|
756
|
+
name: "Communauté Financière Africaine Francs"
|
757
|
+
XPF:
|
758
|
+
code: XPF
|
759
|
+
name: "Comptoirs Français du Pacifique Francs"
|
760
|
+
YER:
|
761
|
+
code: YER
|
762
|
+
name: Rials
|
763
|
+
symbol: ﷼
|
764
|
+
unicode_hex: 65020
|
765
|
+
ZAR:
|
766
|
+
code: ZAR
|
767
|
+
name: Rand
|
768
|
+
symbol: R
|
769
|
+
unicode_hex: 82
|
770
|
+
ZMK:
|
771
|
+
code: ZMK
|
772
|
+
name: Kwacha
|
773
|
+
ZWD:
|
774
|
+
code: ZWD
|
775
|
+
name: "Zimbabwe Dollars"
|
776
|
+
symbol: Z$
|
777
|
+
unicode_hex:
|
778
|
+
- 90
|
779
|
+
- 36
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Currency do
|
4
|
+
before(:all) do
|
5
|
+
@usd = Currency.from_code(:USD)
|
6
|
+
@gbp = Currency.from_code(:GBP)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should return code' do
|
10
|
+
@usd.code.should == 'USD'
|
11
|
+
@gbp.code.should == 'GBP'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return symbol' do
|
15
|
+
@usd.symbol.should == '$'
|
16
|
+
@gbp.symbol.should == '£'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return name' do
|
20
|
+
@usd.name.should == 'Dollars'
|
21
|
+
@gbp.name.should == 'Pounds'
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'from_code' do
|
25
|
+
it 'should return new Currency instance when passed iso4217 currency code' do
|
26
|
+
Currency.from_code('USD').should be_a(Currency)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return a currency with the same code' do
|
30
|
+
Currency.from_code('USD').code.should == 'USD'
|
31
|
+
Currency.from_code('GBP').code.should == 'GBP'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should accept symbol' do
|
35
|
+
Currency.from_code(:USD).code.should == 'USD'
|
36
|
+
Currency.from_code(:GBP).code.should == 'GBP'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should work with lower case' do
|
40
|
+
Currency.from_code('usd').code.should == 'USD'
|
41
|
+
Currency.from_code('gbp').code.should == 'GBP'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'exchange_rate' do
|
46
|
+
it 'should return a float' do
|
47
|
+
Currency.from_code('GBP').exchange_rate.should be_a(Float)
|
48
|
+
puts Currency.from_code('GBP').exchange_rate
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should have an exchange rate of 1.0 for the base currency' do
|
52
|
+
Currency.from_code(Currency.base_currency).exchange_rate.should == 1.0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Currency::ExchangeBank do
|
4
|
+
before :each do
|
5
|
+
@bank = Currency::ExchangeBank.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns the previously specified conversion rate" do
|
9
|
+
@bank.add_rate("USD", "EUR", 0.788332676)
|
10
|
+
@bank.add_rate("EUR", "YEN", 122.631477)
|
11
|
+
@bank.get_rate("USD", "EUR").should == 0.788332676
|
12
|
+
@bank.get_rate("EUR", "YEN").should == 122.631477
|
13
|
+
end
|
14
|
+
|
15
|
+
it "treats currency names case-insensitively" do
|
16
|
+
@bank.add_rate("usd", "eur", 1)
|
17
|
+
@bank.get_rate("USD", "EUR").should == 1
|
18
|
+
@bank.same_currency?("USD", "usd").should be_true
|
19
|
+
@bank.same_currency?("EUR", "usd").should be_false
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns nil if the conversion rate is unknown" do
|
23
|
+
@bank.get_rate("American Pesos", "EUR").should be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "exchanges money from one currency to another according to the specified conversion rates" do
|
27
|
+
@bank.add_rate("USD", "EUR", 0.5)
|
28
|
+
@bank.add_rate("EUR", "YEN", 10)
|
29
|
+
@bank.exchange(10_00, "USD", "EUR").should == 5_00
|
30
|
+
@bank.exchange(500_00, "EUR", "YEN").should == 5000_00
|
31
|
+
end
|
32
|
+
|
33
|
+
it "rounds the exchanged result down" do
|
34
|
+
@bank.add_rate("USD", "EUR", 0.788332676)
|
35
|
+
@bank.add_rate("EUR", "YEN", 122.631477)
|
36
|
+
@bank.exchange(10_00, "USD", "EUR").should == 788
|
37
|
+
@bank.exchange(500_00, "EUR", "YEN").should == 6131573
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should lookup exchange rate if one isn't set" do
|
41
|
+
block = lambda { @bank.exchange(10, "USD", "EUR") }
|
42
|
+
block.should_not raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises Money::UnknownRate upon conversion if the conversion rate is unknown" do
|
46
|
+
block = lambda { @bank.exchange(10, "USD", "BUTTON") }
|
47
|
+
block.should raise_error(Money::UnknownRate)
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: currencies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hexorx
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-18 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: "If you are tracking any kind of assets the currencies gem is for you. It contains every currency in the ISO 4217 standard and allows you to add your own as well. So if you decide to take sparkly buttons as a form of payment you can use currencies to display the shiny button unicode symbol \xE2\x98\xBC (disclaimer: \xE2\x98\xBC may not look like a shiny button to everyone.) when used with something like the money gem. Speaking of the money gem, currencies gives you an ExchangeBank that the money gem can use to convert from one currency to another. There are plans to have ExchangeRate provider plugin system. Right now the rates are either set manually or pulled from Yahoo Finance."
|
36
|
+
email: hexorx@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.markdown
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.markdown
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- lib/currencies.rb
|
52
|
+
- lib/currencies/currency.rb
|
53
|
+
- lib/currencies/exchange_bank.rb
|
54
|
+
- lib/currencies/extentions.rb
|
55
|
+
- lib/data/iso4217.yaml
|
56
|
+
- spec/currency_spec.rb
|
57
|
+
- spec/exchange_bank_spec.rb
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/hexorx/currencies
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --charset=UTF-8
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.5
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Simple gem for working with currencies. It is extracted from the countries gem and contains all the currency information in the ISO 4217 standard.
|
87
|
+
test_files:
|
88
|
+
- spec/currency_spec.rb
|
89
|
+
- spec/exchange_bank_spec.rb
|
90
|
+
- spec/spec_helper.rb
|