money-open-exchange-rates 1.4.1 → 1.4.2

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: a8d1aa20a7e00ad9b92ff6f516af74c9f26a0b4a4cfacdbab246833806976cb7
4
- data.tar.gz: 61646aab5bbcfb00e362df9f6fe8e0bc80b9ef553a99ac6bfd26fa1c7d8f5c93
3
+ metadata.gz: 86f324ed978cde7c5b05b50a8fe3d1ce4740333874457c8776c9871b3fa9ee31
4
+ data.tar.gz: ef5d0c06086d520f7a8816a69007b98d4741fb0063148ee0c66b9ec29a658b6d
5
5
  SHA512:
6
- metadata.gz: 61eea8294a9b0b0a311db01d9b792c3831adc1d1711af486f9c43bac434bb5ced1dde20527624f16054e56cda867306bbf43f63dda9a17ef536da302cc77c250
7
- data.tar.gz: 118f24d214bd24f7264aa575e87de2f04e115ebca9d83ce70c24abdd1cc0d93b2995f192ec760314717bbbed846ab75273ff851812a9fb6fd16a114043f63d76
6
+ metadata.gz: 5361f382ab1462ae3c6b1a18e543c1dbe4d8d31f68278c460092d8fd93b65a9fd9070f290915a498b1b9bb10b2c6c6c6fb3bff356a90f0f0b75b12d296914990
7
+ data.tar.gz: d85876e62c4f13ebe24c71a273cb6667e7a331707cd7f48e90393b1d620b51593ff03cc77bc24cac78075fd21983290d99cba5eb62bfdb3c2235d1b790669f8d
data/History.md CHANGED
@@ -1,4 +1,17 @@
1
1
 
2
+ 1.4.2 / 2023-07-25
3
+ ==================
4
+
5
+ * gitlab: Ruby 3.2 in, 2.6 out
6
+ * Merge pull request #70 from @swiknaba / master
7
+ * CI: nicer name, latest versions of Github actions
8
+ * CI: Ruby 3.2 in, 2.6 out
9
+ * Bump year
10
+ * Update jruby version
11
+ * Update rubocop target ruby version
12
+ * Update Rubies on CIs
13
+ * Handle AppIdInactive error
14
+
2
15
  1.4.1 / 2023-05-07
3
16
  ==================
4
17
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2011-2020 Laurent Arnoud <laurent@spkdev.net>
3
+ Copyright (c) 2011-2023 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
@@ -249,7 +249,7 @@ See [GitHub](https://github.com/spk/money-open-exchange-rates/graphs/contributor
249
249
 
250
250
  The MIT License
251
251
 
252
- Copyright © 2011-2020 Laurent Arnoud <laurent@spkdev.net>
252
+ Copyright © 2011-2023 Laurent Arnoud <laurent@spkdev.net>
253
253
 
254
254
  ---
255
255
  [![Build](https://img.shields.io/gitlab/pipeline/spkdev/money-open-exchange-rates/master)](https://gitlab.com/spkdev/money-open-exchange-rates/-/commits/master)
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+ require 'money'
3
5
  require 'net/http'
6
+ require 'time'
4
7
  require 'uri'
5
- require 'money'
6
- require 'json'
7
8
  require File.expand_path('../../open_exchange_rates_bank/version', __dir__)
8
9
 
9
10
  # Money gem class
@@ -20,6 +21,14 @@ class Money
20
21
  # Access restricted (e.g. usage/request limit exceeded for account)
21
22
  class AccessRestricted < StandardError; end
22
23
 
24
+ # app_id_inactive
25
+ class AppIdInactive < StandardError; end
26
+
27
+ ERROR_MAP = {
28
+ access_restricted: AccessRestricted,
29
+ app_id_inactive: AppIdInactive
30
+ }.freeze
31
+
23
32
  # OpenExchangeRatesBank base class
24
33
  class OpenExchangeRatesBank < Money::Bank::VariableExchange
25
34
  VERSION = ::OpenExchangeRatesBank::VERSION
@@ -374,8 +383,8 @@ class Money
374
383
  # @return [Hash] key is country code (ISO 3166-1 alpha-3) value Float
375
384
  def exchange_rates
376
385
  doc = JSON.parse(read_from_cache || read_from_url)
377
- if doc['error'] && doc['message'] == 'access_restricted'
378
- raise AccessRestricted
386
+ if doc['error'] && ERROR_MAP.key?(doc['message'].to_sym)
387
+ raise ERROR_MAP[doc['message'].to_sym]
379
388
  end
380
389
 
381
390
  self.rates_timestamp = doc[TIMESTAMP_KEY]
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Module for version constant
4
4
  module OpenExchangeRatesBank
5
- VERSION = '1.4.1'
5
+ VERSION = '1.4.2'
6
6
  end
@@ -0,0 +1 @@
1
+ {"error": true, "status": 401, "message": "app_id_inactive", "description": "This App ID has been deactivated. Please use another or contact support@openexchangerates.org for assistance."}
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ source 'https://rubygems.org'
4
+
3
5
  gem 'money', '~> 6.7'
4
6
  gem 'money-open-exchange-rates', path: '../../'
@@ -1,26 +1,24 @@
1
1
  PATH
2
- remote: ../../
2
+ remote: ../..
3
3
  specs:
4
- money-open-exchange-rates (0.6.1)
5
- monetize (~> 1.4)
6
- money (~> 6.7)
4
+ money-open-exchange-rates (1.4.1)
5
+ money (~> 6.12)
7
6
 
8
7
  GEM
8
+ remote: https://rubygems.org/
9
9
  specs:
10
- i18n (0.7.0)
11
- monetize (1.4.0)
12
- money (~> 6.7)
13
- money (6.7.1)
14
- i18n (>= 0.6.4, <= 0.7.0)
15
- sixarm_ruby_unaccent (>= 1.1.1, < 2)
16
- sixarm_ruby_unaccent (1.1.1)
10
+ concurrent-ruby (1.2.2)
11
+ i18n (1.13.0)
12
+ concurrent-ruby (~> 1.0)
13
+ money (6.16.0)
14
+ i18n (>= 0.6.4, <= 2)
17
15
 
18
16
  PLATFORMS
19
- ruby
17
+ x86_64-linux
20
18
 
21
19
  DEPENDENCIES
22
20
  money (~> 6.7)
23
21
  money-open-exchange-rates!
24
22
 
25
23
  BUNDLED WITH
26
- 1.13.1
24
+ 2.4.12
@@ -28,6 +28,9 @@ describe Money::Bank::OpenExchangeRatesBank do
28
28
  let(:oer_access_restricted_error_path) do
29
29
  data_file('access_restricted_error.json')
30
30
  end
31
+ let(:oer_app_id_inactive_error_path) do
32
+ data_file('app_id_inactive.json')
33
+ end
31
34
 
32
35
  describe 'exchange' do
33
36
  before do
@@ -106,6 +109,13 @@ describe Money::Bank::OpenExchangeRatesBank do
106
109
  _(proc { subject.update_rates }).must_raise Money::Bank::AccessRestricted
107
110
  end
108
111
 
112
+ it 'should raise AppIdInactive error when restricted by oer' do
113
+ subject.cache = nil
114
+ filepath = oer_app_id_inactive_error_path
115
+ subject.stubs(:api_response).returns File.read(filepath)
116
+ _(proc { subject.update_rates }).must_raise Money::Bank::AppIdInactive
117
+ end
118
+
109
119
  it 'should update itself with exchange rates from OpenExchangeRates' do
110
120
  subject.oer_rates.keys.each do |currency|
111
121
  next unless Money::Currency.find(currency)
@@ -295,13 +305,11 @@ describe Money::Bank::OpenExchangeRatesBank do
295
305
  end
296
306
 
297
307
  it 'should allow update after save' do
298
- begin
299
- subject.refresh_rates
300
- # rubocop:disable Style/RescueStandardError
301
- rescue
302
- # rubocop:enable Style/RescueStandardError
303
- assert false, 'Should allow updating after saving'
304
- end
308
+ subject.refresh_rates
309
+ # rubocop:disable Style/RescueStandardError
310
+ rescue
311
+ # rubocop:enable Style/RescueStandardError
312
+ assert false, 'Should allow updating after saving'
305
313
  end
306
314
 
307
315
  it 'should not break an existing file if save fails to read' do
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.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Arnoud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-07 00:00:00.000000000 Z
11
+ date: 2023-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -144,6 +144,7 @@ files:
144
144
  - lib/open_exchange_rates_bank/version.rb
145
145
  - test/data/2015-01-01.json
146
146
  - test/data/access_restricted_error.json
147
+ - test/data/app_id_inactive.json
147
148
  - test/data/latest.json
148
149
  - test/integration/Gemfile
149
150
  - test/integration/Gemfile.lock
@@ -162,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
163
  requirements:
163
164
  - - ">="
164
165
  - !ruby/object:Gem::Version
165
- version: '2.4'
166
+ version: '2.6'
166
167
  required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  requirements:
168
169
  - - ">="