peek 0.2.0 → 1.0.1

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: ef0c9cfcf72331e9ea4fb4a99a13a8e310272134
4
- data.tar.gz: fcaa0f1ca750e39bd0b6cf811182ed5555295a85
3
+ metadata.gz: bbed54bce4732314dfcdd567b7dc6a6e1a9239d8
4
+ data.tar.gz: 1f88f52c9afe97f73d1eed6b92146ee052d638f8
5
5
  SHA512:
6
- metadata.gz: 2d03e97811b3ed67445097715013e9443f0ec39e7a7119856d3427e0638ca23638120ea382948881f4776102f7d305ebbdacefc933402d6a464a1439d0a25569
7
- data.tar.gz: 93cdb21287730faf3b08fb1c2fabb692cbba9551cc2c14d09af66863537799da751e4c06d9352fabda102fcc16efe1a932e9ed073374fdc897a289ca0bd0e2ba
6
+ metadata.gz: b8c62b3b22c484f9b9df0de921df6419f66b3aeb81cea9574cbb217776c5e0d6ed7db4753d33e9933cf6446232e717a48056272acedbde3fe5a9db4691408d7d
7
+ data.tar.gz: a68133cfbbc341dbb4fe1518df040748fb2882c8ff326ef14b786ea88db930a0ab0c13e5c48fcaa70560253d724732ce16d69ec0e553f18deca6f2a28945a97c
@@ -1,2 +1,12 @@
1
- before_install:
2
- - gem install bundler
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.3.1
5
+ - 2.2.5
6
+
7
+ gemfile:
8
+ - Gemfile # Rails 5
9
+ - Gemfile-rails42
10
+
11
+ notifications:
12
+ email: false
@@ -82,3 +82,11 @@
82
82
  - Add dependency for coffee-rails for Rails. - [#80](https://github.com/peek/peek/pull/80) [@cllns](https://github.com/cllns)
83
83
  - Fix deprecation warnings for `helper_method` for future versions of Rails past Rails v5. - [#85](https://github.com/peek/peek/pull/85) [@mgrachev](https://github.com/mgrachev)
84
84
  - Listen to Turbolinks v5 `turbolinks:load` JS event to trigger peek updates. - [#88](https://github.com/peek/peek/pull/88) [@lucasmazza](https://github.com/lucasmazza)
85
+
86
+ # 1.0
87
+
88
+ - Rails 4+ compatibility
89
+ - Update `before_filter` to `before_action` @mkcode
90
+ - Replace GIFs with colors @tarebyte
91
+ - Remove CoffeeScript @dewski
92
+ - Use Ruby JSON syntax for hashes
data/Gemfile CHANGED
@@ -4,18 +4,18 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rake'
7
- gem 'json', '~> 1.8.2'
7
+ gem 'json', '~> 2.0', '>= 2.0.2'
8
8
 
9
- gem 'rails', '~> 4.0.0.rc1'
9
+ gem 'rails', '~> 5.0', '>= 5.0.0.1'
10
10
 
11
11
  # Use SCSS for stylesheets
12
- gem 'sass-rails', '~> 4.0.0.rc1'
12
+ gem 'sass-rails', '~> 5.0'
13
13
 
14
14
  # Use Uglifier as compressor for JavaScript assets
15
15
  gem 'uglifier', '>= 1.3.0'
16
16
 
17
17
  # Use CoffeeScript for .js.coffee assets and views
18
- gem 'coffee-rails', '~> 4.0.0'
18
+ gem 'coffee-rails', '~> 4.2'
19
19
 
20
20
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
21
21
  # gem 'therubyracer', platforms: :ruby
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in peek.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+ gem 'json', '~> 1.8.3'
8
+
9
+ gem 'rails', '~> 4.2.7.1'
10
+
11
+ # Use SCSS for stylesheets
12
+ gem 'sass-rails', '~> 5.0.0'
13
+
14
+ # Use Uglifier as compressor for JavaScript assets
15
+ gem 'uglifier', '>= 1.3.0'
16
+
17
+ # Use CoffeeScript for .js.coffee assets and views
18
+ gem 'coffee-rails', '~> 4.1.0'
19
+
20
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
21
+ # gem 'therubyracer', platforms: :ruby
22
+
23
+ # Use jquery as the JavaScript library
24
+ gem 'jquery-rails'
25
+
26
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
27
+ gem 'turbolinks'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Peek
2
2
 
3
- [![Build Status](https://travis-ci.org/peek/peek.png?branch=master)](https://travis-ci.org/peek/peek) [![Gem Version](https://badge.fury.io/rb/peek.png)](http://badge.fury.io/rb/peek) [![Inline docs](http://inch-ci.org/github/peek/peek.png)](http://inch-ci.org/github/peek/peek)
3
+ [![Build Status](https://travis-ci.org/peek/peek.svg?branch=master)](https://travis-ci.org/peek/peek) [![Gem Version](https://badge.fury.io/rb/peek.svg)](http://badge.fury.io/rb/peek) [![Inline docs](http://inch-ci.org/github/peek/peek.svg)](http://inch-ci.org/github/peek/peek)
4
4
 
5
5
  Take a peek into your Rails application.
6
6
 
@@ -34,7 +34,7 @@ file:
34
34
  ```ruby
35
35
  Some::Application.routes.draw do
36
36
  mount Peek::Railtie => '/peek'
37
- root :to => 'home#show'
37
+ root to: 'home#show'
38
38
  end
39
39
  ```
40
40
 
@@ -42,7 +42,7 @@ To pick which views you want to see in your Peek bar, just create a file at
42
42
  `config/initializers/peek.rb` that has a list of the views you'd like to include:
43
43
 
44
44
  ```ruby
45
- Peek.into Peek::Views::Git, :nwo => 'github/janky'
45
+ Peek.into Peek::Views::Git, nwo: 'github/janky'
46
46
  Peek.into Peek::Views::Mysql2
47
47
  Peek.into Peek::Views::Redis
48
48
  Peek.into Peek::Views::Dalli
@@ -125,8 +125,8 @@ Peeked::Application.configure do
125
125
 
126
126
  # Redis with options
127
127
  config.peek.adapter = :redis, {
128
- :client => Redis.new,
129
- :expires_in => 60 * 30 # => 30 minutes in seconds
128
+ client: Redis.new,
129
+ expires_in: 60 * 30 # => 30 minutes in seconds
130
130
  }
131
131
 
132
132
  # Memcache with no options
@@ -134,8 +134,8 @@ Peeked::Application.configure do
134
134
 
135
135
  # Memcache with options
136
136
  config.peek.adapter = :memcache, {
137
- :client => Dalli::Client.new,
138
- :expires_in => 60 * 30 # => 30 minutes in seconds
137
+ client: Dalli::Client.new,
138
+ expires_in: 60 * 30 # => 30 minutes in seconds
139
139
  }
140
140
 
141
141
  # Elasticsearch with no options
@@ -143,10 +143,10 @@ Peeked::Application.configure do
143
143
 
144
144
  # Elasticsearch with options
145
145
  config.peek.adapter = :elasticsearch, {
146
- :client => Elasticsearch::Client.new,
147
- :expires_in => 60 * 30, # => 30 minutes in seconds
148
- :index => 'peek_requests_index',
149
- :type => 'peek_request'
146
+ client: Elasticsearch::Client.new,
147
+ expires_in: 60 * 30, # => 30 minutes in seconds
148
+ index: 'peek_requests_index',
149
+ type: 'peek_request'
150
150
  }
151
151
 
152
152
  # ...
@@ -203,6 +203,7 @@ end
203
203
  - [peek-dalli](https://github.com/peek/peek-dalli)
204
204
  - [peek-delayed_job](https://github.com/18F/peek-delayed_job)
205
205
  - [peek-faraday](https://github.com/grk/peek-faraday)
206
+ - [peek-flexirest](https://github.com/andyjeffries/peek-flexirest)
206
207
  - [peek-gc](https://github.com/peek/peek-gc)
207
208
  - [peek-git](https://github.com/peek/peek-git)
208
209
  - [peek-host](https://github.com/jacobbednarz/peek-host)
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
4
  desc 'Default: run tests'
5
- task :default => :test
5
+ task default: :test
6
6
 
7
7
  desc 'Run Peek tests.'
8
8
  Rake::TestTask.new do |t|
@@ -0,0 +1,86 @@
1
+ //= require peek/vendor/jquery.tipsy
2
+
3
+ var requestId;
4
+
5
+ requestId = null;
6
+
7
+ (function($) {
8
+ var fetchRequestResults, getRequestId, initializeTipsy, peekEnabled, toggleBar, updatePerformanceBar;
9
+ getRequestId = function() {
10
+ if (requestId != null) {
11
+ return requestId;
12
+ } else {
13
+ return $('#peek').data('request-id');
14
+ }
15
+ };
16
+ peekEnabled = function() {
17
+ return $('#peek').length;
18
+ };
19
+ updatePerformanceBar = function(results) {
20
+ var key, label;
21
+ for (key in results.data) {
22
+ for (label in results.data[key]) {
23
+ $("[data-defer-to=" + key + "-" + label + "]").text(results.data[key][label]);
24
+ }
25
+ }
26
+ return $(document).trigger('peek:render', [getRequestId(), results]);
27
+ };
28
+ initializeTipsy = function() {
29
+ return $('#peek .peek-tooltip, #peek .tooltip').each(function() {
30
+ var el, gravity;
31
+ el = $(this);
32
+ gravity = el.hasClass('rightwards') || el.hasClass('leftwards') ? $.fn.tipsy.autoWE : $.fn.tipsy.autoNS;
33
+ return el.tipsy({
34
+ gravity: gravity
35
+ });
36
+ });
37
+ };
38
+ toggleBar = function(event) {
39
+ var wrapper;
40
+ if ($(event.target).is(':input')) {
41
+ return;
42
+ }
43
+ if (event.which === 96 && !event.metaKey) {
44
+ wrapper = $('#peek');
45
+ if (wrapper.hasClass('disabled')) {
46
+ wrapper.removeClass('disabled');
47
+ return document.cookie = "peek=true; path=/";
48
+ } else {
49
+ wrapper.addClass('disabled');
50
+ return document.cookie = "peek=false; path=/";
51
+ }
52
+ }
53
+ };
54
+ fetchRequestResults = function() {
55
+ return $.ajax('/peek/results', {
56
+ data: {
57
+ request_id: getRequestId()
58
+ },
59
+ success: function(data, textStatus, xhr) {
60
+ return updatePerformanceBar(data);
61
+ },
62
+ error: function(xhr, textStatus, error) {}
63
+ });
64
+ };
65
+ $(document).on('keypress', toggleBar);
66
+ $(document).on('peek:update', initializeTipsy);
67
+ $(document).on('peek:update', fetchRequestResults);
68
+ $(document).on('pjax:end', function(event, xhr, options) {
69
+ if (xhr != null) {
70
+ requestId = xhr.getResponseHeader('X-Request-Id');
71
+ }
72
+ if (peekEnabled()) {
73
+ return $(this).trigger('peek:update');
74
+ }
75
+ });
76
+ $(document).on('page:change turbolinks:load', function() {
77
+ if (peekEnabled()) {
78
+ return $(this).trigger('peek:update');
79
+ }
80
+ });
81
+ return $(function() {
82
+ if (peekEnabled()) {
83
+ return $(this).trigger('peek:update');
84
+ }
85
+ });
86
+ })(jQuery);
@@ -1,6 +1,3 @@
1
- //= depend_on_asset 'peek/bar/production.gif'
2
- //= depend_on_asset 'peek/bar/staging.gif'
3
- //= depend_on_asset 'peek/bar/development.gif'
4
1
  //= require peek/vendor/tipsy
5
2
 
6
3
  #peek {
@@ -20,15 +17,15 @@
20
17
  }
21
18
 
22
19
  &.production {
23
- background: image-url('peek/bar/production.gif') repeat 0 0;
20
+ background-color: #222;
24
21
  }
25
22
 
26
23
  &.staging {
27
- background: image-url('peek/bar/staging.gif') repeat 0 0;
24
+ background-color: #291430;
28
25
  }
29
26
 
30
27
  &.development {
31
- background: image-url('peek/bar/development.gif') repeat 0 0;
28
+ background-color: #4c1210;
32
29
  }
33
30
 
34
31
  .wrapper {
@@ -1,14 +1,14 @@
1
1
  module Peek
2
2
  class ResultsController < ApplicationController
3
- before_filter :restrict_non_access
3
+ before_action :restrict_non_access
4
4
 
5
5
  def show
6
6
  respond_to do |format|
7
7
  format.json do
8
8
  if request.xhr?
9
- render :json => Peek.adapter.get(params[:request_id])
9
+ render json: Peek.adapter.get(params[:request_id])
10
10
  else
11
- render :nothing => true, :status => :not_found
11
+ render nothing: true, status: :not_found
12
12
  end
13
13
  end
14
14
  end
@@ -3,7 +3,7 @@
3
3
  <div class="wrapper">
4
4
  <% Peek.views.each do |view| %>
5
5
  <div id="<%= view.dom_id %>" class="view">
6
- <%= render view.partial_path, :view => view %>
6
+ <%= render view.partial_path, view: view %>
7
7
  </div>
8
8
  <% end %>
9
9
  </div>
@@ -1,3 +1,3 @@
1
1
  Peek::Railtie.routes.draw do
2
- get '/results' => 'results#show', :as => :results
2
+ get '/results' => 'results#show', as: :results
3
3
  end
@@ -66,8 +66,8 @@ module Peek
66
66
 
67
67
  def self.results
68
68
  results = {
69
- :context => {},
70
- :data => Hash.new { |h, k| h[k] = {} }
69
+ context: {},
70
+ data: Hash.new { |h, k| h[k] = {} }
71
71
  }
72
72
 
73
73
  views.each do |view|
@@ -3,7 +3,7 @@ module Peek
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- prepend_before_action :set_peek_request_id, :if => :peek_enabled?
6
+ prepend_before_action :set_peek_request_id, if: :peek_enabled?
7
7
  helper_method :peek_enabled? if respond_to? :helper_method
8
8
  end
9
9
 
@@ -1,3 +1,3 @@
1
1
  module Peek
2
- VERSION = '0.2.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -18,8 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ['lib']
20
20
 
21
- gem.add_dependency 'railties', '>= 3.0.0'
21
+ gem.add_dependency 'railties', '>= 4.0.0'
22
22
  gem.add_dependency 'concurrent-ruby', '>= 0.9.0'
23
23
  gem.add_dependency 'concurrent-ruby-ext', '>= 0.9.0'
24
- gem.add_dependency 'coffee-rails'
25
24
  end
@@ -10,5 +10,7 @@
10
10
  // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
11
  // GO AFTER THE REQUIRES BELOW.
12
12
  //
13
+ //= require jquery
14
+ //= require jquery_ujs
13
15
  //= require peek
14
16
  //= require_tree .
@@ -4,6 +4,10 @@ class ApplicationController < ActionController::Base
4
4
  protect_from_forgery with: :exception
5
5
 
6
6
  def peek_enabled?
7
- true
7
+ if defined?(@peek_enabled)
8
+ !!@peek_enabled
9
+ else
10
+ true
11
+ end
8
12
  end
9
13
  end
@@ -1,4 +1,11 @@
1
1
  class HomeController < ApplicationController
2
- def show
2
+ def enabled
3
+ @peek_enabled = true
4
+ render :show
5
+ end
6
+
7
+ def disabled
8
+ @peek_enabled = false
9
+ render :show
3
10
  end
4
11
  end
@@ -1,2 +1,5 @@
1
1
  <h1>Home#show</h1>
2
2
  <p>Find me in app/views/home/show.html.erb</p>
3
+
4
+ <%= debug({ peek_enabled: @peek_enabled }) %>
5
+ <%= debug cookies %>
@@ -0,0 +1 @@
1
+ <strong><span data-defer-to="<%= view.defer_key %>-number">...</span></strong> number
@@ -0,0 +1,3 @@
1
+ require_relative '../../../dummy/lib/test_view'
2
+
3
+ Peek.into TestView
@@ -1,3 +1,8 @@
1
1
  Dummy::Application.routes.draw do
2
- root :to => 'home#show'
2
+ mount Peek::Railtie => 'peek'
3
+
4
+ get '/enabled' => 'home#enabled'
5
+ get '/disabled' => 'home#disabled'
6
+
7
+ root to: 'home#enabled'
3
8
  end
@@ -0,0 +1,20 @@
1
+ require 'concurrent/atomics'
2
+
3
+ class TestView < Peek::Views::View
4
+ class << self
5
+ attr_accessor :counter
6
+ end
7
+ self.counter = Concurrent::AtomicReference.new(0)
8
+
9
+ def results
10
+ self.class.counter.update { |value| value + 1 }
11
+
12
+ {
13
+ number: self.class.counter.value
14
+ }
15
+ end
16
+
17
+ def partial_path
18
+ "peek/test_view"
19
+ end
20
+ end
@@ -37,19 +37,19 @@ describe Peek do
37
37
  end
38
38
 
39
39
  it "should be able to append views" do
40
- Peek.into Staff, :username => 'dewski'
40
+ Peek.into Staff, username: 'dewski'
41
41
  assert_kind_of Staff, Peek.views.first
42
42
  end
43
43
 
44
44
  it "should be able to append views with options" do
45
- Peek.into Staff, :username => 'dewski'
45
+ Peek.into Staff, username: 'dewski'
46
46
  @staff = Peek.views.first
47
47
  assert_kind_of Staff, @staff
48
48
  assert_equal 'dewski', @staff.username
49
49
  end
50
50
 
51
51
  it "should only return enabled views" do
52
- Peek.into Staff, :username => false
52
+ Peek.into Staff, username: false
53
53
  assert_equal [], Peek.views
54
54
  end
55
55
  end
@@ -60,7 +60,7 @@ describe Peek do
60
60
  end
61
61
 
62
62
  it "should clear any current views" do
63
- Peek.into Staff, :username => 'dewski'
63
+ Peek.into Staff, username: 'dewski'
64
64
  assert_kind_of Staff, Peek.views.first
65
65
  Peek.reset
66
66
  assert_equal [], Peek.views
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Bjerkhoel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: concurrent-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.0
55
- - !ruby/object:Gem::Dependency
56
- name: coffee-rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  description: Take a peek into your Rails application.
70
56
  email:
71
57
  - me@garrettbjerkhoel.com
@@ -77,13 +63,11 @@ files:
77
63
  - ".travis.yml"
78
64
  - CHANGELOG.md
79
65
  - Gemfile
66
+ - Gemfile-rails42
80
67
  - LICENSE.txt
81
68
  - README.md
82
69
  - Rakefile
83
- - app/assets/images/peek/bar/development.gif
84
- - app/assets/images/peek/bar/production.gif
85
- - app/assets/images/peek/bar/staging.gif
86
- - app/assets/javascripts/peek.coffee
70
+ - app/assets/javascripts/peek.js
87
71
  - app/assets/javascripts/peek/vendor/jquery.tipsy.js
88
72
  - app/assets/stylesheets/peek.scss
89
73
  - app/assets/stylesheets/peek/vendor/tipsy.scss
@@ -111,6 +95,7 @@ files:
111
95
  - test/dummy/app/helpers/application_helper.rb
112
96
  - test/dummy/app/views/home/show.html.erb
113
97
  - test/dummy/app/views/layouts/application.html.erb
98
+ - test/dummy/app/views/peek/_test_view.html.erb
114
99
  - test/dummy/bin/bundle
115
100
  - test/dummy/bin/rails
116
101
  - test/dummy/bin/rake
@@ -124,11 +109,13 @@ files:
124
109
  - test/dummy/config/initializers/filter_parameter_logging.rb
125
110
  - test/dummy/config/initializers/inflections.rb
126
111
  - test/dummy/config/initializers/mime_types.rb
112
+ - test/dummy/config/initializers/peek.rb
127
113
  - test/dummy/config/initializers/secret_token.rb
128
114
  - test/dummy/config/initializers/session_store.rb
129
115
  - test/dummy/config/initializers/wrap_parameters.rb
130
116
  - test/dummy/config/locales/en.yml
131
117
  - test/dummy/config/routes.rb
118
+ - test/dummy/lib/test_view.rb
132
119
  - test/dummy/log/.keep
133
120
  - test/dummy/public/404.html
134
121
  - test/dummy/public/422.html
@@ -172,6 +159,7 @@ test_files:
172
159
  - test/dummy/app/helpers/application_helper.rb
173
160
  - test/dummy/app/views/home/show.html.erb
174
161
  - test/dummy/app/views/layouts/application.html.erb
162
+ - test/dummy/app/views/peek/_test_view.html.erb
175
163
  - test/dummy/bin/bundle
176
164
  - test/dummy/bin/rails
177
165
  - test/dummy/bin/rake
@@ -185,11 +173,13 @@ test_files:
185
173
  - test/dummy/config/initializers/filter_parameter_logging.rb
186
174
  - test/dummy/config/initializers/inflections.rb
187
175
  - test/dummy/config/initializers/mime_types.rb
176
+ - test/dummy/config/initializers/peek.rb
188
177
  - test/dummy/config/initializers/secret_token.rb
189
178
  - test/dummy/config/initializers/session_store.rb
190
179
  - test/dummy/config/initializers/wrap_parameters.rb
191
180
  - test/dummy/config/locales/en.yml
192
181
  - test/dummy/config/routes.rb
182
+ - test/dummy/lib/test_view.rb
193
183
  - test/dummy/log/.keep
194
184
  - test/dummy/public/404.html
195
185
  - test/dummy/public/422.html
@@ -198,3 +188,4 @@ test_files:
198
188
  - test/peek/views/view_test.rb
199
189
  - test/peek_test.rb
200
190
  - test/test_helper.rb
191
+ has_rdoc:
@@ -1,71 +0,0 @@
1
- #= require peek/vendor/jquery.tipsy
2
-
3
- requestId = null
4
-
5
- do ($ = jQuery) ->
6
-
7
- getRequestId = ->
8
- if requestId? then requestId else $('#peek').data('request-id')
9
-
10
- peekEnabled = ->
11
- $('#peek').length
12
-
13
- updatePerformanceBar = (results) ->
14
- for key of results.data
15
- for label of results.data[key]
16
- $("[data-defer-to=#{key}-#{label}]").text results.data[key][label]
17
- $(document).trigger 'peek:render', [getRequestId(), results]
18
-
19
- initializeTipsy = ->
20
- $('#peek .peek-tooltip, #peek .tooltip').each ->
21
- el = $(this)
22
- gravity = if el.hasClass('rightwards') || el.hasClass('leftwards')
23
- $.fn.tipsy.autoWE
24
- else
25
- $.fn.tipsy.autoNS
26
-
27
- el.tipsy
28
- gravity: gravity
29
-
30
- toggleBar = (event) ->
31
- return if $(event.target).is ':input'
32
-
33
- if event.which == 96 && !event.metaKey
34
- wrapper = $('#peek')
35
- if wrapper.hasClass 'disabled'
36
- wrapper.removeClass 'disabled'
37
- document.cookie = "peek=true; path=/";
38
- else
39
- wrapper.addClass 'disabled'
40
- document.cookie = "peek=false; path=/";
41
-
42
- fetchRequestResults = ->
43
- $.ajax '/peek/results',
44
- data:
45
- request_id: getRequestId()
46
- success: (data, textStatus, xhr) ->
47
- updatePerformanceBar data
48
- error: (xhr, textStatus, error) ->
49
- # Swallow the error
50
-
51
- $(document).on 'keypress', toggleBar
52
-
53
- $(document).on 'peek:update', initializeTipsy
54
- $(document).on 'peek:update', fetchRequestResults
55
-
56
- # Fire the event for our own listeners.
57
- $(document).on 'pjax:end', (event, xhr, options) ->
58
- if xhr?
59
- requestId = xhr.getResponseHeader 'X-Request-Id'
60
-
61
- if peekEnabled()
62
- $(this).trigger 'peek:update'
63
-
64
- # Also listen to turbolinks page change event
65
- $(document).on 'page:change turbolinks:load', ->
66
- if peekEnabled()
67
- $(this).trigger 'peek:update'
68
-
69
- $ ->
70
- if peekEnabled()
71
- $(this).trigger 'peek:update'