New upstream version 12.6.1

This commit is contained in:
Pirate Praveen 2020-01-02 00:40:12 +05:30
parent ba8cc108d2
commit 5ed1f864fe
65 changed files with 0 additions and 2050 deletions

View file

@ -1,19 +0,0 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/dummy/log
test/tmp
test/version_tmp
tmp
/bin

View file

@ -1,12 +0,0 @@
language: ruby
rvm:
- 2.3.1
- 2.2.5
gemfile:
- Gemfile # Rails 5
- Gemfile-rails42
notifications:
email: false

View file

@ -1,96 +0,0 @@
# 0.0.1
- Initial release.
# 0.0.2
- Add own tipsy plugin to allow for tooltips.
# 0.0.3
- Change the scope of the .tipsy selector as it's inserted outside of the Glimpse div.
# 0.0.4
- Don't capture ` being pressed when in combination with `cmd`
- Support for [Turbolinks](https://github.com/rails/turbolinks) (#14)
# 0.0.5
- Namespace the tooltips to the `.glimpse-tooltip` class name to not conflict with any application styles for `.tooltip`. (#18)
# 0.0.6
- Added Peek::Views::View#parse_options that gets called within initialize for subclasses to use to parse their options.
# 0.1.0
- Introduced a new JS event `peek:render` that includes the request id and request payload data that is used to update the information in the bar.
- Request information has moved from the `peek/results` partial to an AJAX request that happens on page load, and when PJAX/Turbolinks change pages.
- Removed the need for `peek/results` partial.
- Introduced a Redis and Memcache adapter for multi-server environments to store request payloads.
- Tooltips automatically repositions depending on where the Peek bar is.
# 0.1.1
- Fix bug with how `peek:render` was passing arguments around.
# 0.1.2
- Fix path to memcache adapter - [#34](https://github.com/peek/peek/pull/34) [@grk](https://github.com/grk)
- Prevent namespace collision when using [peek-dalli](https://github.com/peek/peek-dalli) - [#34](https://github.com/peek/peek/pull/34) [@grk](https://github.com/grk)
# 0.1.3
- Remove Redis dependency from Gemfile
# 0.1.4
- Don't access xhr object when not present in pjax:end
# 0.1.5
- Don't trigger `peek:update` event when the peek bar isn't present - [#37](https://github.com/peek/peek/issues/37) [@dewski](https://github.com/dewski)
- Add `after_request` helper method for Peek::Views::View to help reset state
# 0.1.6
- Use `event.which` for normalization between `event.keyCode` and `event.charCode` - [#38](https://github.com/peek/peek/pull/38) [@leongersing](https://github.com/leongersing)
# 0.1.7
- Support all Rails 3.x.x versions by not using `request.uuid` instead `env` - [#39](https://github.com/peek/peek/pull/39) [@bryanmikaelian](https://github.com/bryanmikaelian)
# 0.1.8
- Include the ControllerHelpers directly into `ActionController::Base` - [#41](https://github.com/peek/peek/pull/41) [@lucasmazza](https://github.com/lucasmazza)
# 0.1.9
- Rescue & log Dalli exceptions instead of crashing - [#50](https://github.com/peek/peek/pull/50) [@barunio](https://github.com/barunio)
# 0.1.10
- Take off Responders - [#65](https://github.com/peek/peek/pull/65) [@nwjsmith](https://github.com/nwjsmith)
# 0.2.0
- Add image dependencies for asset compilation - [#67](https://github.com/peek/peek/pull/67) [@fedesoria](https://github.com/fedesoria)
- Update JSON to 1.8.2 for compatibility with Ruby 2.2.2 - [#73](https://github.com/peek/peek/pull/73) [@eitoball](https://github.com/eitoball)
- Use concurrent-ruby gem in favor of deprecated atomic gem. - [#73](https://github.com/peek/peek/pull/73) [@eitoball](https://github.com/eitoball)
- Prevent errors if compatibility mode is enabled for jQuery - [#74](https://github.com/peek/peek/pull/74) [@warseph](https://github.com/warseph)
- Add dependency for coffee-rails for Rails. - [#80](https://github.com/peek/peek/pull/80) [@cllns](https://github.com/cllns)
- 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)
- 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)
# 1.0
- Rails 4+ compatibility
- Update `before_filter` to `before_action` @mkcode
- Replace GIFs with colors @tarebyte
- Remove CoffeeScript @dewski
- Use Ruby JSON syntax for hashes
# Next
- Ensure that Peek can handle concurrent requests with a multithreaded application server

View file

@ -1,30 +0,0 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in peek.gemspec
gemspec
gem 'rake'
gem 'json', '~> 2.0', '>= 2.0.2'
# For the test application
gem 'rails', '~> 5.0', '>= 5.0.0.1'
gem 'concurrent-ruby', '>= 0.9.0'
gem 'concurrent-ruby-ext', '>= 0.9.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

View file

@ -1,27 +0,0 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in peek.gemspec
gemspec
gem 'rake'
gem 'json', '~> 1.8.3'
gem 'rails', '~> 4.2.7.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

View file

@ -1,22 +0,0 @@
Copyright (c) 2013 Garrett Bjerkhoel
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,253 +0,0 @@
# Peek
## Fork notice
This is a fork of https://github.com/peek/peek to support multi-threaded
application servers, like Puma. The upstream pull request to add this is
https://github.com/peek/peek/pull/113.
This repo is a pull mirror of https://github.com/smcgivern/peek, the
source repository for that PR.
## Original README
[![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)
Take a peek into your Rails application.
![Preview](https://f.cloud.github.com/assets/79995/244991/03cee1fa-8a74-11e2-8e33-283cf1298a60.png)
This is a profiling tool originally built at GitHub to help us get an insight into our application. Now, we have extracted this into Peek, so that other Rails application can experience the same benefit.
Peek puts a little bar on top of your application to show you all sorts of helpful information about your application. From the screenshot above, you can see that Peek provides information about database queries, cache, Resque workers and more. However, this is only part of Peek's beauty.
The true beauty of Peek lies in the fact that it is an extensible platform. If there are some performance metrics that you need but are not available on Peek, you can find it from the list of available [Peek Views](#available-peek-views) and integrate it into Peek. Even if you do not find what you want on Peek Views, you can always [create your own](#creating-your-own-peek-item).
## Installation
Add this line to your application's Gemfile:
gem 'peek'
And then execute:
$ bundle
Or install it yourself as:
$ gem install peek
## Usage
Now that Peek is installed, you'll need to mount the engine within your `config/routes.rb`
file:
```ruby
Some::Application.routes.draw do
mount Peek::Railtie => '/peek'
root to: 'home#show'
end
```
To pick which views you want to see in your Peek bar, just create a file at
`config/initializers/peek.rb` that has a list of the views you'd like to include:
```ruby
Peek.into Peek::Views::Git, nwo: 'github/janky'
Peek.into Peek::Views::Mysql2
Peek.into Peek::Views::Redis
Peek.into Peek::Views::Dalli
```
Feel free to pick and install from the [list](https://github.com/peek/peek#available-peek-views) or create your own. The order they
are added to Peek, the order they will appear in your bar.
Next, to render the Peek bar in your application just add the following snippet
just after the opening `<body>` tag in your application layout.
```erb
<%= render 'peek/bar' %>
```
It will look like:
```erb
<html>
<head>
<title>Application</title>
</head>
<body>
<%= render 'peek/bar' %>
<%= yield %>
</body>
</html>
```
Peek fetches the data collected throughout your requests by using the unique request id
that was assigned to the request by Rails. It will call out to its own controller at
[Peek::ResultsController](https://github.com/peek/peek/blob/master/app/controllers/peek/results_controller.rb) which will render the data and be inserted into the bar.
Now that you have the partials in your application, you will need to include the
CSS and JS that help make Peek :sparkles:
In `app/assets/stylesheets/application.scss`:
```scss
//= require peek
```
In `app/assets/javascripts/application.coffee`:
```coffeescript
#= require jquery
#= require jquery_ujs
#= require peek
```
Note: Each additional view may have their own CSS and JS that you may need to require
which should be stated in their usage documentation.
### Configuring the default adapter
For Peek to work, it keeps track of all requests made in your application
so it can report back and display that information in the Peek bar. By default
it stores this information in memory, which is not recommended for production environments.
In production environments you may have application servers on multiple hosts,
at which Peek will not be able to access the request data if it was saved in memory on
another host. Peek provides 2 additional adapters for multi server environments.
You can configure which adapter Peek uses by updating your application
config or an individual environment config file. We'll use production as an example.
Note: Peek does not provide the dependencies for each of these adapters. If you use these
adapters be sure to include their dependencies in your application.
- Redis - The [redis](https://github.com/redis/redis-rb) gem
- Dalli - The [dalli](https://github.com/mperham/dalli) gem
- Elasticsearch - The [elasticsearch](https://github.com/elasticsearch/elasticsearch-ruby) gem
```ruby
Peeked::Application.configure do
# ...
# Redis with no options
config.peek.adapter = :redis
# Redis with options
config.peek.adapter = :redis, {
client: Redis.new,
expires_in: 60 * 30 # => 30 minutes in seconds
}
# Memcache with no options
config.peek.adapter = :memcache
# Memcache with options
config.peek.adapter = :memcache, {
client: Dalli::Client.new,
expires_in: 60 * 30 # => 30 minutes in seconds
}
# Elasticsearch with no options
config.peek.adapter = :elasticsearch
# Elasticsearch with options
config.peek.adapter = :elasticsearch, {
client: Elasticsearch::Client.new,
expires_in: 60 * 30, # => 30 minutes in seconds
index: 'peek_requests_index',
type: 'peek_request'
}
# ...
end
```
Peek doesn't persist the request data forever. It uses a safe 30 minute cache
length that way data will be available if you'd like to aggregate it or
use it for other Peek views. You can update this to be 30 seconds if you don't
want the data to be available to stick around.
### Customizing the bar
You can customize the appearance of the bar by customizing it in your own application's CSS.
One common example is fixing the peek bar to the bottom, rather than top, of a page, for use with [Bootstrap](http://getbootstrap.com/):
```css
#peek {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
}
```
## Using Peek with PJAX
It just works.
## Using Peek with Turbolinks
It just works.
## Access Control
Peek will only render in development and staging environments. If you'd
like to whitelist a select number of users to view Peek in production you
can override the `peek_enabled?` guard in `ApplicationController`:
```ruby
class ApplicationController < ActionController::Base
def peek_enabled?
current_user.staff?
end
end
```
## Available Peek views
- [peek-active_resource](https://github.com/gotmayonase/peek-active_resource)
- [peek-alt-routes](https://github.com/mkcode/peek-alt-routes)
- [peek-dalli](https://github.com/peek/peek-dalli)
- [peek-delayed_job](https://github.com/18F/peek-delayed_job)
- [peek-faraday](https://github.com/grk/peek-faraday)
- [peek-flexirest](https://github.com/andyjeffries/peek-flexirest)
- [peek-gc](https://github.com/peek/peek-gc)
- [peek-git](https://github.com/peek/peek-git)
- [peek-host](https://github.com/jacobbednarz/peek-host)
- [peek-mongo](https://github.com/peek/peek-mongo)
- [peek-moped](https://github.com/nodkz/peek-moped)
- [peek-mysql2](https://github.com/peek/peek-mysql2)
- [peek-performance_bar](https://github.com/peek/peek-performance_bar)
- [peek-pg](https://github.com/peek/peek-pg)
- [peek-rblineprof](https://github.com/peek/peek-rblineprof)
- [peek-redis](https://github.com/peek/peek-redis)
- [peek-resque](https://github.com/peek/peek-resque)
- [peek-sidekiq](https://github.com/suranyami/peek-sidekiq)
- [peek-svn](https://github.com/neilco/peek-svn)
- Unicorn :soon:
Feel free to submit a Pull Request adding your own Peek item to this list.
## Creating your own Peek item
Each Peek item is a self contained Rails engine which gives you the power to
use all features of Ruby on Rails to dig in deep within your application and
report it back to the Peek bar. A Peek item is just a custom class that
is responsible for fetching and building the data that should be reported back
to the user.
There are still some docs to be written, but if you'd like to checkout a simple
example of how to create your own, just checkout [peek-git](https://github.com/peek/peek-git).
To just look at an example view, there is [Peek::Views::Git](https://github.com/peek/peek-git/blob/master/lib/peek/views/git.rb).
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

View file

@ -1,13 +0,0 @@
require 'bundler/gem_tasks'
require 'rake/testtask'
desc 'Default: run tests'
task default: :test
desc 'Run Peek tests.'
Rake::TestTask.new do |t|
t.libs << 'lib'
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end

View file

@ -1,86 +0,0 @@
//= require peek/vendor/jquery.tipsy
var requestId;
requestId = null;
(function($) {
var fetchRequestResults, getRequestId, initializeTipsy, peekEnabled, toggleBar, updatePerformanceBar;
getRequestId = function() {
if (requestId != null) {
return requestId;
} else {
return $('#peek').data('request-id');
}
};
peekEnabled = function() {
return $('#peek').length;
};
updatePerformanceBar = function(results) {
var key, label;
for (key in results.data) {
for (label in results.data[key]) {
$("[data-defer-to=" + key + "-" + label + "]").text(results.data[key][label]);
}
}
return $(document).trigger('peek:render', [getRequestId(), results]);
};
initializeTipsy = function() {
return $('#peek .peek-tooltip, #peek .tooltip').each(function() {
var el, gravity;
el = $(this);
gravity = el.hasClass('rightwards') || el.hasClass('leftwards') ? $.fn.tipsy.autoWE : $.fn.tipsy.autoNS;
return el.tipsy({
gravity: gravity
});
});
};
toggleBar = function(event) {
var wrapper;
if ($(event.target).is(':input')) {
return;
}
if (event.which === 96 && !event.metaKey) {
wrapper = $('#peek');
if (wrapper.hasClass('disabled')) {
wrapper.removeClass('disabled');
return document.cookie = "peek=true; path=/";
} else {
wrapper.addClass('disabled');
return document.cookie = "peek=false; path=/";
}
}
};
fetchRequestResults = function() {
return $.ajax('/peek/results', {
data: {
request_id: getRequestId()
},
success: function(data, textStatus, xhr) {
return updatePerformanceBar(data);
},
error: function(xhr, textStatus, error) {}
});
};
$(document).on('keypress', toggleBar);
$(document).on('peek:update', initializeTipsy);
$(document).on('peek:update', fetchRequestResults);
$(document).on('pjax:end', function(event, xhr, options) {
if (xhr != null) {
requestId = xhr.getResponseHeader('X-Request-Id');
}
if (peekEnabled()) {
return $(this).trigger('peek:update');
}
});
$(document).on('page:change turbolinks:load', function() {
if (peekEnabled()) {
return $(this).trigger('peek:update');
}
});
return $(function() {
if (peekEnabled()) {
return $(this).trigger('peek:update');
}
});
})(jQuery);

View file

@ -1,258 +0,0 @@
// tipsy, facebook style tooltips for jquery
// version 1.0.0a
// (c) 2008-2010 jason frame [jason@onehackoranother.com]
// released under the MIT license
(function($) {
function maybeCall(thing, ctx) {
return (typeof thing == 'function') ? (thing.call(ctx)) : thing;
};
function isElementInDOM(ele) {
while (ele = ele.parentNode) {
if (ele == document) return true;
}
return false;
};
function Tipsy(element, options) {
this.$element = $(element);
this.options = options;
this.enabled = true;
this.fixTitle();
};
Tipsy.prototype = {
show: function() {
var title = this.getTitle();
if (title && this.enabled) {
var $tip = this.tip();
$tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title);
$tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity
$tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).prependTo(document.body);
var pos = $.extend({}, this.$element.offset(), {
width: this.$element[0].offsetWidth,
height: this.$element[0].offsetHeight
});
var actualWidth = $tip[0].offsetWidth,
actualHeight = $tip[0].offsetHeight,
gravity = maybeCall(this.options.gravity, this.$element[0]);
var tp;
switch (gravity.charAt(0)) {
case 'n':
tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2};
break;
case 's':
tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2};
break;
case 'e':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset};
break;
case 'w':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset};
break;
}
if (gravity.length == 2) {
if (gravity.charAt(1) == 'w') {
tp.left = pos.left + pos.width / 2 - 15;
} else {
tp.left = pos.left + pos.width / 2 - actualWidth + 15;
}
}
$tip.css(tp).addClass('tipsy-' + gravity);
$tip.find('.tipsy-arrow')[0].className = 'tipsy-arrow tipsy-arrow-' + gravity.charAt(0);
if (this.options.className) {
$tip.addClass(maybeCall(this.options.className, this.$element[0]));
}
if (this.options.fade) {
$tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity});
} else {
$tip.css({visibility: 'visible', opacity: this.options.opacity});
}
}
},
hide: function() {
if (this.options.fade) {
this.tip().stop().fadeOut(function() { $(this).remove(); });
} else {
this.tip().remove();
}
},
fixTitle: function() {
var $e = this.$element;
if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') {
$e.attr('original-title', $e.attr('title') || '').removeAttr('title');
}
},
getTitle: function() {
var title, $e = this.$element, o = this.options;
this.fixTitle();
var title, o = this.options;
if (typeof o.title == 'string') {
title = $e.attr(o.title == 'title' ? 'original-title' : o.title);
} else if (typeof o.title == 'function') {
title = o.title.call($e[0]);
}
title = ('' + title).replace(/(^\s*|\s*$)/, "");
return title || o.fallback;
},
tip: function() {
if (!this.$tip) {
this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>');
this.$tip.data('tipsy-pointee', this.$element[0]);
}
return this.$tip;
},
validate: function() {
if (!this.$element[0].parentNode) {
this.hide();
this.$element = null;
this.options = null;
}
},
enable: function() { this.enabled = true; },
disable: function() { this.enabled = false; },
toggleEnabled: function() { this.enabled = !this.enabled; }
};
$.fn.tipsy = function(options) {
if (options === true) {
return this.data('tipsy');
} else if (typeof options == 'string') {
var tipsy = this.data('tipsy');
if (tipsy) tipsy[options]();
return this;
}
options = $.extend({}, $.fn.tipsy.defaults, options);
function get(ele) {
var tipsy = $.data(ele, 'tipsy');
if (!tipsy) {
tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options));
$.data(ele, 'tipsy', tipsy);
}
return tipsy;
}
function enter() {
var tipsy = get(this);
tipsy.hoverState = 'in';
if (options.delayIn == 0) {
tipsy.show();
} else {
tipsy.fixTitle();
setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn);
}
};
function leave() {
var tipsy = get(this);
tipsy.hoverState = 'out';
if (options.delayOut == 0) {
tipsy.hide();
} else {
setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut);
}
};
if (!options.live) this.each(function() { get(this); });
if (options.trigger != 'manual') {
var binder = options.live ? 'live' : 'bind',
eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus',
eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur';
this[binder](eventIn, enter)[binder](eventOut, leave);
}
return this;
};
$.fn.tipsy.defaults = {
className: null,
delayIn: 0,
delayOut: 0,
fade: false,
fallback: '',
gravity: 'n',
html: false,
live: false,
offset: 0,
opacity: 0.8,
title: 'title',
trigger: 'hover'
};
$.fn.tipsy.revalidate = function() {
$('.tipsy').each(function() {
var pointee = $.data(this, 'tipsy-pointee');
if (!pointee || !isElementInDOM(pointee)) {
$(this).remove();
}
});
};
// Overwrite this method to provide options on a per-element basis.
// For example, you could store the gravity in a 'tipsy-gravity' attribute:
// return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
// (remember - do not modify 'options' in place!)
$.fn.tipsy.elementOptions = function(ele, options) {
return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
};
$.fn.tipsy.autoNS = function() {
return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
};
$.fn.tipsy.autoWE = function() {
return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
};
/**
* yields a closure of the supplied parameters, producing a function that takes
* no arguments and is suitable for use as an autogravity function like so:
*
* @param margin (int) - distance from the viewable region edge that an
* element should be before setting its tooltip's gravity to be away
* from that edge.
* @param prefer (string, e.g. 'n', 'sw', 'w') - the direction to prefer
* if there are no viewable region edges effecting the tooltip's
* gravity. It will try to vary from this minimally, for example,
* if 'sw' is preferred and an element is near the right viewable
* region edge, but not the top edge, it will set the gravity for
* that element's tooltip to be 'se', preserving the southern
* component.
*/
$.fn.tipsy.autoBounds = function(margin, prefer) {
return function() {
var dir = {ns: prefer[0], ew: (prefer.length > 1 ? prefer[1] : false)},
boundTop = $(document).scrollTop() + margin,
boundLeft = $(document).scrollLeft() + margin,
$this = $(this);
if ($this.offset().top < boundTop) dir.ns = 'n';
if ($this.offset().left < boundLeft) dir.ew = 'w';
if ($(window).width() + $(document).scrollLeft() - $this.offset().left < margin) dir.ew = 'e';
if ($(window).height() + $(document).scrollTop() - $this.offset().top < margin) dir.ns = 's';
return dir.ns + (dir.ew ? dir.ew : '');
}
};
})(jQuery);

View file

@ -1,85 +0,0 @@
//= require peek/vendor/tipsy
#peek {
background: #000;
height: 35px;
line-height: 35px;
color: #999;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
.hidden {
display: none;
visibility: visible;
}
&.disabled {
display: none;
}
&.production {
background-color: #222;
}
&.staging {
background-color: #291430;
}
&.development {
background-color: #4c1210;
}
.wrapper {
width: 800px;
margin: 0 auto;
}
// UI Elements
.bucket {
background: #111;
display: inline-block;
padding: 4px 6px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
line-height: 1;
color: #ccc;
border-radius: 3px;
box-shadow: 0 1px 0 rgba(255,255,255,.2), inset 0 1px 2px rgba(0,0,0,.25);
.hidden {
display: none;
}
&:hover .hidden {
display: inline;
}
}
strong {
color: #fff;
}
.view {
margin-right: 15px;
float: left;
&:last-child {
margin-right: 0;
}
}
.css-truncate {
&.css-truncate-target,
.css-truncate-target {
display: inline-block;
max-width: 125px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: top;
}
&.expandable:hover .css-truncate-target,
&.expandable:hover.css-truncate-target {
max-width: 10000px !important;
}
}
}

View file

@ -1,22 +0,0 @@
.tipsy { font-size: 10px; position: absolute; padding: 5px; z-index: 100000; }
.tipsy-inner { background-color: #000; color: #FFF; max-width: 200px; padding: 5px 8px 4px 8px; text-align: center; }
/* Rounded corners */
.tipsy-inner { border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
.tipsy-arrow { position: absolute; width: 0; height: 0; line-height: 0; border: 5px dashed #000; }
/* Rules to colour arrows */
.tipsy-arrow-n { border-bottom-color: #000; }
.tipsy-arrow-s { border-top-color: #000; }
.tipsy-arrow-e { border-left-color: #000; }
.tipsy-arrow-w { border-right-color: #000; }
.tipsy-n .tipsy-arrow { top: 0px; left: 50%; margin-left: -5px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-nw .tipsy-arrow { top: 0; left: 10px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent;}
.tipsy-ne .tipsy-arrow { top: 0; right: 10px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent;}
.tipsy-s .tipsy-arrow { bottom: 0; left: 50%; margin-left: -5px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-sw .tipsy-arrow { bottom: 0; left: 10px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-se .tipsy-arrow { bottom: 0; right: 10px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
.tipsy-e .tipsy-arrow { right: 0; top: 50%; margin-top: -5px; border-left-style: solid; border-right: none; border-top-color: transparent; border-bottom-color: transparent; }
.tipsy-w .tipsy-arrow { left: 0; top: 50%; margin-top: -5px; border-right-style: solid; border-left: none; border-top-color: transparent; border-bottom-color: transparent; }

View file

@ -1,25 +0,0 @@
module Peek
class ResultsController < ApplicationController
before_action :restrict_non_access
def show
respond_to do |format|
format.json do
if request.xhr?
render json: Peek.adapter.get(params[:request_id])
else
render nothing: true, status: :not_found
end
end
end
end
private
def restrict_non_access
unless peek_enabled?
raise ActionController::RoutingError.new('Not Found')
end
end
end
end

View file

@ -1,11 +0,0 @@
<% if peek_enabled? %>
<div id="peek" class="<%= Peek.env %><%= ' disabled' if cookies[:peek] == 'false' %>" data-request-id="<%= peek_request_id %>">
<div class="wrapper">
<% Peek.views.each do |view| %>
<div id="<%= view.dom_id %>" class="view">
<%= render view.partial_path, view: view %>
</div>
<% end %>
</div>
</div>
<% end %>

View file

@ -1,3 +0,0 @@
Peek::Railtie.routes.draw do
get '/results' => 'results#show', as: :results
end

View file

@ -1,22 +0,0 @@
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'peek/version'
Gem::Specification.new do |gem|
gem.name = 'gitlab-peek'
gem.version = Peek::VERSION
gem.authors = ['Garrett Bjerkhoel']
gem.email = ['me@garrettbjerkhoel.com']
gem.description = %q{Take a peek into your Rails application.}
gem.summary = %q{Take a peek into your Rails application.}
gem.homepage = 'https://github.com/peek/peek'
gem.license = 'MIT'
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ['lib']
gem.add_dependency 'railties', '>= 4.0.0'
end

View file

@ -1,93 +0,0 @@
require 'peek/version'
require 'rails'
require 'peek/adapters/memory'
require 'peek/views/view'
module Peek
ALLOWED_ENVS = ['development', 'staging'].freeze
def self.adapter
@adapter
end
def self.adapter=(*adapter_options)
adapter, *parameters = *Array.wrap(adapter_options).flatten
@adapter = case adapter
when Symbol
adapter_class_name = adapter.to_s.camelize
adapter_class =
begin
require "peek/adapters/#{adapter}"
rescue LoadError => e
raise "Could not find adapter for #{adapter} (#{e})"
else
Peek::Adapters.const_get(adapter_class_name)
end
adapter_class.new(*parameters)
when nil
Peek::Adapters::Memory.new
else
adapter
end
@adapter
end
def self.enabled?
ALLOWED_ENVS.include?(env)
end
def self.env
Rails.env
end
def self.views
@cached_views ||= if @views && @views.any?
@views.collect { |klass, options| klass.new(options.dup) }.select(&:enabled?)
else
[]
end
end
def self.results
results = {
context: {},
data: Hash.new { |h, k| h[k] = {} }
}
views.each do |view|
if view.context?
results[:context][view.key] = view.context
end
view.results.each do |key, value|
results[:data][view.key][key] = value
end
end
results
end
def self.into(klass, options = {})
@views ||= []
@views << [klass, options]
end
# Clears out any and all views.
#
# Returns nothing.
def self.reset
@views = nil
@cached_views = nil
end
def self.setup
ActiveSupport::Deprecation.warn "'Peek.setup' is deprecated and does nothing.", caller
end
end
require 'peek/railtie'
ActiveSupport.run_load_hooks(:peek, Peek)

View file

@ -1,17 +0,0 @@
module Peek
module Adapters
class Base
def initialize(options = {})
end
def get(request_id)
raise "#{self.class}#get(request_id) is not yet implemented"
end
def save
raise "#{self.class}#save is not yet implemented"
end
end
end
end

View file

@ -1,33 +0,0 @@
require 'peek/adapters/base'
require 'elasticsearch'
module Peek
module Adapters
class Elasticsearch < Base
def initialize(options = {})
@client = options.fetch(:client, ::Elasticsearch::Client.new)
@expires_in = Integer(options.fetch(:expires_in, 60 * 30) * 1000)
@index = options.fetch(:index, 'peek_requests_index')
@type = options.fetch(:type, 'peek_request')
end
def get(request_id)
result = @client.get_source index: @index, type: @type, id: "#{request_id}"
result.to_json
rescue ::Elasticsearch::Transport::Transport::Errors::NotFound
# pass
end
def save(request_id)
@client.index index: @index,
type: @type,
id: "#{request_id}",
body: Peek.results.to_json,
ttl: @expires_in
rescue ::Elasticsearch::Transport::Transport::Errors::BadRequest
false
end
end
end
end

View file

@ -1,25 +0,0 @@
require 'peek/adapters/base'
require 'dalli'
module Peek
module Adapters
class Memcache < Base
def initialize(options = {})
@client = options.fetch(:client, ::Dalli::Client.new)
@expires_in = options.fetch(:expires_in, 60 * 30)
end
def get(request_id)
@client.get("peek:requests:#{request_id}")
rescue ::Dalli::DalliError => e
Rails.logger.error "#{e.class.name}: #{e.message}"
end
def save(request_id)
@client.add("peek:requests:#{request_id}", Peek.results.to_json, @expires_in)
rescue ::Dalli::DalliError => e
Rails.logger.error "#{e.class.name}: #{e.message}"
end
end
end
end

View file

@ -1,25 +0,0 @@
require 'peek/adapters/base'
module Peek
module Adapters
class Memory < Base
attr_accessor :requests
def initialize(options = {})
@requests = {}
end
def get(request_id)
@requests[request_id]
end
def save(request_id)
@requests[request_id] = Peek.results
end
def reset
@requests.clear
end
end
end
end

View file

@ -1,21 +0,0 @@
require 'peek/adapters/base'
require 'redis'
module Peek
module Adapters
class Redis < Base
def initialize(options = {})
@client = options.fetch(:client, ::Redis.new)
@expires_in = Integer(options.fetch(:expires_in, 60 * 30))
end
def get(request_id)
@client.get("peek:requests:#{request_id}")
end
def save(request_id)
@client.setex("peek:requests:#{request_id}", @expires_in, Peek.results.to_json)
end
end
end
end

View file

@ -1,22 +0,0 @@
module Peek
module ControllerHelpers
extend ActiveSupport::Concern
included do
if respond_to? :helper_method
helper_method :peek_enabled?
helper_method :peek_request_id
end
end
protected
def peek_enabled?
Peek.enabled?
end
def peek_request_id
request.env['action_dispatch.request_id']
end
end
end

View file

@ -1,37 +0,0 @@
require 'peek/controller_helpers'
module Peek
class Railtie < ::Rails::Engine
isolate_namespace Peek
engine_name :peek
config.peek = ActiveSupport::OrderedOptions.new
# Default adapter
config.peek.adapter = :memory
initializer 'peek.set_configs' do |app|
ActiveSupport.on_load(:peek) do
app.config.peek.each do |k,v|
send "#{k}=", v
end
end
end
initializer 'peek.persist_request_data' do
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |_name, _start, _finish, _id, payload|
Peek.adapter.save(payload[:headers].env['action_dispatch.request_id'])
end
end
initializer 'peek.include_controller_helpers' do
ActiveSupport.on_load(:action_controller) do
include Peek::ControllerHelpers
end
config.to_prepare do
Peek.views
end
end
end
end

View file

@ -1,3 +0,0 @@
module Peek
VERSION = '0.0.1'
end

View file

@ -1,124 +0,0 @@
module Peek
module Views
class View
def initialize(options = {})
@options = options
parse_options
setup_subscribers
end
# Where any subclasses should pick and pull from @options to set any and
# all instance variables they like.
#
# Returns nothing.
def parse_options
# pass
end
# Conditionally enable views based on any gathered data. Helpful
# if you don't want views to show up when they return 0 or are
# touched during the request.
#
# Returns true.
def enabled?
true
end
# The path to the partial that will be rendered to the Peek bar.
#
# Examples:
#
# Peek::Views::PerformanceBar.partial_path => "peek/views/performance_bar"
# CustomResque.partial_path => "performance_bar"
#
# Returns String.
def partial_path
self.class.to_s.underscore
end
# The defer key that is derived from the classname.
#
# Examples:
#
# Peek::Views::PerformanceBar => "performance-bar"
# Peek::Views::Resque => "resque"
#
# Returns String.
def key
self.class.to_s.split('::').last.underscore.gsub(/\_/, '-')
end
alias defer_key key
# The context id that is derived from the classname.
#
# Examples:
#
# Peek::Views::PerformanceBar => "peek-context-performance-bar"
# Peek::Views::Resque => "peek-context-resque"
#
# Returns String.
def context_id
"peek-context-#{key}"
end
# The wrapper ID for the individual view in the Peek bar.
#
# Returns String.
def dom_id
"peek-view-#{key}"
end
# Additional context for any view to render tooltips for.
#
# Returns Hash.
def context
{}
end
def context?
context.any?
end
# The data results that are inserted at the end of the request for use in
# deferred placeholders in the Peek the bar.
#
# Returns Hash.
def results
{}
end
def results?
results.any?
end
def subscribe(*args)
ActiveSupport::Notifications.subscribe(*args) do |name, start, finish, id, payload|
yield name, start, finish, id, payload
end
end
private
def setup_subscribers
# pass
end
# Helper method for subscribing to the event that is fired when new
# requests are made.
def before_request
subscribe 'start_processing.action_controller' do |name, start, finish, id, payload|
yield name, start, finish, id, payload
end
end
# Helper method for subscribing to the event that is fired when requests
# are finished.
def after_request
subscribe 'process_action.action_controller' do |name, start, finish, id, payload|
yield name, start, finish, id, payload
end
end
end
end
end

View file

@ -1,33 +0,0 @@
require 'test_helper'
require_relative '../dummy/lib/test_view'
class RequestsTest < ActionDispatch::IntegrationTest
setup do
Peek.adapter.reset
Peek.reset
end
test "the request id is set" do
assert_empty Peek.adapter.requests
get '/'
assert_not_empty Peek.adapter.requests
end
test "the request ID and data are set correctly for concurrent requests" do
Peek.into TestView
concurrent_requests = 10
assert_empty Peek.adapter.requests
concurrent_requests.times.map do
Thread.new { get '/' }
end.map(&:join)
result_sequence = Peek.adapter.requests.values.map { |value| value[:data]['test-view'][:number] }
assert_equal Peek.adapter.requests.length, concurrent_requests
assert_equal result_sequence, 1.upto(concurrent_requests).to_a
end
end

View file

@ -1,28 +0,0 @@
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.

View file

@ -1,6 +0,0 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Dummy::Application.load_tasks

View file

@ -1,16 +0,0 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require peek
//= require_tree .

View file

@ -1,14 +0,0 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require peek
*= require_self
*= require_tree .
*/

View file

@ -1,13 +0,0 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def peek_enabled?
if defined?(@peek_enabled)
!!@peek_enabled
else
true
end
end
end

View file

@ -1,11 +0,0 @@
class HomeController < ApplicationController
def enabled
@peek_enabled = true
render :show
end
def disabled
@peek_enabled = false
render :show
end
end

View file

@ -1,2 +0,0 @@
module ApplicationHelper
end

View file

@ -1,5 +0,0 @@
<h1>Home#show</h1>
<p>Find me in app/views/home/show.html.erb</p>
<%= debug({ peek_enabled: @peek_enabled }) %>
<%= debug cookies %>

View file

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= render 'peek/bar' %>
<%= yield %>
</body>
</html>

View file

@ -1 +0,0 @@
<strong><span data-defer-to="<%= view.defer_key %>-number">...</span></strong> number

View file

@ -1,3 +0,0 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

View file

@ -1,4 +0,0 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

View file

@ -1,4 +0,0 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

View file

@ -1,4 +0,0 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View file

@ -1,25 +0,0 @@
require File.expand_path('../boot', __FILE__)
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'sprockets/railtie'
require 'rails/test_unit/railtie'
Bundler.require(*Rails.groups)
require 'peek'
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end

View file

@ -1,5 +0,0 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

View file

@ -1,5 +0,0 @@
# Load the rails application.
require File.expand_path('../application', __FILE__)
# Initialize the rails application.
Dummy::Application.initialize!

View file

@ -1,23 +0,0 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
end

View file

@ -1,36 +0,0 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
end

View file

@ -1,7 +0,0 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View file

@ -1,4 +0,0 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View file

@ -1,16 +0,0 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View file

@ -1,5 +0,0 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

View file

@ -1,3 +0,0 @@
require_relative '../../../dummy/lib/test_view'
Peek.into TestView

View file

@ -1,12 +0,0 @@
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
Rails.application.config.secret_key_base = '94c84623660ec36e05fa8584f7dad694c280aae1894eedb73fc017564933a4eea53962e7d8aba5dc33be928373045982ec9af92cef8150bb9576eaa55ad36d5b'

View file

@ -1,3 +0,0 @@
# Be sure to restart your server when you modify this file.
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'

View file

@ -1,14 +0,0 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

View file

@ -1,23 +0,0 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View file

@ -1,8 +0,0 @@
Dummy::Application.routes.draw do
mount Peek::Railtie => 'peek'
get '/enabled' => 'home#enabled'
get '/disabled' => 'home#disabled'
root to: 'home#enabled'
end

View file

@ -1,18 +0,0 @@
require 'concurrent/atomics'
class TestView < Peek::Views::View
class << self
attr_accessor :counter
end
self.counter = Concurrent::AtomicFixnum.new
def results
{
number: self.class.counter.increment
}
end
def partial_path
"peek/test_view"
end
end

View file

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>

View file

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>

View file

@ -1,57 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>

View file

@ -1,37 +0,0 @@
require 'test_helper'
describe Peek::Views::View do
before do
@view = Peek::Views::View.new
end
describe "partial path" do
it "should return correct partial class" do
assert_equal 'peek/views/view', @view.partial_path
end
end
describe "dom_id" do
it "should return correct dom_id" do
assert_equal 'peek-view-view', @view.dom_id
end
end
describe "key" do
it "should return correct key" do
assert_equal 'view', @view.key
end
end
describe "context" do
it "should return correct context_id" do
assert_equal 'peek-context-view', @view.context_id
end
end
describe "toggling off and on" do
it "should be enabled by default" do
assert @view.enabled?
end
end
end

View file

@ -1,69 +0,0 @@
require 'test_helper'
class Staff < Peek::Views::View
def initialize(options = {})
@username = options.delete(:username)
end
def username
@username
end
def enabled?
!!@username
end
end
describe Peek do
describe "enabled?" do
it "should not be enabled in test" do
refute Peek.enabled?
end
end
describe "env" do
it "should return the current environment" do
assert_equal 'test', Peek.env
end
end
describe "views" do
before do
Peek.reset
end
it "should have none by default" do
assert_equal [], Peek.views
end
it "should be able to append views" do
Peek.into Staff, username: 'dewski'
assert_kind_of Staff, Peek.views.first
end
it "should be able to append views with options" do
Peek.into Staff, username: 'dewski'
@staff = Peek.views.first
assert_kind_of Staff, @staff
assert_equal 'dewski', @staff.username
end
it "should only return enabled views" do
Peek.into Staff, username: false
assert_equal [], Peek.views
end
end
describe "reset" do
before do
Peek.reset
end
it "should clear any current views" do
Peek.into Staff, username: 'dewski'
assert_kind_of Staff, Peek.views.first
Peek.reset
assert_equal [], Peek.views
end
end
end

View file

@ -1,22 +0,0 @@
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../dummy/config/environment.rb', __FILE__)
require 'rails/test_help'
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# Load fixtures from the engine
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end
require 'minitest/autorun'
begin
require 'turn'
rescue LoadError
# Not installed.
end