Skip to content

Commit cdbab1a

Browse files
committed
Tidying up the project
- Old not maintained ruby removed - Gem version maintenance - Github workflow - Switch for an old version removed
1 parent d0b55d2 commit cdbab1a

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

.github/workflows/ruby.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ on:
1515

1616
jobs:
1717
test:
18-
1918
runs-on: ubuntu-latest
2019
strategy:
2120
matrix:
22-
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
21+
ruby-version: ["3.0", "3.1", "3.2", "3.3", "3.4"]
2322

2423
steps:
25-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2625
- name: Set up Ruby
2726
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
2827
# change this to (see https://github.com/ruby/setup-ruby#versioning):

eu_central_bank.gemspec

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ Gem::Specification.new do |s|
1111
s.description = "This gem reads exchange rates from the european central bank website. It uses it to calculates exchange rates. It is compatible with the money gem"
1212
s.license = "MIT"
1313

14-
s.add_dependency "nokogiri", RUBY_VERSION >= "2.1" ? "~> 1.9" : "~> 1.6.8"
15-
s.add_dependency "money", "~> 6.13", ">= 6.13.6"
14+
s.metadata['changelog_uri'] = "https://github.com/RubyMoney/eu_central_bank/blob/main/CHANGELOG.md"
15+
s.metadata['source_code_uri'] = "https://github.com/RubyMoney/eu_central_bank"
16+
s.metadata['bug_tracker_uri'] = "https://github.com/RubyMoney/eu_central_bank/issues"
17+
18+
s.required_ruby_version = ">= 3.0.0"
19+
20+
s.add_dependency "nokogiri", "~> 1.11"
21+
s.add_dependency "money", "~> 6.19"
1622

1723
s.add_development_dependency "rspec", "~> 3.12.0"
1824

lib/eu_central_bank.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def update_historical_rates(cache=nil, all=false)
4141
def save_rates(cache, url=ECB_RATES_URL)
4242
raise InvalidCache unless cache
4343
File.open(cache, "w") do |file|
44-
io = open_url(url)
44+
io = URI.open(url)
4545
io.each_line { |line| file.puts line }
4646
end
4747
end
@@ -56,7 +56,7 @@ def update_rates_from_s(content)
5656
end
5757

5858
def save_rates_to_s(url=ECB_RATES_URL)
59-
open_url(url).read
59+
URI.open(url).read
6060
end
6161

6262
def exchange(cents, from_currency, to_currency, date=nil)
@@ -179,9 +179,9 @@ def check_currency_available(currency)
179179
def doc(cache, url=ECB_RATES_URL)
180180
rates_source = !!cache ? cache : url
181181
begin
182-
parse_rates(open_url(rates_source))
182+
parse_rates(URI.open(rates_source))
183183
rescue Nokogiri::XML::XPath::SyntaxError
184-
parse_rates(open_url(url))
184+
parse_rates(URI.open(url))
185185
end
186186
end
187187

@@ -237,12 +237,4 @@ def calculate_exchange(from, to_currency, rate)
237237
money = (decimal_money * from.cents * rate).round
238238
Money.new(money, to_currency)
239239
end
240-
241-
def open_url(url)
242-
if RUBY_VERSION >= '2.5.0'
243-
URI.open(url)
244-
else
245-
open(url)
246-
end
247-
end
248240
end

0 commit comments

Comments
 (0)