historical-bank 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5fcd5e46f402afbf0763d24571c0693def95ceec4deccbd729cec64aafa3efe
4
- data.tar.gz: 0f783433317e6ec2dd7e66e7fbef898da8d0c14eca2fd9e7978cd0bf53057504
3
+ metadata.gz: e568c08d9edc80b5179c9f5213e673cb6903970cff5c0a4fa39b129216828c2a
4
+ data.tar.gz: 50c5a20b8e49885b1e236ce396c2338b485fb9f8bf97bf3ca306866003b9923c
5
5
  SHA512:
6
- metadata.gz: d3d495434687b598670eb5bcbd3a5945becd67937993f62288cf55fb91e9bd2fc1a72b43db56bdacd3998debbf9d63d0058c58301b513442442e770e14c64118
7
- data.tar.gz: eb517bdcb3e1c9210ffabacd375448b2279b032060d8aea55d5a662f51264a55096f31ddc402a1fd54c3297c3f2fe5909de370224483104129c1f74fc83f6eb7
6
+ metadata.gz: cbaa94ddb35713b5d9493c1093227b130d76122d6888d8a48fb2c6157998bfb244bc4ed286d86d63e7b501263928d818f8e1b7db4a6b5f4d63074ec1a1c62f59
7
+ data.tar.gz: 261784912fbac3b807e24a480b3d7ca93c34aa286a8b5c839993cdeccd8e2f4fc835768807c0e2a8dab72208711dee81ca23c65d11b76fe2b401c84b58687406
data/AUTHORS CHANGED
@@ -2,3 +2,4 @@ Kostis Dadamis
2
2
  Emili Parreno
3
3
  Loris Mazloum
4
4
  Carlos Lopes
5
+ Marek Stańczyk
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.7
4
+ - Fix bug with Ruby memory cache not used. Thank you @stanley90!!
5
+
3
6
  ## 0.1.6
4
7
  - Update how Redis pipeline command is made. The old way will be removed in Redis 5.0.0
5
8
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  Gem::Specification.new do |s|
18
18
  s.name = 'historical-bank'
19
- s.version = '0.1.6'
19
+ s.version = '0.1.7'
20
20
  s.summary = 'Historical Bank'
21
21
  s.description = 'A `Money::Bank::Base` with historical exchange rates'
22
22
  s.authors = ['Kostis Dadamis', 'Emili Parreno']
@@ -318,7 +318,7 @@ class Money
318
318
  def get_base_rate(currency, date)
319
319
  @mutex.synchronize do
320
320
  rates = @rates[currency.iso_code]
321
- rates[date] if rates
321
+ rates[date.iso8601] if rates
322
322
  end
323
323
  end
324
324
 
@@ -357,6 +357,38 @@ class Money
357
357
 
358
358
  it { is_expected.to eq expected_result }
359
359
  end
360
+
361
+ context 'when rates do not exist anywhere' do
362
+ let(:from_currency_base_rates_store) { nil }
363
+ let(:to_currency_base_rates_store) { nil }
364
+ let(:rates_provider) { nil }
365
+
366
+ it 'raises an error' do
367
+ expect { subject }.to raise_error(NoMethodError)
368
+ end
369
+ end
370
+
371
+ context 'when rates exist in Redis but then disappear from Redis' do
372
+ let(:from_currency_base_rates_store) { from_currency_base_rates }
373
+ let(:to_currency_base_rates_store) { to_currency_base_rates }
374
+ let(:rates_provider) { nil }
375
+
376
+ it 'uses the value cached in memory' do
377
+ # first get it from Redis
378
+ expect_any_instance_of(RatesStore::HistoricalRedis).to receive(:get_rates)
379
+ .with(from_currency)
380
+ expect_any_instance_of(RatesStore::HistoricalRedis).to receive(:get_rates)
381
+ .with(to_currency)
382
+ expect(bank.exchange_with_historical(from_money, to_currency, datetime)).to eq expected_result
383
+
384
+ # then get it from memory
385
+ expect_any_instance_of(RatesStore::HistoricalRedis).not_to receive(:get_rates)
386
+ .with(from_currency)
387
+ expect_any_instance_of(RatesStore::HistoricalRedis).not_to receive(:get_rates)
388
+ .with(to_currency)
389
+ expect(bank.exchange_with_historical(from_money, to_currency, datetime)).to eq expected_result
390
+ end
391
+ end
360
392
  end
361
393
 
362
394
  # taken from real rates from XE.com
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: historical-bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kostis Dadamis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-26 00:00:00.000000000 Z
12
+ date: 2024-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: money