exchange 0.12.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -0
- data/README.rdoc +34 -6
- data/Rakefile +3 -30
- data/changelog.rdoc +6 -0
- data/exchange.gemspec +3 -6
- data/iso4217.yml +238 -81
- data/lib/exchange.rb +2 -1
- data/lib/exchange/base.rb +3 -2
- data/lib/exchange/cache.rb +1 -0
- data/lib/exchange/cache/base.rb +2 -1
- data/lib/exchange/cache/configuration.rb +2 -1
- data/lib/exchange/cache/file.rb +2 -1
- data/lib/exchange/cache/memcached.rb +2 -1
- data/lib/exchange/cache/memory.rb +2 -1
- data/lib/exchange/cache/no_cache.rb +2 -1
- data/lib/exchange/cache/rails.rb +2 -1
- data/lib/exchange/cache/redis.rb +2 -1
- data/lib/exchange/configurable.rb +3 -2
- data/lib/exchange/configuration.rb +8 -5
- data/lib/exchange/core_extensions.rb +2 -1
- data/lib/exchange/core_extensions/cachify.rb +2 -1
- data/lib/exchange/core_extensions/float/error_safe.rb +2 -1
- data/lib/exchange/core_extensions/numeric/conversability.rb +2 -1
- data/lib/exchange/external_api.rb +3 -1
- data/lib/exchange/external_api/base.rb +2 -1
- data/lib/exchange/external_api/call.rb +2 -1
- data/lib/exchange/external_api/configuration.rb +18 -3
- data/lib/exchange/external_api/ecb.rb +2 -1
- data/lib/exchange/external_api/json.rb +2 -1
- data/lib/exchange/external_api/open_exchange_rates.rb +2 -1
- data/lib/exchange/external_api/random.rb +31 -0
- data/lib/exchange/external_api/xavier_media.rb +2 -1
- data/lib/exchange/external_api/xml.rb +2 -1
- data/lib/exchange/gem_loader.rb +2 -1
- data/lib/exchange/helper.rb +2 -1
- data/lib/exchange/iso.rb +29 -13
- data/lib/exchange/money.rb +35 -9
- data/lib/exchange/typecasting.rb +2 -1
- data/spec/exchange/cache/base_spec.rb +2 -1
- data/spec/exchange/cache/configuration_spec.rb +4 -1
- data/spec/exchange/cache/file_spec.rb +2 -1
- data/spec/exchange/cache/memcached_spec.rb +2 -1
- data/spec/exchange/cache/memory_spec.rb +4 -2
- data/spec/exchange/cache/no_cache_spec.rb +2 -1
- data/spec/exchange/cache/rails_spec.rb +2 -1
- data/spec/exchange/cache/redis_spec.rb +2 -1
- data/spec/exchange/configuration_spec.rb +6 -2
- data/spec/exchange/core_extensions/array/cachify_spec.rb +2 -1
- data/spec/exchange/core_extensions/float/error_safe_spec.rb +2 -1
- data/spec/exchange/core_extensions/hash/cachify_spec.rb +2 -1
- data/spec/exchange/core_extensions/numeric/cachify_spec.rb +2 -1
- data/spec/exchange/core_extensions/numeric/conversability_spec.rb +2 -1
- data/spec/exchange/core_extensions/string/cachify_spec.rb +2 -1
- data/spec/exchange/core_extensions/symbol/cachify_spec.rb +2 -1
- data/spec/exchange/external_api/base_spec.rb +2 -1
- data/spec/exchange/external_api/call_spec.rb +2 -1
- data/spec/exchange/external_api/configuration_spec.rb +18 -2
- data/spec/exchange/external_api/ecb_spec.rb +2 -1
- data/spec/exchange/external_api/open_exchange_rates_spec.rb +2 -1
- data/spec/exchange/external_api/random_spec.rb +40 -0
- data/spec/exchange/external_api/xavier_media_spec.rb +2 -1
- data/spec/exchange/gem_loader_spec.rb +2 -1
- data/spec/exchange/helper_spec.rb +2 -1
- data/spec/exchange/iso_spec.rb +214 -189
- data/spec/exchange/money_spec.rb +65 -2
- data/spec/exchange/typecasting_spec.rb +2 -1
- data/spec/spec_helper.rb +3 -1
- metadata +10 -10
- data/benchmark/benchmark.rb +0 -50
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe "Exchange::ExternalAPI::XavierMedia" do
|
@@ -63,4 +64,4 @@ describe "Exchange::ExternalAPI::XavierMedia" do
|
|
63
64
|
subject.convert(70, :sek, :usd, :at => Time.gm(Time.now.year - 1,3,1)).round(2).should == 10.35
|
64
65
|
end
|
65
66
|
end
|
66
|
-
end
|
67
|
+
end
|
data/spec/exchange/iso_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
@@ -6,175 +6,171 @@ describe "Exchange::ISO" do
|
|
6
6
|
let(:subject) { Exchange::ISO }
|
7
7
|
describe "self.definitions" do
|
8
8
|
it "should be a hash of exactly the ISO standard definitions loaded from the yaml file" do
|
9
|
-
subject.definitions.should === {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
:zar => {:format=>"# ###.##", :minor_unit=>2, :currency=>"Rand", :symbol=>"R"},
|
175
|
-
:zmk => {:minor_unit=>2, :currency=>"Zambian Kwacha", :symbol=>nil},
|
176
|
-
:zwl => {:minor_unit=>2, :currency=>"Zimbabwe Dollar", :symbol=>nil}
|
177
|
-
}
|
9
|
+
subject.definitions.should === {
|
10
|
+
:nio=>{:minor_unit=>2, :currency=>"Cordoba Oro", :symbol=>"C$"},
|
11
|
+
:lak=>{:minor_unit=>2, :currency=>"Kip", :symbol=>"₭"},
|
12
|
+
:sar=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Saudi Riyal", :symbol=>"﷼"},
|
13
|
+
:nok=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Norwegian Krone", :symbol=>"kr"},
|
14
|
+
:usd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"US Dollar", :symbol=>"$"},
|
15
|
+
:rub=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Russian Ruble", :symbol=>"руб"},
|
16
|
+
:xcd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"East Caribbean Dollar", :symbol=>"$"},
|
17
|
+
:omr=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>3, :currency=>"Rial Omani", :symbol=>"﷼"},
|
18
|
+
:amd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Armenian Dram", :symbol=>nil},
|
19
|
+
:cdf=>{:minor_unit=>2, :currency=>"Congolese Franc", :symbol=>nil},
|
20
|
+
:kpw=>{:minor_unit=>2, :currency=>"North Korean Won", :symbol=>"₩"},
|
21
|
+
:cny=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Yuan Renminbi", :symbol=>"¥"},
|
22
|
+
:kes=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Kenyan Shilling", :symbol=>nil},
|
23
|
+
:khr=>{:minor_unit=>2, :currency=>"Riel", :symbol=>"៛"},
|
24
|
+
:pln=>{:separators=>{:major=>" ", :minor=>","}, :minor_unit=>2, :currency=>"Zloty", :symbol=>"zł"},
|
25
|
+
:mvr=>{:minor_unit=>2, :currency=>"Rufiyaa", :symbol=>nil},
|
26
|
+
:gtq=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Quetzal", :symbol=>"Q"},
|
27
|
+
:clp=>{:separators=>{:major=>"."}, :minor_unit=>0, :currency=>"Chilean Peso", :symbol=>"$"},
|
28
|
+
:inr=>{:separators=>{:major=>",", :minor=>"."}, :format=>"#,##,###.##", :minor_unit=>2, :currency=>"Indian Rupee", :symbol=>""},
|
29
|
+
:bzd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Belize Dollar", :symbol=>"BZ$"},
|
30
|
+
:myr=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Malaysian Ringgit", :symbol=>"RM"},
|
31
|
+
:hkd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Hong Kong Dollar", :symbol=>"$"},
|
32
|
+
:cop=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Colombian Peso", :symbol=>"$"},
|
33
|
+
:dkk=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Danish Krone", :symbol=>"kr"},
|
34
|
+
:sek=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Swedish Krona", :symbol=>"kr"},
|
35
|
+
:byr=>{:minor_unit=>0, :currency=>"Belarussian Ruble", :symbol=>"p."},
|
36
|
+
:lyd=>{:minor_unit=>3, :currency=>"Libyan Dinar", :symbol=>nil},
|
37
|
+
:ron=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"New Romanian Leu", :symbol=>"lei"},
|
38
|
+
:dzd=>{:minor_unit=>2, :currency=>"Algerian Dinar", :symbol=>nil}, :bif=>{:minor_unit=>0, :currency=>"Burundi Franc", :symbol=>nil},
|
39
|
+
:ars=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Argentine Peso", :symbol=>"$"},
|
40
|
+
:gip=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Gibraltar Pound", :symbol=>"£"},
|
41
|
+
:uyi=>{:minor_unit=>0, :currency=>"Uruguay Peso en Unidades Indexadas (URUIURUI)", :symbol=>nil},
|
42
|
+
:bob=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Boliviano", :symbol=>"$b"},
|
43
|
+
:ssp=>{:minor_unit=>2, :currency=>"South Sudanese Pound", :symbol=>nil},
|
44
|
+
:ngn=>{:minor_unit=>2, :currency=>"Naira", :symbol=>"₦"},
|
45
|
+
:pgk=>{:minor_unit=>2, :currency=>"Kina", :symbol=>nil},
|
46
|
+
:std=>{:minor_unit=>2, :currency=>"Dobra", :symbol=>nil},
|
47
|
+
:xof=>{:minor_unit=>0, :currency=>"CFA Franc BCEAO", :symbol=>nil},
|
48
|
+
:aed=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"UAE Dirham", :symbol=>nil},
|
49
|
+
:ern=>{:minor_unit=>2, :currency=>"Nakfa", :symbol=>nil}, :mwk=>{:minor_unit=>2, :currency=>"Kwacha", :symbol=>nil},
|
50
|
+
:cup=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Cuban Peso", :symbol=>"₱"},
|
51
|
+
:usn=>{:minor_unit=>2, :currency=>"US Dollar (Next day)", :symbol=>nil},
|
52
|
+
:gmd=>{:minor_unit=>2, :currency=>"Dalasi", :symbol=>nil},
|
53
|
+
:cve=>{:minor_unit=>2, :currency=>"Cape Verde Escudo", :symbol=>nil},
|
54
|
+
:tzs=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Tanzanian Shilling", :symbol=>nil},
|
55
|
+
:cou=>{:minor_unit=>2, :currency=>"Unidad de Valor Real", :symbol=>nil},
|
56
|
+
:btn=>{:minor_unit=>2, :currency=>"Ngultrum", :symbol=>nil},
|
57
|
+
:zwl=>{:minor_unit=>2, :currency=>"Zimbabwe Dollar", :symbol=>nil},
|
58
|
+
:ugx=>{:minor_unit=>2, :currency=>"Uganda Shilling", :symbol=>nil},
|
59
|
+
:syp=>{:minor_unit=>2, :currency=>"Syrian Pound", :symbol=>"£"},
|
60
|
+
:mad=>{:minor_unit=>2, :currency=>"Moroccan Dirham", :symbol=>nil},
|
61
|
+
:mnt=>{:minor_unit=>2, :currency=>"Tugrik", :symbol=>"₮"},
|
62
|
+
:lsl=>{:minor_unit=>2, :currency=>"Loti", :symbol=>nil},
|
63
|
+
:xaf=>{:minor_unit=>0, :currency=>"CFA Franc BEAC", :symbol=>nil},
|
64
|
+
:shp=>{:minor_unit=>2, :currency=>"Saint Helena Pound", :symbol=>"£"},
|
65
|
+
:htg=>{:minor_unit=>2, :currency=>"Gourde", :symbol=>nil},
|
66
|
+
:rsd=>{:minor_unit=>2, :currency=>"Serbian Dinar", :symbol=>"Дин."},
|
67
|
+
:mga=>{:minor_unit=>2, :currency=>"Malagasy Ariary", :symbol=>nil},
|
68
|
+
:top=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Pa’anga", :symbol=>nil},
|
69
|
+
:mzn=>{:minor_unit=>2, :currency=>"Mozambique Metical", :symbol=>"MT"},
|
70
|
+
:lvl=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Latvian Lats", :symbol=>"Ls"},
|
71
|
+
:fkp=>{:minor_unit=>2, :currency=>"Falkland Islands Pound", :symbol=>"£"},
|
72
|
+
:uss=>{:minor_unit=>2, :currency=>"US Dollar (Same day)", :symbol=>nil},
|
73
|
+
:bwp=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Pula", :symbol=>"P"},
|
74
|
+
:hnl=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Lempira", :symbol=>"L"},
|
75
|
+
:eur=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Euro", :symbol=>"€"},
|
76
|
+
:egp=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Egyptian Pound", :symbol=>"£"},
|
77
|
+
:chf=>{:separators=>{:major=>"'", :minor=>"."}, :minor_unit=>2, :currency=>"Swiss Franc"},
|
78
|
+
:ils=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"New Israeli Sheqel", :symbol=>"₪"},
|
79
|
+
:pyg=>{:minor_unit=>0, :currency=>"Guarani", :symbol=>"Gs"},
|
80
|
+
:lbp=>{:separators=>{:major=>" ", :minor=>"."}, :minor_unit=>2, :currency=>"Lebanese Pound", :symbol=>"£"},
|
81
|
+
:ang=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Netherlands Antillean Guilder", :symbol=>"ƒ"},
|
82
|
+
:kzt=>{:minor_unit=>2, :currency=>"Tenge", :symbol=>"лв"},
|
83
|
+
:gyd=>{:minor_unit=>2, :currency=>"Guyana Dollar", :symbol=>"$"},
|
84
|
+
:wst=>{:minor_unit=>2, :currency=>"Tala", :symbol=>nil},
|
85
|
+
:npr=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Nepalese Rupee", :symbol=>"₨"},
|
86
|
+
:kmf=>{:minor_unit=>0, :currency=>"Comoro Franc", :symbol=>nil},
|
87
|
+
:thb=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Baht", :symbol=>"฿"},
|
88
|
+
:irr=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Iranian Rial", :symbol=>"﷼"},
|
89
|
+
:srd=>{:minor_unit=>2, :currency=>"Surinam Dollar", :symbol=>"$"},
|
90
|
+
:jpy=>{:separators=>{:major=>","}, :minor_unit=>0, :currency=>"Yen", :symbol=>"¥"},
|
91
|
+
:brl=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Brazilian Real", :symbol=>"R$"},
|
92
|
+
:uyu=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Peso Uruguayo", :symbol=>"$U"},
|
93
|
+
:mop=>{:minor_unit=>2, :currency=>"Pataca", :symbol=>nil},
|
94
|
+
:bmd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Bermudian Dollar", :symbol=>"$"},
|
95
|
+
:szl=>{:separators=>{:major=>", ", :minor=>"."}, :minor_unit=>2, :currency=>"Lilangeni", :symbol=>nil},
|
96
|
+
:etb=>{:minor_unit=>2, :currency=>"Ethiopian Birr", :symbol=>nil},
|
97
|
+
:jod=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>3, :currency=>"Jordanian Dinar", :symbol=>nil},
|
98
|
+
:idr=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Rupiah", :symbol=>"Rp"},
|
99
|
+
:mdl=>{:minor_unit=>2, :currency=>"Moldovan Leu", :symbol=>nil},
|
100
|
+
:xpf=>{:minor_unit=>0, :currency=>"CFP Franc", :symbol=>nil},
|
101
|
+
:mro=>{:minor_unit=>2, :currency=>"Ouguiya", :symbol=>nil},
|
102
|
+
:yer=>{:minor_unit=>2, :currency=>"Yemeni Rial", :symbol=>"﷼"},
|
103
|
+
:bam=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Convertible Mark", :symbol=>"KM"},
|
104
|
+
:awg=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Aruban Florin", :symbol=>"ƒ"},
|
105
|
+
:nzd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"New Zealand Dollar", :symbol=>"$"},
|
106
|
+
:pen=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Nuevo Sol", :symbol=>"S/."},
|
107
|
+
:aoa=>{:minor_unit=>2, :currency=>"Kwanza", :symbol=>nil},
|
108
|
+
:kyd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Cayman Islands Dollar", :symbol=>"$"},
|
109
|
+
:sll=>{:minor_unit=>2, :currency=>"Leone", :symbol=>nil},
|
110
|
+
:try=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Turkish Lira", :symbol=>""},
|
111
|
+
:vef=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Bolivar Fuerte", :symbol=>"Bs"},
|
112
|
+
:isk=>{:format=>"#.###", :minor_unit=>0, :currency=>"Iceland Krona", :symbol=>"kr"},
|
113
|
+
:gnf=>{:minor_unit=>0, :currency=>"Guinea Franc", :symbol=>nil},
|
114
|
+
:bsd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Bahamian Dollar", :symbol=>"$"},
|
115
|
+
:djf=>{:minor_unit=>0, :currency=>"Djibouti Franc", :symbol=>nil},
|
116
|
+
:huf=>{:separators=>{:major=>".", :minor=>"."}, :minor_unit=>2, :currency=>"Forint", :symbol=>"Ft"},
|
117
|
+
:ltl=>{:separators=>{:major=>" ", :minor=>","}, :minor_unit=>2, :currency=>"Lithuanian Litas", :symbol=>"Lt"},
|
118
|
+
:mxn=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Mexican Peso", :symbol=>"$"},
|
119
|
+
:scr=>{:minor_unit=>2, :currency=>"Seychelles Rupee", :symbol=>"₨"},
|
120
|
+
:sgd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Singapore Dollar", :symbol=>"$"},
|
121
|
+
:lkr=>{:minor_unit=>2, :currency=>"Sri Lanka Rupee", :symbol=>"₨"},
|
122
|
+
:tjs=>{:minor_unit=>2, :currency=>"Somoni", :symbol=>nil},
|
123
|
+
:tnd=>{:minor_unit=>3, :currency=>"Tunisian Dinar", :symbol=>nil},
|
124
|
+
:dop=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Dominican Peso", :symbol=>"RD$"},
|
125
|
+
:fjd=>{:minor_unit=>2, :currency=>"Fiji Dollar", :symbol=>"$"},
|
126
|
+
:gel=>{:minor_unit=>2, :currency=>"Lari", :symbol=>nil}, :sdg=>{:minor_unit=>2, :currency=>"Sudanese Pound", :symbol=>nil},
|
127
|
+
:vuv=>{:separators=>{:major=>","}, :minor_unit=>0, :currency=>"Vatu", :symbol=>nil},
|
128
|
+
:bbd=>{:minor_unit=>2, :currency=>"Barbados Dollar", :symbol=>"$"},
|
129
|
+
:lrd=>{:minor_unit=>2, :currency=>"Liberian Dollar", :symbol=>"$"},
|
130
|
+
:krw=>{:separators=>{:major=>","}, :minor_unit=>0, :currency=>"Won", :symbol=>"₩"},
|
131
|
+
:mmk=>{:minor_unit=>2, :currency=>"Kyat", :symbol=>nil},
|
132
|
+
:mur=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Mauritius Rupee", :symbol=>"₨"},
|
133
|
+
:php=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Philippine Peso", :symbol=>"₱"},
|
134
|
+
:zar=>{:separators=>{:major=>" ", :minor=>"."}, :minor_unit=>2, :currency=>"Rand", :symbol=>"R"},
|
135
|
+
:kgs=>{:minor_unit=>2, :currency=>"Som", :symbol=>"лв"},
|
136
|
+
:gbp=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Pound Sterling", :symbol=>"£"},
|
137
|
+
:bgn=>{:minor_unit=>2, :currency=>"Bulgarian Lev", :symbol=>"лв"},
|
138
|
+
:iqd=>{:minor_unit=>3, :currency=>"Iraqi Dinar", :symbol=>nil},
|
139
|
+
:tmt=>{:minor_unit=>2, :currency=>"Turkmenistan New Manat", :symbol=>nil},
|
140
|
+
:uah=>{:separators=>{:major=>" ", :minor=>","}, :minor_unit=>2, :currency=>"Hryvnia", :symbol=>"₴"},
|
141
|
+
:vnd=>{:separators=>{:major=>"."}, :minor_unit=>0, :currency=>"Dong", :symbol=>"₫"},
|
142
|
+
:zmk=>{:minor_unit=>2, :currency=>"Zambian Kwacha", :symbol=>nil},
|
143
|
+
:bov=>{:minor_unit=>2, :currency=>"Mvdol", :symbol=>nil},
|
144
|
+
:hrk=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Croatian Kuna", :symbol=>"kn"},
|
145
|
+
:ttd=>{:minor_unit=>2, :currency=>"Trinidad and Tobago Dollar", :symbol=>"TT$"},
|
146
|
+
:bhd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>3, :currency=>"Bahraini Dinar", :symbol=>nil},
|
147
|
+
:clf=>{:minor_unit=>0, :currency=>"Unidades de fomento", :symbol=>nil},
|
148
|
+
:rwf=>{:minor_unit=>0, :currency=>"Rwanda Franc", :symbol=>nil},
|
149
|
+
:mkd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Denar", :symbol=>"ден"},
|
150
|
+
:aud=>{:separators=>{:major=>" ", :minor=>"."}, :minor_unit=>2, :currency=>"Australian Dollar", :symbol=>"$"},
|
151
|
+
:crc=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Costa Rican Colon", :symbol=>"₡"},
|
152
|
+
:pkr=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Pakistan Rupee", :symbol=>"₨"},
|
153
|
+
:twd=>{:minor_unit=>2, :currency=>"New Taiwan Dollar", :symbol=>"NT$"},
|
154
|
+
:uzs=>{:minor_unit=>2, :currency=>"Uzbekistan Sum", :symbol=>"лв"},
|
155
|
+
:czk=>{:separators=>{:major=>".", :minor=>","}, :minor_unit=>2, :currency=>"Czech Koruna", :symbol=>"Kč"},
|
156
|
+
:azn=>{:minor_unit=>2, :currency=>"Azerbaijanian Manat", :symbol=>"ман"},
|
157
|
+
:bdt=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Taka", :symbol=>nil},
|
158
|
+
:nad=>{:minor_unit=>2, :currency=>"Namibia Dollar", :symbol=>"$"},
|
159
|
+
:afn=>{:minor_unit=>2, :currency=>"Afghani", :symbol=>"؋"},
|
160
|
+
:mxv=>{:minor_unit=>2, :currency=>"Mexican Unidad de Inversion (UDI)", :symbol=>nil},
|
161
|
+
:cuc=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Peso Convertible", :symbol=>nil},
|
162
|
+
:pab=>{:minor_unit=>2, :currency=>"Balboa", :symbol=>"B/."},
|
163
|
+
:qar=>{:minor_unit=>2, :currency=>"Qatari Rial", :symbol=>"﷼"},
|
164
|
+
:sos=>{:minor_unit=>2, :currency=>"Somali Shilling", :symbol=>"S"},
|
165
|
+
:chw=>{:minor_unit=>2, :currency=>"WIR Franc", :symbol=>nil},
|
166
|
+
:cad=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Canadian Dollar", :symbol=>"$"},
|
167
|
+
:jmd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Jamaican Dollar", :symbol=>"J$"},
|
168
|
+
:bnd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"Brunei Dollar", :symbol=>"$"},
|
169
|
+
:all=>{:minor_unit=>2, :currency=>"Lek", :symbol=>"Lek"},
|
170
|
+
:svc=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>2, :currency=>"El Salvador Colon", :symbol=>"$"},
|
171
|
+
:sbd=>{:minor_unit=>2, :currency=>"Solomon Islands Dollar", :symbol=>"$"},
|
172
|
+
:ghs=>{:minor_unit=>2, :currency=>"Ghana Cedi", :symbol=>nil},
|
173
|
+
:kwd=>{:separators=>{:major=>",", :minor=>"."}, :minor_unit=>3, :currency=>"Kuwaiti Dinar", :symbol=>nil}}
|
178
174
|
end
|
179
175
|
end
|
180
176
|
describe "self.country_map" do
|
@@ -755,41 +751,70 @@ describe "Exchange::ISO" do
|
|
755
751
|
subject.round(BigDecimal.new("23.232524"), :sar).should == BigDecimal.new("23.23")
|
756
752
|
subject.round(BigDecimal.new("23.232524"), :clp).should == BigDecimal.new("23")
|
757
753
|
end
|
754
|
+
it "should round psychologically if asked" do
|
755
|
+
subject.round(BigDecimal.new("23.232524"), :tnd, nil, {:psych => true}).should == BigDecimal.new("22.999")
|
756
|
+
subject.round(BigDecimal.new("23.232524"), :sar, nil, {:psych => true}).should == BigDecimal.new("22.99")
|
757
|
+
subject.round(BigDecimal.new("23.232524"), :clp, nil, {:psych => true}).should == BigDecimal.new("19")
|
758
|
+
end
|
759
|
+
end
|
760
|
+
describe "self.ceil" do
|
761
|
+
it "should ceil a currency according to ISO 4217 Definitions" do
|
762
|
+
subject.ceil(BigDecimal.new("23.232524"), :tnd).should == BigDecimal.new("23.233")
|
763
|
+
subject.ceil(BigDecimal.new("23.232524"), :sar).should == BigDecimal.new("23.24")
|
764
|
+
subject.ceil(BigDecimal.new("23.232524"), :clp).should == BigDecimal.new("24")
|
765
|
+
end
|
766
|
+
it "should ceil psychologically if asked" do
|
767
|
+
subject.ceil(BigDecimal.new("23.232524"), :tnd, nil, {:psych => true}).should == BigDecimal.new("23.999")
|
768
|
+
subject.ceil(BigDecimal.new("23.232524"), :sar, nil, {:psych => true}).should == BigDecimal.new("23.99")
|
769
|
+
subject.ceil(BigDecimal.new("23.232524"), :clp, nil, {:psych => true}).should == BigDecimal.new("29")
|
770
|
+
end
|
771
|
+
end
|
772
|
+
describe "self.floor" do
|
773
|
+
it "should floor a currency according to ISO 4217 Definitions" do
|
774
|
+
subject.floor(BigDecimal.new("23.232524"), :tnd).should == BigDecimal.new("23.232")
|
775
|
+
subject.floor(BigDecimal.new("23.232524"), :sar).should == BigDecimal.new("23.23")
|
776
|
+
subject.floor(BigDecimal.new("23.232524"), :clp).should == BigDecimal.new("23")
|
777
|
+
end
|
778
|
+
it "should floor psychologically if asked" do
|
779
|
+
subject.floor(BigDecimal.new("23.232524"), :tnd, nil, {:psych => true}).should == BigDecimal.new("22.999")
|
780
|
+
subject.floor(BigDecimal.new("23.232524"), :sar, nil, {:psych => true}).should == BigDecimal.new("22.99")
|
781
|
+
subject.floor(BigDecimal.new("23.232524"), :clp, nil, {:psych => true}).should == BigDecimal.new("19")
|
782
|
+
end
|
758
783
|
end
|
759
784
|
describe "self.stringify" do
|
760
785
|
it "should stringify a currency according to ISO 4217 Definitions" do
|
761
|
-
subject.stringify(BigDecimal.new("
|
762
|
-
subject.stringify(BigDecimal.new("
|
763
|
-
subject.stringify(BigDecimal.new("
|
764
|
-
subject.stringify(BigDecimal.new("
|
765
|
-
subject.stringify(BigDecimal.new("
|
766
|
-
subject.stringify(BigDecimal.new("
|
786
|
+
subject.stringify(BigDecimal.new("23234234.232524"), :tnd).should == "TND 23234234.233"
|
787
|
+
subject.stringify(BigDecimal.new("23234234.232524"), :sar).should == "SAR 23,234,234.23"
|
788
|
+
subject.stringify(BigDecimal.new("2323434223.232524"), :clp).should == "CLP 2.323.434.223"
|
789
|
+
subject.stringify(BigDecimal.new("232344.2"), :tnd).should == "TND 232344.200"
|
790
|
+
subject.stringify(BigDecimal.new("233432434.4"), :sar).should == "SAR 233,432,434.40"
|
791
|
+
subject.stringify(BigDecimal.new("23234234.0"), :clp).should == "CLP 23.234.234"
|
767
792
|
end
|
768
793
|
context "amount only" do
|
769
794
|
it "should not render the currency" do
|
770
|
-
subject.stringify(BigDecimal.new("23.232524"), :tnd, :
|
771
|
-
subject.stringify(BigDecimal.new("
|
772
|
-
subject.stringify(BigDecimal.new("23.232524"), :clp, :
|
773
|
-
subject.stringify(BigDecimal.new("23.2"), :tnd, :
|
774
|
-
subject.stringify(BigDecimal.new("
|
775
|
-
subject.stringify(BigDecimal.new("23.0"), :clp, :
|
795
|
+
subject.stringify(BigDecimal.new("23.232524"), :tnd, :format => :amount).should == "23.233"
|
796
|
+
subject.stringify(BigDecimal.new("223423432343.232524"), :chf, :format => :amount).should == "223'423'432'343.23"
|
797
|
+
subject.stringify(BigDecimal.new("23.232524"), :clp, :format => :amount).should == "23"
|
798
|
+
subject.stringify(BigDecimal.new("23.2"), :tnd, :format => :amount).should == "23.200"
|
799
|
+
subject.stringify(BigDecimal.new("25645645663.4"), :sar, :format => :amount).should == "25,645,645,663.40"
|
800
|
+
subject.stringify(BigDecimal.new("23.0"), :clp, :format => :amount).should == "23"
|
776
801
|
end
|
777
802
|
end
|
778
803
|
context "symbol" do
|
779
804
|
context "with a symbol present" do
|
780
805
|
it "should render a symbol for the currency" do
|
781
|
-
subject.stringify(BigDecimal.new("23.232524"), :usd, :
|
782
|
-
subject.stringify(BigDecimal.new("23.232524"), :irr, :
|
783
|
-
subject.stringify(BigDecimal.new("
|
784
|
-
subject.stringify(BigDecimal.new("23.232524"), :eur, :
|
806
|
+
subject.stringify(BigDecimal.new("23.232524"), :usd, :format => :symbol).should == "$23.23"
|
807
|
+
subject.stringify(BigDecimal.new("23.232524"), :irr, :format => :symbol).should == "﷼23.23"
|
808
|
+
subject.stringify(BigDecimal.new("345543453453.232524"), :gbp, :format => :symbol).should == "£345,543,453,453.23"
|
809
|
+
subject.stringify(BigDecimal.new("23.232524"), :eur, :format => :symbol).should == "€23.23"
|
785
810
|
end
|
786
811
|
end
|
787
812
|
context "without a symbol present" do
|
788
813
|
it "should render the currency abbreviation" do
|
789
|
-
subject.stringify(BigDecimal.new("
|
790
|
-
subject.stringify(BigDecimal.new("23.232524"), :etb, :
|
814
|
+
subject.stringify(BigDecimal.new("32741393.232524"), :chf, :format => :symbol).should == "CHF 32'741'393.23"
|
815
|
+
subject.stringify(BigDecimal.new("23.232524"), :etb, :format => :symbol).should == "ETB 23.23"
|
791
816
|
end
|
792
817
|
end
|
793
818
|
end
|
794
819
|
end
|
795
|
-
end
|
820
|
+
end
|