currency-rate 0.3.4 → 0.3.5

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
  SHA1:
3
- metadata.gz: c0d1be583b0fe2d1816be95e42335f03c6cbaa07
4
- data.tar.gz: a73d7e099708f8a6ca6c6a7b544fffb991f8f1cf
3
+ metadata.gz: 056017ba095ed7c0a12d48dd98ece18793bdaba4
4
+ data.tar.gz: 9c633f17e7a7ce37e3405597b56a42fd99146e51
5
5
  SHA512:
6
- metadata.gz: de77dd04a942473265c1d516e26d609f88c872d7b85a3728c33072822686ae674f41d4fc808b30c6ec27d5f29c9dcc4f2d2d8b8ac69ba0bcc1273be5b4f11dd2
7
- data.tar.gz: 4c88b3c697e32bf0a6f66c243949f5559f57e98a51546e8c61d3976a467da2c7d315714c6671ad2dcf370a4b490e276df3017f72606c829137c1a3256fdb16ef
6
+ metadata.gz: 927a4f023ac052b62501b55c0caa3bbdbaa279b892f322af6eb8ffdbba0b905e60364769c26cbcffafce77692478787516bd37365f68fcb89b4ccf07141c6a11
7
+ data.tar.gz: 1d110cdffb8e532db7bb55eabdc4dba9c156531a34e0e1a17c1c183900375dad60679dbfbfa222d5f9d06f12c552dd01457ec53ee6f972a999cec8a1d9e319b1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -6,7 +6,7 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "currency-rate"
9
- s.version = "0.3.4"
9
+ s.version = "0.3.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
data/lib/adapter.rb CHANGED
@@ -24,7 +24,6 @@ module CurrencyRate
24
24
  end
25
25
  @rates_updated_at = Time.now
26
26
  rescue Exception => e
27
- # TODO: Try average rate adapter
28
27
  raise FetchingFailed
29
28
  end
30
29
  end
data/lib/storage.rb CHANGED
@@ -6,8 +6,8 @@ module CurrencyRate
6
6
  @mem_storage = {}
7
7
  end
8
8
 
9
- def fetch(key)
10
- if @mem_storage[key].nil? || (@mem_storage[key][:timestamp] < (Time.now.to_i - @timeout))
9
+ def fetch(key, force_from_storage: false)
10
+ if !force_from_storage && (@mem_storage[key].nil? || (@mem_storage[key][:timestamp] < (Time.now.to_i - @timeout)))
11
11
  @mem_storage[key] = { content: yield, timestamp: Time.now.to_i }
12
12
  end
13
13
  @mem_storage[key][:content]
@@ -21,5 +21,12 @@ describe CurrencyRate::Storage do
21
21
  @storage.instance_variable_set(:@timeout, 1800)
22
22
  expect(@storage.fetch('hello_world') { '' }).to eq('hello')
23
23
  end
24
+
25
+ it "fetches from storage regardless if the timestamp expired if :force_from_storage is true" do
26
+ allow(@source).to receive(:get).twice.and_return('hi', 'hello')
27
+ @storage.fetch('hello_world') { @source.get }
28
+ @storage.instance_variable_set(:@timeout, 1800)
29
+ expect(@storage.fetch('hello_world') { '' }).to eq('hi')
30
+ end
24
31
 
25
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currency-rate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: satoshi-unit