money-open-exchange-rates 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +19 -0
- data/LICENSE +1 -1
- data/README.md +39 -13
- data/lib/money/bank/open_exchange_rates_bank.rb +62 -23
- data/lib/open_exchange_rates_bank/version.rb +1 -1
- data/test/integration/api.rb +3 -0
- data/test/open_exchange_rates_bank_test.rb +47 -19
- data/test/test_helper.rb +8 -3
- metadata +48 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 936862d5f32115f726c00579e6e248fd972d4d399d5e5866be087186cdfe2ade
|
4
|
+
data.tar.gz: 2ad7d8ff2636e13aa19284c23a1eb26da74dd7c5ddc5ad3bff9bbec91dc026ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf9beece860326d2fcdb8413cdbf8b878e799d3c2fb3ecb5d858342d5cfc2b9a052d6e5147abcde56f34529fdcc51cd02e2552253b0944a381f583af8dd59be
|
7
|
+
data.tar.gz: 234054fbc3bbb9e55db3f69976113eb4691806e98e0e7365074e730941932164bc41cc7cd47d5e540200dac8a65af3c9a42e880b3778f89b92fd8415189f9ca4
|
data/History.md
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
|
2
|
+
1.3.0 / 2019-01-20
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Update webmock to 3.5
|
6
|
+
* Update rubocop to 0.63
|
7
|
+
* Switch from rr to mocha/minitest
|
8
|
+
* Add prettyprint option
|
9
|
+
* README: add info about tests
|
10
|
+
* Remove deprecated secure_connection= option
|
11
|
+
* Merge pull request #54 from @LinkUpStudioUA / symbols-doc-link-fix
|
12
|
+
* Fix link to filtering by symbols doc
|
13
|
+
* Fix bundler to <2 on travis (dropped support Ruby < 2.3)
|
14
|
+
* Fix bundler to 1.17.3 (2.0 dropped support Ruby < 2.3)
|
15
|
+
* Merge pull request #52 from @thejchap / feature/symbols
|
16
|
+
* add support for symbols query param
|
17
|
+
* Remove ruby 2.0/2.1 support and fix rubocop offenses
|
18
|
+
* Add minitest-focus gem
|
19
|
+
* Avoid redefine json_response method
|
20
|
+
|
2
21
|
v1.2.2 / 2018-03-31
|
3
22
|
===================
|
4
23
|
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2011-
|
3
|
+
Copyright (c) 2011-2019 Laurent Arnoud <laurent@spkdev.net>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -24,9 +24,9 @@ Check [api documentation](https://docs.openexchangerates.org/)
|
|
24
24
|
|
25
25
|
Add this line to your application's Gemfile:
|
26
26
|
|
27
|
-
|
27
|
+
``` ruby
|
28
28
|
gem 'money-open-exchange-rates'
|
29
|
-
|
29
|
+
```
|
30
30
|
|
31
31
|
And then execute:
|
32
32
|
|
@@ -42,7 +42,7 @@ gem install money-open-exchange-rates
|
|
42
42
|
|
43
43
|
## Usage
|
44
44
|
|
45
|
-
|
45
|
+
``` ruby
|
46
46
|
require 'money/bank/open_exchange_rates_bank'
|
47
47
|
|
48
48
|
# Memory store per default; for others just pass as argument a class like
|
@@ -81,6 +81,11 @@ oxr.source = 'USD'
|
|
81
81
|
# see: https://docs.openexchangerates.org/docs/alternative-currencies
|
82
82
|
oxr.show_alternative = true
|
83
83
|
|
84
|
+
# (optional)
|
85
|
+
# Minified Response ('prettyprint')
|
86
|
+
# see https://docs.openexchangerates.org/docs/prettyprint
|
87
|
+
oxr.prettyprint = false
|
88
|
+
|
84
89
|
# (optional)
|
85
90
|
# Refresh rates, store in cache and update rates
|
86
91
|
# Should be used on crontab/worker/scheduler `Money.default_bank.refresh_rates`
|
@@ -98,14 +103,14 @@ oxr.force_refresh_rate_on_expire = true
|
|
98
103
|
Money.default_bank = oxr
|
99
104
|
|
100
105
|
Money.default_bank.get_rate('USD', 'CAD')
|
101
|
-
|
106
|
+
```
|
102
107
|
|
103
108
|
## Cache
|
104
109
|
|
105
110
|
You can also provide a `Proc` as a cache to provide your own caching mechanism
|
106
111
|
perhaps with Redis or just a thread safe `Hash` (global). For example:
|
107
112
|
|
108
|
-
|
113
|
+
``` ruby
|
109
114
|
oxr.cache = Proc.new do |v|
|
110
115
|
key = 'money:exchange_rates'
|
111
116
|
if v
|
@@ -114,12 +119,12 @@ oxr.cache = Proc.new do |v|
|
|
114
119
|
Thread.current[key]
|
115
120
|
end
|
116
121
|
end
|
117
|
-
|
122
|
+
```
|
118
123
|
|
119
124
|
With `Rails` cache example:
|
120
125
|
|
121
|
-
|
122
|
-
OXR_CACHE_KEY =
|
126
|
+
``` ruby
|
127
|
+
OXR_CACHE_KEY = "#{Rails.env}:money:exchange_rates".freeze
|
123
128
|
oxr.ttl_in_seconds = 86400
|
124
129
|
oxr.cache = Proc.new do |text|
|
125
130
|
if text
|
@@ -128,7 +133,7 @@ oxr.cache = Proc.new do |text|
|
|
128
133
|
Rails.cache.read(OXR_CACHE_KEY)
|
129
134
|
end
|
130
135
|
end
|
131
|
-
|
136
|
+
```
|
132
137
|
|
133
138
|
To update the cache call `Money.default_bank.refresh_rates` on
|
134
139
|
crontab/worker/scheduler. This have to be done this way because the fetch can
|
@@ -136,10 +141,10 @@ take some time (HTTP call) and can fail.
|
|
136
141
|
|
137
142
|
## Full example configuration initializer with Rails and cache
|
138
143
|
|
139
|
-
|
144
|
+
``` ruby
|
140
145
|
require 'money/bank/open_exchange_rates_bank'
|
141
146
|
|
142
|
-
OXR_CACHE_KEY =
|
147
|
+
OXR_CACHE_KEY = "#{Rails.env}:money:exchange_rates".freeze
|
143
148
|
# ExchangeRate is an ActiveRecord model
|
144
149
|
# more info at https://github.com/RubyMoney/money#exchange-rate-stores
|
145
150
|
oxr = Money::Bank::OpenExchangeRatesBank.new(ExchangeRate)
|
@@ -156,10 +161,31 @@ oxr.cache = Proc.new do |text|
|
|
156
161
|
end
|
157
162
|
oxr.app_id = ENV['OXR_API_KEY']
|
158
163
|
oxr.show_alternative = true
|
164
|
+
oxr.prettyprint = false
|
159
165
|
oxr.update_rates
|
160
166
|
|
161
167
|
Money.default_bank = oxr
|
162
|
-
|
168
|
+
```
|
169
|
+
|
170
|
+
### Tests
|
171
|
+
|
172
|
+
To avoid to hit the API we can use the cache option with a saved file like this:
|
173
|
+
|
174
|
+
``` ruby
|
175
|
+
OXR_CACHE_KEY = "#{Rails.env}:money:exchange_rates".freeze
|
176
|
+
if Rails.env.test?
|
177
|
+
oxr.cache = Rails.root.join("test/fixtures/currency-rates.json").to_s
|
178
|
+
else
|
179
|
+
oxr.ttl_in_seconds = 5.minutes.to_i
|
180
|
+
oxr.cache = Proc.new do |text|
|
181
|
+
if text
|
182
|
+
Rails.cache.write(OXR_CACHE_KEY, text)
|
183
|
+
else
|
184
|
+
Rails.cache.read(OXR_CACHE_KEY)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
```
|
163
189
|
|
164
190
|
## Pair rates
|
165
191
|
|
@@ -187,7 +213,7 @@ See [GitHub](https://github.com/spk/money-open-exchange-rates/graphs/contributor
|
|
187
213
|
|
188
214
|
The MIT License
|
189
215
|
|
190
|
-
Copyright © 2011-
|
216
|
+
Copyright © 2011-2019 Laurent Arnoud <laurent@spkdev.net>
|
191
217
|
|
192
218
|
---
|
193
219
|
[![Build](https://img.shields.io/travis-ci/spk/money-open-exchange-rates.svg)](https://travis-ci.org/spk/money-open-exchange-rates)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'net/http'
|
3
4
|
require 'uri'
|
4
|
-
require 'open-uri'
|
5
5
|
require 'money'
|
6
6
|
require 'json'
|
7
|
-
require File.expand_path('
|
7
|
+
require File.expand_path('../../open_exchange_rates_bank/version', __dir__)
|
8
8
|
|
9
9
|
# Money gem class
|
10
10
|
# rubocop:disable ClassLength
|
@@ -31,12 +31,6 @@ class Money
|
|
31
31
|
RATES_KEY = 'rates'.freeze
|
32
32
|
TIMESTAMP_KEY = 'timestamp'.freeze
|
33
33
|
|
34
|
-
# @deprecated secure_connection is deprecated and has no effect
|
35
|
-
def secure_connection=(*)
|
36
|
-
warn 'secure_connection is deprecated and has no effect'
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
|
40
34
|
# As of the end of August 2012 all requests to the Open Exchange Rates
|
41
35
|
# API must have a valid app_id
|
42
36
|
# see https://docs.openexchangerates.org/docs/authentication
|
@@ -103,6 +97,24 @@ class Money
|
|
103
97
|
# @return [Boolean] Setted show alternative
|
104
98
|
attr_writer :show_alternative
|
105
99
|
|
100
|
+
# Filter response to a list of symbols
|
101
|
+
# see https://docs.openexchangerates.org/docs/get-specific-currencies
|
102
|
+
# @example
|
103
|
+
# oxr.symbols = [:usd, :cad]
|
104
|
+
#
|
105
|
+
# @param [Array] list of symbols
|
106
|
+
# @return [Array] Setted list of symbols
|
107
|
+
attr_writer :symbols
|
108
|
+
|
109
|
+
# Minified Response ('prettyprint')
|
110
|
+
# see https://docs.openexchangerates.org/docs/prettyprint
|
111
|
+
# @example
|
112
|
+
# oxr.prettyprint = false
|
113
|
+
#
|
114
|
+
# @param [Boolean] Set to false to receive minified (default: true)
|
115
|
+
# @return [Boolean]
|
116
|
+
attr_writer :prettyprint
|
117
|
+
|
106
118
|
# Set current rates timestamp
|
107
119
|
#
|
108
120
|
# @return [Time]
|
@@ -129,7 +141,7 @@ class Money
|
|
129
141
|
def ttl_in_seconds=(value)
|
130
142
|
@ttl_in_seconds = value
|
131
143
|
refresh_rates_expiration if ttl_in_seconds
|
132
|
-
|
144
|
+
ttl_in_seconds
|
133
145
|
end
|
134
146
|
|
135
147
|
# Set the base currency for all rates. By default, USD is used.
|
@@ -143,9 +155,12 @@ class Money
|
|
143
155
|
#
|
144
156
|
# @return [String] chosen base currency
|
145
157
|
def source=(value)
|
146
|
-
|
147
|
-
|
148
|
-
|
158
|
+
scurrency = Money::Currency.find(value.to_s)
|
159
|
+
@source = if scurrency
|
160
|
+
scurrency.iso_code
|
161
|
+
else
|
162
|
+
OE_SOURCE
|
163
|
+
end
|
149
164
|
end
|
150
165
|
|
151
166
|
# Get the base currency for all rates. By default, USD is used.
|
@@ -163,6 +178,7 @@ class Money
|
|
163
178
|
rate = exchange_rate.last
|
164
179
|
currency = exchange_rate.first
|
165
180
|
next unless Money::Currency.find(currency)
|
181
|
+
|
166
182
|
set_rate(source, currency, rate)
|
167
183
|
set_rate(currency, source, 1.0 / rate)
|
168
184
|
end
|
@@ -200,6 +216,7 @@ class Money
|
|
200
216
|
def expire_rates
|
201
217
|
return unless ttl_in_seconds
|
202
218
|
return if rates_expiration > Time.now
|
219
|
+
|
203
220
|
refresh_rates if force_refresh_rate_on_expire
|
204
221
|
update_rates
|
205
222
|
refresh_rates_expiration
|
@@ -212,18 +229,36 @@ class Money
|
|
212
229
|
@show_alternative ||= false
|
213
230
|
end
|
214
231
|
|
232
|
+
# Get prettyprint option
|
233
|
+
#
|
234
|
+
# @return [Boolean]
|
235
|
+
def prettyprint
|
236
|
+
return true unless defined? @prettyprint
|
237
|
+
return true if @prettyprint.nil?
|
238
|
+
|
239
|
+
@prettyprint
|
240
|
+
end
|
241
|
+
|
242
|
+
# Get symbols
|
243
|
+
#
|
244
|
+
# @return [Array] list of symbols to filter by
|
245
|
+
def symbols
|
246
|
+
@symbols ||= nil
|
247
|
+
end
|
248
|
+
|
215
249
|
# Source url of openexchangerates
|
216
250
|
# defined with app_id
|
217
251
|
#
|
218
252
|
# @return [String] URL
|
219
253
|
def source_url
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
"&
|
254
|
+
str = "#{oer_url}?app_id=#{app_id}"
|
255
|
+
str = "#{str}&base=#{source}" unless source == OE_SOURCE
|
256
|
+
str = "#{str}&show_alternative=#{show_alternative}"
|
257
|
+
str = "#{str}&prettyprint=#{prettyprint}"
|
258
|
+
if symbols && symbols.is_a?(Array)
|
259
|
+
str = "#{str}&symbols=#{symbols.join(',')}"
|
226
260
|
end
|
261
|
+
str
|
227
262
|
end
|
228
263
|
|
229
264
|
protected
|
@@ -275,7 +310,7 @@ class Money
|
|
275
310
|
if cache.is_a?(Proc)
|
276
311
|
cache.call(text)
|
277
312
|
elsif cache.is_a?(String)
|
278
|
-
open(cache, 'w') do |f|
|
313
|
+
File.open(cache, 'w') do |f|
|
279
314
|
f.write(text)
|
280
315
|
end
|
281
316
|
end
|
@@ -288,7 +323,7 @@ class Money
|
|
288
323
|
result = if cache.is_a?(Proc)
|
289
324
|
cache.call(nil)
|
290
325
|
elsif cache.is_a?(String) && File.exist?(cache)
|
291
|
-
open(cache).read
|
326
|
+
File.open(cache).read
|
292
327
|
end
|
293
328
|
result if valid_rates?(result)
|
294
329
|
end
|
@@ -296,8 +331,8 @@ class Money
|
|
296
331
|
# Read API
|
297
332
|
#
|
298
333
|
# @return [String]
|
299
|
-
def
|
300
|
-
|
334
|
+
def api_response
|
335
|
+
Net::HTTP.get(URI(source_url))
|
301
336
|
end
|
302
337
|
|
303
338
|
# Read from url
|
@@ -305,7 +340,8 @@ class Money
|
|
305
340
|
# @return [String] JSON content
|
306
341
|
def read_from_url
|
307
342
|
raise NoAppId if app_id.nil? || app_id.empty?
|
308
|
-
|
343
|
+
|
344
|
+
@json_response = api_response
|
309
345
|
save_cache if cache
|
310
346
|
@json_response
|
311
347
|
end
|
@@ -319,6 +355,7 @@ class Money
|
|
319
355
|
# @return [Boolean] valid or not
|
320
356
|
def valid_rates?(text)
|
321
357
|
return false unless text
|
358
|
+
|
322
359
|
parsed = JSON.parse(text)
|
323
360
|
parsed && parsed.key?(RATES_KEY) && parsed.key?(TIMESTAMP_KEY)
|
324
361
|
rescue JSON::ParserError
|
@@ -371,6 +408,7 @@ class Money
|
|
371
408
|
to_base_rate = get_rate_or_calc_inverse(source, to_currency, opts)
|
372
409
|
return unless to_base_rate
|
373
410
|
return unless from_base_rate
|
411
|
+
|
374
412
|
rate = BigDecimal(to_base_rate.to_s) / from_base_rate
|
375
413
|
add_rate(from_currency, to_currency, rate)
|
376
414
|
rate
|
@@ -378,3 +416,4 @@ class Money
|
|
378
416
|
end
|
379
417
|
end
|
380
418
|
end
|
419
|
+
# rubocop:enable ClassLength
|
data/test/integration/api.rb
CHANGED
@@ -29,6 +29,9 @@ begin
|
|
29
29
|
puts 'Money to_currency', cad_rate
|
30
30
|
# rubocop:disable Style/AndOr
|
31
31
|
json_to_currency == cad_rate or raise ERROR_MSG
|
32
|
+
# rubocop:enable Style/AndOr
|
33
|
+
# rubocop:disable Style/RescueStandardError
|
32
34
|
rescue
|
35
|
+
# rubocop:enable Style/RescueStandardError
|
33
36
|
raise ERROR_MSG
|
34
37
|
end
|
@@ -94,6 +94,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
94
94
|
it 'should update itself with exchange rates from OpenExchangeRates' do
|
95
95
|
subject.oer_rates.keys.each do |currency|
|
96
96
|
next unless Money::Currency.find(currency)
|
97
|
+
|
97
98
|
subject.get_rate('USD', currency).must_be :>, 0
|
98
99
|
end
|
99
100
|
end
|
@@ -152,7 +153,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
152
153
|
end
|
153
154
|
|
154
155
|
it 'should get from url' do
|
155
|
-
|
156
|
+
subject.expects(:save_cache).never
|
156
157
|
subject.update_rates
|
157
158
|
subject.oer_rates.wont_be_empty
|
158
159
|
end
|
@@ -162,8 +163,11 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
162
163
|
before do
|
163
164
|
subject.app_id = TEST_APP_ID
|
164
165
|
end
|
166
|
+
let(:default_options) do
|
167
|
+
'&show_alternative=false&prettyprint=true'
|
168
|
+
end
|
165
169
|
let(:source_url) do
|
166
|
-
"#{oer_url}#{subject.date}?app_id=#{TEST_APP_ID}
|
170
|
+
"#{oer_url}#{subject.date}?app_id=#{TEST_APP_ID}#{default_options}"
|
167
171
|
end
|
168
172
|
|
169
173
|
describe 'historical' do
|
@@ -173,7 +177,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
173
177
|
|
174
178
|
let(:historical_url) do
|
175
179
|
"#{oer_historical_url}#{subject.date}.json?app_id=#{TEST_APP_ID}" \
|
176
|
-
|
180
|
+
"#{default_options}"
|
177
181
|
end
|
178
182
|
|
179
183
|
it 'should use the secure https url' do
|
@@ -190,15 +194,6 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
190
194
|
subject.source_url.must_include '/api/latest.json'
|
191
195
|
end
|
192
196
|
end
|
193
|
-
|
194
|
-
describe 'secure_connection=' do
|
195
|
-
it 'do nothing' do
|
196
|
-
_out, err = capture_io do
|
197
|
-
subject.secure_connection = false
|
198
|
-
end
|
199
|
-
err.must_include 'deprecated'
|
200
|
-
end
|
201
|
-
end
|
202
197
|
end
|
203
198
|
|
204
199
|
describe 'no valid file for cache' do
|
@@ -232,7 +227,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
232
227
|
|
233
228
|
it 'should save from url and get from cache' do
|
234
229
|
@global_rates.wont_be_empty
|
235
|
-
|
230
|
+
subject.expects(:source_url).never
|
236
231
|
subject.update_rates
|
237
232
|
subject.oer_rates.wont_be_empty
|
238
233
|
end
|
@@ -242,7 +237,7 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
242
237
|
before do
|
243
238
|
subject.app_id = TEST_APP_ID
|
244
239
|
subject.cache = temp_cache_path
|
245
|
-
|
240
|
+
subject.stubs(:api_response).returns File.read(oer_latest_path)
|
246
241
|
subject.update_rates
|
247
242
|
end
|
248
243
|
|
@@ -253,28 +248,30 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
253
248
|
it 'should allow update after save' do
|
254
249
|
begin
|
255
250
|
subject.refresh_rates
|
251
|
+
# rubocop:disable Style/RescueStandardError
|
256
252
|
rescue
|
253
|
+
# rubocop:enable Style/RescueStandardError
|
257
254
|
assert false, 'Should allow updating after saving'
|
258
255
|
end
|
259
256
|
end
|
260
257
|
|
261
258
|
it 'should not break an existing file if save fails to read' do
|
262
259
|
initial_size = File.read(temp_cache_path).size
|
263
|
-
|
260
|
+
subject.stubs(:api_response).returns ''
|
264
261
|
subject.refresh_rates
|
265
262
|
File.open(temp_cache_path).read.size.must_equal initial_size
|
266
263
|
end
|
267
264
|
|
268
265
|
it 'should not break an existing file if save returns json without rates' do
|
269
266
|
initial_size = File.read(temp_cache_path).size
|
270
|
-
|
267
|
+
subject.stubs(:api_response).returns '{"error": "An error"}'
|
271
268
|
subject.refresh_rates
|
272
269
|
File.open(temp_cache_path).read.size.must_equal initial_size
|
273
270
|
end
|
274
271
|
|
275
272
|
it 'should not break an existing file if save returns a invalid json' do
|
276
273
|
initial_size = File.read(temp_cache_path).size
|
277
|
-
|
274
|
+
subject.stubs(:api_response).returns '{invalid_json: "An error"}'
|
278
275
|
subject.refresh_rates
|
279
276
|
File.open(temp_cache_path).read.size.must_equal initial_size
|
280
277
|
end
|
@@ -364,8 +361,8 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
364
361
|
it 'should not update the rates' do
|
365
362
|
exp_time = subject.rates_expiration
|
366
363
|
Timecop.freeze(subject.rates_timestamp) do
|
367
|
-
|
368
|
-
|
364
|
+
subject.expects(:update_rates).never
|
365
|
+
subject.expects(:refresh_rates_expiration).never
|
369
366
|
subject.expire_rates
|
370
367
|
subject.rates_expiration.must_equal exp_time
|
371
368
|
end
|
@@ -408,6 +405,36 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
408
405
|
end
|
409
406
|
end
|
410
407
|
|
408
|
+
describe 'prettyprint' do
|
409
|
+
describe 'when no value given' do
|
410
|
+
before do
|
411
|
+
subject.prettyprint = nil
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'should return the default value' do
|
415
|
+
subject.prettyprint.must_equal true
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'should include prettyprint param as true' do
|
419
|
+
subject.source_url.must_include 'prettyprint=true'
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
describe 'when value is given' do
|
424
|
+
before do
|
425
|
+
subject.prettyprint = false
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'should return the value' do
|
429
|
+
subject.prettyprint.must_equal false
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'should include prettyprint param as false' do
|
433
|
+
subject.source_url.must_include 'prettyprint=false'
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
411
438
|
describe 'show alternative' do
|
412
439
|
describe 'when no value given' do
|
413
440
|
before do
|
@@ -438,3 +465,4 @@ describe Money::Bank::OpenExchangeRatesBank do
|
|
438
465
|
end
|
439
466
|
end
|
440
467
|
end
|
468
|
+
# rubocop:enable Metrics/BlockLength
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
begin
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
rescue LoadError
|
7
|
+
STDERR.puts 'coveralls not loaded'
|
8
|
+
end
|
5
9
|
|
6
10
|
require 'minitest/autorun'
|
7
|
-
require '
|
11
|
+
require 'minitest/focus'
|
12
|
+
require 'mocha/minitest'
|
8
13
|
require 'webmock/minitest'
|
9
14
|
require 'money/bank/open_exchange_rates_bank'
|
10
15
|
require 'monetize'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-open-exchange-rates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Arnoud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money
|
@@ -16,118 +16,132 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.12'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
26
|
+
version: '6.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3.1
|
34
|
-
- - "<"
|
31
|
+
- - "~>"
|
35
32
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
33
|
+
version: '5'
|
37
34
|
type: :development
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - "
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.3.1
|
44
|
-
- - "<"
|
38
|
+
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '5'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: minitest-focus
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '1'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
54
|
+
version: '1'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
56
|
+
name: mocha
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
61
|
+
version: '1.2'
|
68
62
|
type: :development
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
66
|
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
68
|
+
version: '1.2'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
70
|
+
name: monetize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.1
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.1
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
95
|
+
version: '12'
|
82
96
|
type: :development
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
102
|
+
version: '12'
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
104
|
+
name: rubocop
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
107
|
- - "~>"
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
109
|
+
version: '0.63'
|
96
110
|
type: :development
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
114
|
- - "~>"
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
116
|
+
version: '0.63'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
118
|
+
name: timecop
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
106
120
|
requirements:
|
107
121
|
- - "~>"
|
108
122
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
123
|
+
version: '0.9'
|
110
124
|
type: :development
|
111
125
|
prerelease: false
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
114
128
|
- - "~>"
|
115
129
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
130
|
+
version: '0.9'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
132
|
+
name: webmock
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
120
134
|
requirements:
|
121
135
|
- - "~>"
|
122
136
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
137
|
+
version: '3.5'
|
124
138
|
type: :development
|
125
139
|
prerelease: false
|
126
140
|
version_requirements: !ruby/object:Gem::Requirement
|
127
141
|
requirements:
|
128
142
|
- - "~>"
|
129
143
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
144
|
+
version: '3.5'
|
131
145
|
description: A gem that calculates the exchange rate using published rates from open-exchange-rates.
|
132
146
|
Compatible with the money gem.
|
133
147
|
email: laurent@spkdev.net
|
@@ -161,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
175
|
requirements:
|
162
176
|
- - ">="
|
163
177
|
- !ruby/object:Gem::Version
|
164
|
-
version: '2.
|
178
|
+
version: '2.2'
|
165
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
180
|
requirements:
|
167
181
|
- - ">="
|