caches 0.0.5 → 0.0.6

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: c9e78a1f8363d6a34aa3ecfcf301b2bc1390ade2
4
- data.tar.gz: 3cb95979ea3b0c416029e2b0791558b48c190b1f
3
+ metadata.gz: 413c1adc86d415334b1ff133cf124fe7f82a4831
4
+ data.tar.gz: 90d46e2b56699932fe3e1b76699fb92c37b23d7f
5
5
  SHA512:
6
- metadata.gz: 413dc61d9667e5825611409ec0a3b2d1abd8b20f3c93128440ab1a5226755ae331093a18e32d478255c25e5b94430912c566b8d25fbfcf7d9ccc75bbf68a3a9e
7
- data.tar.gz: 3e11bc28feb7a34b4a782c4020b7ee61c7e73113636f74c4146ba686a1722f8265af2347c80aebb68483cecc0f20139fbd7eec7adf1a86b2c424740d851f3565
6
+ metadata.gz: a461ad78571ebf10c4b54fc9ec00122750b1b71754e7a2b07080c12b634009c2e02adcbc6eb0d1532ad657419752e7d4217e09a61a256ae116916926d7c7380e
7
+ data.tar.gz: e8f5022d40eecfc8c386d41ecc35812c1b071bf0b36dd518eec449e057b2b33f71f669634c792b30b7b30535a49a6dbd999f81c98ded88ac873fc59fbef2c657
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
 
6
6
  - Nothing
7
7
 
8
+ ## 0.0.6 - 2015-03-09
9
+
10
+ - Stats include a percentage
11
+
8
12
  ## 0.0.5 - 2015-03-09
9
13
 
10
14
  ### Added
data/lib/caches/stats.rb CHANGED
@@ -8,7 +8,7 @@ module Caches
8
8
  end
9
9
 
10
10
  def stats
11
- {hits: @hits, misses: @misses}
11
+ {hits: @hits, misses: @misses, hit_rate: hit_rate}
12
12
  end
13
13
 
14
14
  private
@@ -21,5 +21,10 @@ module Caches
21
21
  @misses += 1
22
22
  end
23
23
 
24
+ def hit_rate
25
+ rate = (Float(@hits) / (Float(@hits) + Float(@misses)))
26
+ "#{rate * 100}%"
27
+ end
28
+
24
29
  end
25
30
  end
@@ -1,3 +1,3 @@
1
1
  module Caches
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -129,7 +129,7 @@ describe Caches::LRU do
129
129
  cache[:a]
130
130
  cache[:b]
131
131
  cache[:nope]
132
- expect(cache.stats).to eq(hits: 2, misses: 1)
132
+ expect(cache.stats).to eq(hits: 2, misses: 1, hit_rate: "66.66666666666666%")
133
133
  end
134
134
 
135
135
  end
@@ -228,7 +228,7 @@ describe Caches::TTL do
228
228
  cache[:a]
229
229
  cache[:b]
230
230
  cache[:nope]
231
- expect(cache.stats).to eq(hits: 2, misses: 1)
231
+ expect(cache.stats).to eq(hits: 2, misses: 1, hit_rate: "66.66666666666666%")
232
232
  end
233
233
 
234
234
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Long