peek-dalli 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -9,3 +9,7 @@
9
9
  # 1.1.1
10
10
 
11
11
  - Fix an issue with the peek rename.
12
+
13
+ # 1.1.2
14
+
15
+ - Add CoffeeScript for tooltip context
data/README.md CHANGED
@@ -23,12 +23,26 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- Add the following to your `config/initializers/peek.rb`:
26
+ Add the following to your `config/initializers/peek.rb`:
27
27
 
28
28
  ```ruby
29
29
  Peek.into Peek::Views::Dalli
30
30
  ```
31
31
 
32
+ There is an additional JavaScript file peek-dalli provides that gives
33
+ additional information about the requests Dalli makes during the request:
34
+
35
+ - Reads
36
+ - Misses
37
+ - Writes
38
+
39
+ Include the `peek/views/dalli` JavaScript file in your application:
40
+
41
+ ```coffeescript
42
+ #= require peek
43
+ #= require peek/views/dalli
44
+ ```
45
+
32
46
  ## Contributing
33
47
 
34
48
  1. Fork it
@@ -0,0 +1,11 @@
1
+ $(document).on 'peek:render', (event, requestId, data) ->
2
+ title = []
3
+ title.push("Reads: #{data.context.dalli.reads}")
4
+ title.push("Misses: #{data.context.dalli.misses}")
5
+ title.push("Writes: #{data.context.dalli.writes}")
6
+
7
+ $('#peek-dalli-tooltip')
8
+ .attr('title', title.join('<br>'))
9
+ .tipsy
10
+ html: true
11
+ gravity: $.fn.tipsy.autoNS
@@ -1 +1,5 @@
1
- <strong><span data-defer-to="<%= view.defer_key %>-duration">...</span> / <span data-defer-to="<%= view.defer_key %>-calls">...</span></strong> dalli
1
+ <strong>
2
+ <span id="peek-dalli-tooltip">
3
+ <span data-defer-to="<%= view.defer_key %>-duration">...</span> / <span data-defer-to="<%= view.defer_key %>-calls">...</span>
4
+ </span>
5
+ </strong> dalli
@@ -7,6 +7,10 @@ module Peek
7
7
  @duration = Atomic.new(0)
8
8
  @calls = Atomic.new(0)
9
9
 
10
+ @reads = Atomic.new(0)
11
+ @misses = Atomic.new(0)
12
+ @writes = Atomic.new(0)
13
+
10
14
  setup_subscribers
11
15
  end
12
16
 
@@ -19,8 +23,19 @@ module Peek
19
23
  end
20
24
  end
21
25
 
26
+ def context
27
+ {
28
+ :reads => @reads.value,
29
+ :misses => @misses.value,
30
+ :writes => @writes.value
31
+ }
32
+ end
33
+
22
34
  def results
23
- { :duration => formatted_duration, :calls => @calls.value }
35
+ {
36
+ :duration => formatted_duration,
37
+ :calls => @calls.value
38
+ }
24
39
  end
25
40
 
26
41
  private
@@ -30,6 +45,22 @@ module Peek
30
45
  before_request do
31
46
  @duration.value = 0
32
47
  @calls.value = 0
48
+
49
+ @reads.value = 0
50
+ @misses.value = 0
51
+ @writes.value = 0
52
+ end
53
+
54
+ subscribe('cache_read.active_support') do
55
+ @reads.update { |value| value + 1 }
56
+ end
57
+
58
+ subscribe('cache_miss.active_support') do
59
+ @misses.update { |value| value + 1 }
60
+ end
61
+
62
+ subscribe('cache_write.active_support') do
63
+ @writes.update { |value| value + 1 }
33
64
  end
34
65
 
35
66
  subscribe(/cache_(.*).active_support/) do |name, start, finish, id, payload|
@@ -1,5 +1,5 @@
1
1
  module Peek
2
2
  module Dalli
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peek-dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-28 00:00:00.000000000 Z
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: peek
@@ -73,6 +73,7 @@ files:
73
73
  - LICENSE.txt
74
74
  - README.md
75
75
  - Rakefile
76
+ - app/assets/javascripts/peek/views/dalli.coffee
76
77
  - app/views/peek/views/_dalli.html.erb
77
78
  - lib/peek-dalli.rb
78
79
  - lib/peek-dalli/railtie.rb