money-open-exchange-rates 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -0
- data/lib/money/bank/open_exchange_rates_bank.rb +2 -1
- data/test/latest.json +159 -121
- data/test/open_exchange_rates_bank_test.rb +4 -1
- metadata +10 -10
data/README.markdown
CHANGED
@@ -9,7 +9,7 @@ class Money
|
|
9
9
|
|
10
10
|
class OpenExchangeRatesBank < Money::Bank::VariableExchange
|
11
11
|
|
12
|
-
OER_URL = 'http://openexchangerates.org/latest.
|
12
|
+
OER_URL = 'http://openexchangerates.org/latest.json'
|
13
13
|
|
14
14
|
attr_accessor :cache
|
15
15
|
attr_reader :doc, :oer_rates, :rates_source
|
@@ -18,6 +18,7 @@ class Money
|
|
18
18
|
exchange_rates.each do |exchange_rate|
|
19
19
|
rate = exchange_rate.last
|
20
20
|
currency = exchange_rate.first
|
21
|
+
next unless Money::Currency.find(currency)
|
21
22
|
set_rate('USD', currency, rate)
|
22
23
|
end
|
23
24
|
end
|
data/test/latest.json
CHANGED
@@ -1,129 +1,167 @@
|
|
1
1
|
{
|
2
2
|
"disclaimer": "This data is collected from various providers and provided free of charge for informational purposes only, with no guarantee whatsoever of accuracy, validity, availability or fitness for any purpose; use at your own risk. Other than that - have fun, and please share/watch/fork if you think data like this should be free!",
|
3
3
|
"license": "all code open-source under GPL v3 [http://www.opensource.org/licenses/GPL-3.0]. all data made available by various providers; copyright may apply; not for resale; no warranties given.",
|
4
|
-
"timestamp":
|
4
|
+
"timestamp": 1323614876,
|
5
5
|
"base": "USD",
|
6
6
|
"rates": {
|
7
|
-
"AED": 3.
|
8
|
-
"
|
9
|
-
"
|
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
|
-
"
|
7
|
+
"AED": 3.6733,
|
8
|
+
"AFN": 43,
|
9
|
+
"ALL": 104.019997,
|
10
|
+
"AMD": 383.119995,
|
11
|
+
"ANG": 1.79,
|
12
|
+
"AOA": 94.699997,
|
13
|
+
"ARS": 4.271,
|
14
|
+
"AUD": 0.978522,
|
15
|
+
"AWG": 1.7898,
|
16
|
+
"AZN": 0.7864,
|
17
|
+
"BAM": 1.46415,
|
18
|
+
"BBD": 2,
|
19
|
+
"BDT": 77.330002,
|
20
|
+
"BGN": 1.4663,
|
21
|
+
"BHD": 0.37705,
|
22
|
+
"BIF": 1308,
|
23
|
+
"BMD": 1,
|
24
|
+
"BND": 1.293,
|
25
|
+
"BOB": 6.91,
|
26
|
+
"BRL": 1.8059,
|
27
|
+
"BSD": 1,
|
28
|
+
"BTN": 52.035,
|
29
|
+
"BWP": 7.4516,
|
30
|
+
"BYR": 8675,
|
31
|
+
"BZD": 1.9855,
|
32
|
+
"CAD": 1.016,
|
33
|
+
"CDF": 895.183472,
|
34
|
+
"CHF": 0.92295,
|
35
|
+
"CLF": 0.02292,
|
36
|
+
"CLP": 510.149994,
|
37
|
+
"CNY": 6.337,
|
38
|
+
"COP": 1925.599976,
|
39
|
+
"CRC": 502.600006,
|
40
|
+
"CUP": 1,
|
41
|
+
"CVE": 82.449997,
|
42
|
+
"CZK": 19.006001,
|
43
|
+
"DJF": 178.449997,
|
44
|
+
"DKK": 5.5579,
|
45
|
+
"DOP": 38.549999,
|
46
|
+
"DZD": 74.550003,
|
47
|
+
"EGP": 6.0226,
|
48
|
+
"ETB": 17.272449,
|
49
|
+
"EUR": 0.747021,
|
50
|
+
"FJD": 1.8484,
|
51
|
+
"FKP": 0.6384,
|
52
|
+
"GBP": 0.638142,
|
53
|
+
"GEL": 1.65485,
|
54
|
+
"GHS": 1.6455,
|
55
|
+
"GIP": 0.63845,
|
56
|
+
"GMD": 29.030001,
|
57
|
+
"GNF": 7195,
|
58
|
+
"GTQ": 7.7795,
|
59
|
+
"GYD": 206.199997,
|
60
|
+
"HKD": 7.7821,
|
61
|
+
"HNL": 18.92,
|
62
|
+
"HRK": 5.61,
|
63
|
+
"HTG": 40.349998,
|
64
|
+
"HUF": 225.639999,
|
65
|
+
"IDR": 9053,
|
66
|
+
"IEP": 0.588339,
|
67
|
+
"ILS": 3.76165,
|
68
|
+
"INR": 51.889999,
|
69
|
+
"IQD": 1168.75,
|
70
|
+
"IRR": 10888,
|
71
|
+
"ISK": 118.900002,
|
72
|
+
"JMD": 86.489998,
|
73
|
+
"JOD": 0.7105,
|
74
|
+
"JPY": 77.629997,
|
75
|
+
"KES": 89.449997,
|
76
|
+
"KGS": 46.609402,
|
77
|
+
"KHR": 4030.300049,
|
78
|
+
"KMF": 367.524109,
|
79
|
+
"KPW": 900,
|
80
|
+
"KRW": 1145.400024,
|
81
|
+
"KWD": 0.27705,
|
82
|
+
"KZT": 147.820007,
|
83
|
+
"LAK": 7995.799805,
|
84
|
+
"LBP": 1505,
|
85
|
+
"LKR": 113.885002,
|
86
|
+
"LRD": 72.5,
|
87
|
+
"LSL": 8.09,
|
88
|
+
"LTL": 2.5821,
|
89
|
+
"LVL": 0.5218,
|
90
|
+
"LYD": 1.2416,
|
91
|
+
"MAD": 8.3563,
|
92
|
+
"MDL": 11.7,
|
93
|
+
"MGA": 2095,
|
94
|
+
"MKD": 46.185001,
|
95
|
+
"MMK": 6.51,
|
96
|
+
"MNT": 1352.5,
|
97
|
+
"MOP": 8.01585,
|
98
|
+
"MRO": 288,
|
99
|
+
"MUR": 29.18,
|
100
|
+
"MVR": 15.31,
|
101
|
+
"MWK": 164.649994,
|
102
|
+
"MXN": 13.5745,
|
103
|
+
"MYR": 3.1525,
|
104
|
+
"MZN": 27.558001,
|
105
|
+
"NAD": 8.119,
|
106
|
+
"NGN": 161.75,
|
107
|
+
"NIO": 22.915001,
|
108
|
+
"NOK": 5.7476,
|
109
|
+
"NPR": 82.300003,
|
110
|
+
"NZD": 1.289325,
|
111
|
+
"OMR": 0.38465,
|
112
|
+
"PAB": 1,
|
113
|
+
"PEN": 2.697,
|
114
|
+
"PGK": 2.1277,
|
115
|
+
"PHP": 43.470001,
|
116
|
+
"PKR": 89.019997,
|
117
|
+
"PLN": 3.3702,
|
118
|
+
"PYG": 4435,
|
119
|
+
"QAR": 3.6416,
|
120
|
+
"RON": 3.2461,
|
121
|
+
"RSD": 77.095497,
|
122
|
+
"RUB": 31.4657,
|
123
|
+
"RWF": 602.814758,
|
124
|
+
"SAR": 3.7504,
|
125
|
+
"SBD": 7.362893,
|
126
|
+
"SCR": 13.1239,
|
127
|
+
"SDG": 2.6785,
|
128
|
+
"SEK": 6.7308,
|
129
|
+
"SGD": 1.2925,
|
130
|
+
"SHP": 0.63845,
|
131
|
+
"SLL": 4378.5,
|
132
|
+
"SOS": 1627,
|
133
|
+
"SRD": 3.275,
|
134
|
+
"STD": 18411.5,
|
135
|
+
"SVC": 8.7475,
|
136
|
+
"SYP": 54.150002,
|
137
|
+
"SZL": 8.091,
|
138
|
+
"THB": 30.91,
|
139
|
+
"TJS": 4.7587,
|
140
|
+
"TMT": 2.8475,
|
141
|
+
"TND": 1.4776,
|
142
|
+
"TOP": 1.709527,
|
143
|
+
"TRY": 1.843,
|
144
|
+
"TTD": 6.38645,
|
145
|
+
"TWD": 30.212,
|
146
|
+
"TZS": 1612.5,
|
147
|
+
"UAH": 8,
|
148
|
+
"UGX": 2465,
|
117
149
|
"USD": 1,
|
118
|
-
"UYU": 19.
|
119
|
-
"
|
120
|
-
"
|
121
|
-
"
|
122
|
-
"
|
123
|
-
"
|
124
|
-
"
|
125
|
-
"
|
126
|
-
"
|
127
|
-
"
|
150
|
+
"UYU": 19.799999,
|
151
|
+
"UZS": 1783.849976,
|
152
|
+
"VEF": 4.2949,
|
153
|
+
"VND": 21005,
|
154
|
+
"VUV": 92.199997,
|
155
|
+
"WST": 2.372813,
|
156
|
+
"XAF": 490.032135,
|
157
|
+
"XCD": 2.7,
|
158
|
+
"XDR": 0.642197,
|
159
|
+
"XOF": 490.279999,
|
160
|
+
"XPF": 89.150002,
|
161
|
+
"YER": 213.054993,
|
162
|
+
"ZAR": 8.1,
|
163
|
+
"ZMK": 5089.5,
|
164
|
+
"ZWD": 378.700012,
|
165
|
+
"ZWL": 322.355011
|
128
166
|
}
|
129
167
|
}
|
@@ -14,6 +14,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
14
14
|
|
15
15
|
it "should update itself with exchange rates from OpenExchangeRates" do
|
16
16
|
@bank.oer_rates.keys.each do |currency|
|
17
|
+
next unless Money::Currency.find(currency)
|
17
18
|
@bank.get_rate("USD", currency).must_be :>, 0
|
18
19
|
end
|
19
20
|
end
|
@@ -21,6 +22,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
21
22
|
it "should return the correct oer rates using oer" do
|
22
23
|
@bank.update_rates
|
23
24
|
@bank.oer_rates.keys.each do |currency|
|
25
|
+
next unless Money::Currency.find(currency)
|
24
26
|
subunit = Money::Currency.wrap(currency).subunit_to_unit
|
25
27
|
@bank.exchange(100, "USD", currency).cents.must_equal (@bank.oer_rates[currency].to_f * subunit).round
|
26
28
|
end
|
@@ -29,11 +31,12 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
29
31
|
it "should return the correct oer rates using exchange_with" do
|
30
32
|
@bank.update_rates
|
31
33
|
@bank.oer_rates.keys.each do |currency|
|
34
|
+
next unless Money::Currency.find(currency)
|
32
35
|
subunit = Money::Currency.wrap(currency).subunit_to_unit
|
33
36
|
@bank.exchange_with(Money.new(100, "USD"), currency).cents.must_equal (@bank.oer_rates[currency].to_f * subunit).round
|
34
37
|
@bank.exchange_with(1.to_money("USD"), currency).cents.must_equal (@bank.oer_rates[currency].to_f * subunit).round
|
35
38
|
end
|
36
|
-
@bank.exchange_with(5000.to_money('JPY'), 'USD').cents.must_equal
|
39
|
+
@bank.exchange_with(5000.to_money('JPY'), 'USD').cents.must_equal 6441
|
37
40
|
end
|
38
41
|
|
39
42
|
# in response to #4
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-open-exchange-rates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &20494700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20494700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: money
|
27
|
-
requirement: &
|
27
|
+
requirement: &20492640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.7.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20492640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: minitest
|
38
|
-
requirement: &
|
38
|
+
requirement: &20491460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *20491460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rr
|
49
|
-
requirement: &
|
49
|
+
requirement: &20490720 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *20490720
|
58
58
|
description: A gem that calculates the exchange rate using published rates from open-exchange-rates.
|
59
59
|
Compatible with the money gem.
|
60
60
|
email: laurent@spkdev.net
|