eu_central_bank 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52d1fe9c87277a5ff6fdb243688949f5159686690a1bab6d8210ff0c643381da
4
- data.tar.gz: 8cc1b167c31e16ae87a4d89f62f298a5a05639f10611c5f5064bae72029818a4
3
+ metadata.gz: f8305b19d4e97311f612dff41676d21546bde2ee5bdf34ca0a11b329681f8cc1
4
+ data.tar.gz: 272e8a8bc25af1aca904743b5336865bb40725874a60161fe700c49ebff5e6e3
5
5
  SHA512:
6
- metadata.gz: a026554544da7e040565e6daa9cca1aad9e35be6d041511dcf16fb8d4cae90e6d02430a5940f21464675b95a70a4a52e1c7eb09dfffa9dabb213a79ab5bc3938
7
- data.tar.gz: c913cbcd6c2c0c8c247fba9eb582b57600ad75acf932b1fa5817bc81b260c2135193c876ed16d51a08d8150c2c464870b8a0a7f8f5ff48765bebd59a1879282f
6
+ metadata.gz: 43df545b3f015459fd1a10065e4989afe35ab57f0dcc34c989dcf008de739e82887223d1c4fe5d995203b612f33f2ec30c3e252f6d8585f7299484c59bd0117a
7
+ data.tar.gz: 511ed0225001148ee8cc84a3a0e9c7d7a6f31663399a762ee98ed5a254589e791320959ef44fde7950949c8cf1274a0310d31b6963f8256cda7352f53cbd08e4
@@ -36,7 +36,7 @@ class EuCentralBank < Money::Bank::VariableExchange
36
36
  def save_rates(cache, url=ECB_RATES_URL)
37
37
  raise InvalidCache unless cache
38
38
  File.open(cache, "w") do |file|
39
- io = open(url);
39
+ io = open_url(url);
40
40
  io.each_line { |line| file.puts line }
41
41
  end
42
42
  end
@@ -46,7 +46,7 @@ class EuCentralBank < Money::Bank::VariableExchange
46
46
  end
47
47
 
48
48
  def save_rates_to_s(url=ECB_RATES_URL)
49
- open(url).read
49
+ open_url(url).read
50
50
  end
51
51
 
52
52
  def exchange(cents, from_currency, to_currency, date=nil)
@@ -164,9 +164,9 @@ class EuCentralBank < Money::Bank::VariableExchange
164
164
 
165
165
  def doc(cache, url=ECB_RATES_URL)
166
166
  rates_source = !!cache ? cache : url
167
- Nokogiri::XML(open(rates_source)).tap { |doc| doc.xpath('gesmes:Envelope/xmlns:Cube/xmlns:Cube//xmlns:Cube') }
167
+ Nokogiri::XML(open_url(rates_source)).tap { |doc| doc.xpath('gesmes:Envelope/xmlns:Cube/xmlns:Cube//xmlns:Cube') }
168
168
  rescue Nokogiri::XML::XPath::SyntaxError
169
- Nokogiri::XML(open(url))
169
+ Nokogiri::XML(open_url(url))
170
170
  end
171
171
 
172
172
  def doc_from_s(content)
@@ -218,4 +218,12 @@ class EuCentralBank < Money::Bank::VariableExchange
218
218
  money = (decimal_money * from.cents * rate).round
219
219
  Money.new(money, to_currency)
220
220
  end
221
+
222
+ def open_url(url)
223
+ if RUBY_VERSION >= '2.5.0'
224
+ URI.open(url)
225
+ else
226
+ open(url)
227
+ end
228
+ end
221
229
  end
@@ -12,7 +12,7 @@ module Money::RatesStore
12
12
 
13
13
  # Wraps block execution in a thread-safe transaction
14
14
  def transaction(_force_sync = false, &block)
15
- super &block
15
+ super(&block)
16
16
  end
17
17
 
18
18
  # Iterate over rate tuples (iso_from, iso_to, rate)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eu_central_bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-07 00:00:00.000000000 Z
11
+ date: 2021-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -75,7 +75,7 @@ homepage: https://github.com/RubyMoney/eu_central_bank
75
75
  licenses:
76
76
  - MIT
77
77
  metadata: {}
78
- post_install_message:
78
+ post_install_message:
79
79
  rdoc_options: []
80
80
  require_paths:
81
81
  - lib
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubygems_version: 3.0.3
94
- signing_key:
94
+ signing_key:
95
95
  specification_version: 4
96
96
  summary: Calculates exchange rates based on rates from european central bank. Money
97
97
  gem compatible.