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 +4 -4
- data/VERSION +1 -1
- data/currency-rate.gemspec +1 -1
- data/lib/adapter.rb +0 -1
- data/lib/storage.rb +2 -2
- data/spec/lib/storage_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056017ba095ed7c0a12d48dd98ece18793bdaba4
|
4
|
+
data.tar.gz: 9c633f17e7a7ce37e3405597b56a42fd99146e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927a4f023ac052b62501b55c0caa3bbdbaa279b892f322af6eb8ffdbba0b905e60364769c26cbcffafce77692478787516bd37365f68fcb89b4ccf07141c6a11
|
7
|
+
data.tar.gz: 1d110cdffb8e532db7bb55eabdc4dba9c156531a34e0e1a17c1c183900375dad60679dbfbfa222d5f9d06f12c552dd01457ec53ee6f972a999cec8a1d9e319b1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/currency-rate.gemspec
CHANGED
data/lib/adapter.rb
CHANGED
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]
|
data/spec/lib/storage_spec.rb
CHANGED
@@ -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
|
+
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-
|
11
|
+
date: 2017-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: satoshi-unit
|