eu_central_bank 1.7.0 → 2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/LICENSE +1 -1
- data/README.md +5 -9
- data/lib/eu_central_bank/version.rb +5 -0
- data/lib/eu_central_bank.rb +12 -15
- metadata +21 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ca70af38e85e1aa52636b0e86ed6a7686b4c5670451da56a01eb880d82b89138
|
|
4
|
+
data.tar.gz: e552f4eaf63c199a3fb4023a434c8f5d2b8fd324c86177a20628aac0d144e3a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18c56beb798fa5773b2dade4b59eae065abaee2d328532946695d0fa1a7acc2b3f725d4c4d21b5edf86040f766ee8b091588514848c3ab2e2ff258934b2c4669
|
|
7
|
+
data.tar.gz: 2b1de916b41d2304d615824c918faa4fae62d275521fddd842397758c22d80eb4d6a0e0f75ebb8726bf19ff6e8a520b51ebbc2255dd148744bcc238f0049bdf5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# eu_central_bank changelog
|
|
2
2
|
|
|
3
|
+
## Upcoming release (unreleased)
|
|
4
|
+
|
|
5
|
+
## 2.0.0 (Dec 10 2025)
|
|
6
|
+
|
|
7
|
+
* **Breaking change**: Require Ruby >= 3.1
|
|
8
|
+
* **Breaking change**: Update Money dependency to 7.0. Make sure to read [the upgrade
|
|
9
|
+
guide](https://github.com/RubyMoney/money/blob/main/UPGRADING-7.0.md).
|
|
10
|
+
* Update YAML loading from compatibility with recent Psych versions.
|
|
11
|
+
* Move Croatian Kuna (HRK) and Russian Ruble (RUB) to legacy currencies
|
|
12
|
+
* Add `EuCentralBank::VERSION`.
|
|
13
|
+
|
|
3
14
|
## 1.7.0 (Nov 17 2021)
|
|
4
15
|
|
|
5
16
|
* Support historical rates
|
|
6
17
|
|
|
7
18
|
## 1.6.1 (Mar 3 2021)
|
|
8
19
|
|
|
9
|
-
* Allow a fallback when loading cached rate files to inhibit network fetch.
|
|
20
|
+
* Allow a fallback when loading cached rate files to inhibit network fetch.
|
|
10
21
|
|
|
11
22
|
## 1.5.0 (Dec 7 2019)
|
|
12
23
|
|
data/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2009 Wong Liang Zan
|
|
4
|
-
Copyright (c)
|
|
4
|
+
Copyright (c) 2025 Shane Emmons
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# eu_central_bank
|
|
2
2
|
|
|
3
|
-
[](https://rubygems.org/gems/eu_central_bank)
|
|
4
|
+
[](https://github.com/RubyMoney/eu_central_bank/actions/workflows/ruby.yml)
|
|
4
5
|
|
|
5
6
|
## Introduction
|
|
6
7
|
|
|
@@ -12,15 +13,10 @@ This gem downloads the exchange rates from the European Central Bank. You can ca
|
|
|
12
13
|
gem install eu_central_bank
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
In case you're using older ruby (< 2.1) you need nokogiri < 1.6.8, so add this to your `Gemfile`:
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
gem 'nokogiri', '1.6.8'
|
|
19
|
-
```
|
|
20
|
-
|
|
21
16
|
## Dependencies
|
|
22
17
|
|
|
23
18
|
- nokogiri
|
|
19
|
+
- bigdecimal
|
|
24
20
|
- money
|
|
25
21
|
|
|
26
22
|
## Usage
|
|
@@ -72,9 +68,9 @@ eu_bank.exchange_with(Money.new(100, "CAD"), "USD") # Money.new(80, "USD")
|
|
|
72
68
|
|
|
73
69
|
- Fork the project.
|
|
74
70
|
- Make your feature addition or bug fix.
|
|
75
|
-
- Add tests for it. This is important so I don't break it in a
|
|
71
|
+
- Add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
76
72
|
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
|
77
73
|
|
|
78
74
|
## Copyright
|
|
79
75
|
|
|
80
|
-
Copyright (c) 2010-
|
|
76
|
+
Copyright (c) 2010-2025 RubyMoney. See LICENSE for details.
|
data/lib/eu_central_bank.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'nokogiri'
|
|
|
3
3
|
require 'money'
|
|
4
4
|
require 'money/rates_store/store_with_historical_data_support'
|
|
5
5
|
require 'eu_central_bank/rates_document'
|
|
6
|
+
require 'eu_central_bank/version'
|
|
6
7
|
|
|
7
8
|
class InvalidCache < StandardError ; end
|
|
8
9
|
|
|
@@ -17,12 +18,12 @@ class EuCentralBank < Money::Bank::VariableExchange
|
|
|
17
18
|
|
|
18
19
|
SERIALIZER_DATE_SEPARATOR = '_AT_'
|
|
19
20
|
DECIMAL_PRECISION = 5
|
|
20
|
-
CURRENCIES = %w(USD JPY BGN CZK DKK GBP HUF ILS ISK PLN RON SEK CHF NOK
|
|
21
|
+
CURRENCIES = %w(USD JPY BGN CZK DKK GBP HUF ILS ISK PLN RON SEK CHF NOK TRY AUD BRL CAD CNY HKD IDR INR KRW MXN MYR NZD PHP SGD THB ZAR).map(&:freeze).freeze
|
|
21
22
|
ECB_RATES_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'.freeze
|
|
22
23
|
ECB_90_DAY_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml'.freeze
|
|
23
24
|
ECB_ALL_HIST_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml'.freeze
|
|
24
25
|
|
|
25
|
-
LEGACY_CURRENCIES = %w(CYP SIT ROL TRL)
|
|
26
|
+
LEGACY_CURRENCIES = %w(CYP HRK RUB SIT ROL TRL)
|
|
26
27
|
|
|
27
28
|
def initialize(st = Money::RatesStore::StoreWithHistoricalDataSupport.new, &block)
|
|
28
29
|
super
|
|
@@ -41,7 +42,7 @@ class EuCentralBank < Money::Bank::VariableExchange
|
|
|
41
42
|
def save_rates(cache, url=ECB_RATES_URL)
|
|
42
43
|
raise InvalidCache unless cache
|
|
43
44
|
File.open(cache, "w") do |file|
|
|
44
|
-
io =
|
|
45
|
+
io = URI.open(url)
|
|
45
46
|
io.each_line { |line| file.puts line }
|
|
46
47
|
end
|
|
47
48
|
end
|
|
@@ -56,7 +57,7 @@ class EuCentralBank < Money::Bank::VariableExchange
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def save_rates_to_s(url=ECB_RATES_URL)
|
|
59
|
-
|
|
60
|
+
URI.open(url).read
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
def exchange(cents, from_currency, to_currency, date=nil)
|
|
@@ -149,7 +150,11 @@ class EuCentralBank < Money::Bank::VariableExchange
|
|
|
149
150
|
when :ruby
|
|
150
151
|
Marshal.load(s)
|
|
151
152
|
when :yaml
|
|
152
|
-
|
|
153
|
+
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
|
|
154
|
+
YAML.safe_load(s, permitted_classes: [ BigDecimal ])
|
|
155
|
+
else
|
|
156
|
+
YAML.safe_load(s, [ BigDecimal ], [], true)
|
|
157
|
+
end
|
|
153
158
|
end
|
|
154
159
|
|
|
155
160
|
data.each do |key, rate|
|
|
@@ -175,9 +180,9 @@ class EuCentralBank < Money::Bank::VariableExchange
|
|
|
175
180
|
def doc(cache, url=ECB_RATES_URL)
|
|
176
181
|
rates_source = !!cache ? cache : url
|
|
177
182
|
begin
|
|
178
|
-
parse_rates(
|
|
183
|
+
parse_rates(URI.open(rates_source))
|
|
179
184
|
rescue Nokogiri::XML::XPath::SyntaxError
|
|
180
|
-
parse_rates(
|
|
185
|
+
parse_rates(URI.open(url))
|
|
181
186
|
end
|
|
182
187
|
end
|
|
183
188
|
|
|
@@ -233,12 +238,4 @@ class EuCentralBank < Money::Bank::VariableExchange
|
|
|
233
238
|
money = (decimal_money * from.cents * rate).round
|
|
234
239
|
Money.new(money, to_currency)
|
|
235
240
|
end
|
|
236
|
-
|
|
237
|
-
def open_url(url)
|
|
238
|
-
if RUBY_VERSION >= '2.5.0'
|
|
239
|
-
URI.open(url)
|
|
240
|
-
else
|
|
241
|
-
open(url)
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
241
|
end
|
metadata
CHANGED
|
@@ -1,63 +1,57 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eu_central_bank
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane Emmons
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-12-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: bigdecimal
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0'
|
|
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: '
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: nokogiri
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
34
|
-
- - ">="
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 6.13.6
|
|
33
|
+
version: '1.11'
|
|
37
34
|
type: :runtime
|
|
38
35
|
prerelease: false
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
37
|
requirements:
|
|
41
38
|
- - "~>"
|
|
42
39
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 6.13.6
|
|
40
|
+
version: '1.11'
|
|
47
41
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
42
|
+
name: money
|
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
|
50
44
|
requirements:
|
|
51
45
|
- - "~>"
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
54
|
-
type: :
|
|
47
|
+
version: '7.0'
|
|
48
|
+
type: :runtime
|
|
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: '7.0'
|
|
61
55
|
description: This gem reads exchange rates from the european central bank website.
|
|
62
56
|
It uses it to calculates exchange rates. It is compatible with the money gem
|
|
63
57
|
email:
|
|
@@ -71,11 +65,15 @@ files:
|
|
|
71
65
|
- README.md
|
|
72
66
|
- lib/eu_central_bank.rb
|
|
73
67
|
- lib/eu_central_bank/rates_document.rb
|
|
68
|
+
- lib/eu_central_bank/version.rb
|
|
74
69
|
- lib/money/rates_store/store_with_historical_data_support.rb
|
|
75
70
|
homepage: https://github.com/RubyMoney/eu_central_bank
|
|
76
71
|
licenses:
|
|
77
72
|
- MIT
|
|
78
|
-
metadata:
|
|
73
|
+
metadata:
|
|
74
|
+
changelog_uri: https://github.com/RubyMoney/eu_central_bank/blob/main/CHANGELOG.md
|
|
75
|
+
source_code_uri: https://github.com/RubyMoney/eu_central_bank
|
|
76
|
+
bug_tracker_uri: https://github.com/RubyMoney/eu_central_bank/issues
|
|
79
77
|
post_install_message:
|
|
80
78
|
rdoc_options: []
|
|
81
79
|
require_paths:
|
|
@@ -84,14 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
84
82
|
requirements:
|
|
85
83
|
- - ">="
|
|
86
84
|
- !ruby/object:Gem::Version
|
|
87
|
-
version:
|
|
85
|
+
version: 3.1.0
|
|
88
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
87
|
requirements:
|
|
90
88
|
- - ">="
|
|
91
89
|
- !ruby/object:Gem::Version
|
|
92
90
|
version: '0'
|
|
93
91
|
requirements: []
|
|
94
|
-
rubygems_version: 3.
|
|
92
|
+
rubygems_version: 3.5.22
|
|
95
93
|
signing_key:
|
|
96
94
|
specification_version: 4
|
|
97
95
|
summary: Calculates exchange rates based on rates from european central bank. Money
|