glimpse 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +37 -22
- data/app/assets/stylesheets/glimpse/vendor/tipsy.scss +21 -23
- data/app/assets/stylesheets/glimpse.scss +10 -0
- data/app/views/glimpse/_bar.html.erb +3 -1
- data/app/views/glimpse/_results.html.erb +6 -0
- data/lib/glimpse/version.rb +1 -1
- data/lib/glimpse/views/view.rb +59 -0
- data/test/glimpse/views/view_test.rb +18 -0
- data/test/glimpse_test.rb +4 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/dewski/glimpse.png?branch=master)](https://travis-ci.org/dewski/glimpse)
|
4
4
|
|
5
|
-
Provide a glimpse into your Rails application.
|
5
|
+
Provide a glimpse into your Rails application.
|
6
|
+
|
7
|
+
![Preview](https://f.cloud.github.com/assets/79995/244991/03cee1fa-8a74-11e2-8e33-283cf1298a60.png)
|
8
|
+
|
9
|
+
This was originally built at GitHub to help us get insight into what's going
|
10
|
+
on, this is just an extraction so other Rails applications can have the same.
|
6
11
|
|
7
12
|
## Installation
|
8
13
|
|
@@ -20,17 +25,8 @@ Or install it yourself as:
|
|
20
25
|
|
21
26
|
## Usage
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
```
|
26
|
-
rails generate glimpse:install
|
27
|
-
```
|
28
|
-
|
29
|
-
This will create a file at `config/initializers/glimpse.rb` which will give you
|
30
|
-
example views to include into your Glimpse bar.
|
31
|
-
|
32
|
-
Feel free to pick and choose from the list or create your own. The order they
|
33
|
-
are added to Glimpse, the order they will appear in your bar.
|
28
|
+
To pick which views you want to see in your Glimpse bar, just create a file at
|
29
|
+
`config/initializers/glimpse.rb` that has a list of the views you'd like to see:
|
34
30
|
|
35
31
|
```ruby
|
36
32
|
Glimpse.into Glimpse::Views::Git, :nwo => 'github/janky'
|
@@ -39,7 +35,10 @@ Glimpse.into Glimpse::Views::Mysql2
|
|
39
35
|
Glimpse.into Glimpse::Views::Redis
|
40
36
|
```
|
41
37
|
|
42
|
-
|
38
|
+
Feel free to pick and choose from the list or create your own. The order they
|
39
|
+
are added to Glimpse, the order they will appear in your bar.
|
40
|
+
|
41
|
+
Next, to render the Glimpse bar in your application just add the following snippet
|
43
42
|
just before the opening `<body>` tag in your application layout.
|
44
43
|
|
45
44
|
```erb
|
@@ -83,7 +82,7 @@ It will look something like:
|
|
83
82
|
```
|
84
83
|
|
85
84
|
Now that you have the partials in your application, you will need to include the
|
86
|
-
|
85
|
+
CSS and JS that help make Glimpse work :sparkles:
|
87
86
|
|
88
87
|
In `app/assets/stylesheets/application.scss`:
|
89
88
|
|
@@ -99,13 +98,16 @@ In `app/assets/javascripts/application.coffee`:
|
|
99
98
|
#= require glimpse
|
100
99
|
```
|
101
100
|
|
101
|
+
Note: Each additional view my have their own CSS and JS you need to require.
|
102
|
+
|
102
103
|
## Using Glimpse with PJAX
|
103
104
|
|
104
|
-
When using PJAX requests won't render
|
105
|
-
up not including the required results partial.
|
106
|
-
if you're using the
|
105
|
+
When using PJAX in your application, by default requests won't render the
|
106
|
+
application layout which ends up not including the required results partial.
|
107
|
+
It's fairly simple to get this working with PJAX if you're using the
|
108
|
+
[pjax_rails](https://github.com/rails/pjax_rails) gem.
|
107
109
|
|
108
|
-
Create a new layout at `app/views/layouts/
|
110
|
+
Create a new layout at `app/views/layouts/glimpse.html.erb`:
|
109
111
|
|
110
112
|
```erb
|
111
113
|
<%= yield %>
|
@@ -117,13 +119,13 @@ Now you'll just need use the PJAX layout:
|
|
117
119
|
```ruby
|
118
120
|
class ApplicationController < ActionController::Base
|
119
121
|
def pjax_layout
|
120
|
-
'
|
122
|
+
'glimpse'
|
121
123
|
end
|
122
124
|
end
|
123
125
|
```
|
124
126
|
|
125
|
-
You're done! Now every time a PJAX request is made, the Glimpse bar will update
|
126
|
-
the
|
127
|
+
You're done! Now every time a PJAX request is made, the Glimpse bar will update
|
128
|
+
with the Glimpse results of the PJAX request.
|
127
129
|
|
128
130
|
## Access Control
|
129
131
|
|
@@ -140,7 +142,7 @@ class ApplicationController < ActionController::Base
|
|
140
142
|
end
|
141
143
|
```
|
142
144
|
|
143
|
-
## Available Glimpse
|
145
|
+
## Available Glimpse items
|
144
146
|
|
145
147
|
- [glimpse-dalli](https://github.com/dewski/glimpse-dalli)
|
146
148
|
- [glimpse-git](https://github.com/dewski/glimpse-git)
|
@@ -148,9 +150,22 @@ end
|
|
148
150
|
- [glimpse-mysql2](https://github.com/dewski/glimpse-mysql2)
|
149
151
|
- [glimpse-pg](https://github.com/dewski/glimpse-pg)
|
150
152
|
- [glimpse-redis](https://github.com/dewski/glimpse-redis)
|
153
|
+
- [glimpse-resque](https://github.com/dewski/glimpse-resque)
|
151
154
|
- Navigation Time :soon:
|
152
155
|
- Unicorn :soon:
|
153
156
|
|
157
|
+
## Creating your own Glimpse item
|
158
|
+
|
159
|
+
Each Glimpse item is a self contained Rails engine which gives you the power to
|
160
|
+
use all features of Ruby on Rails to dig in deep within your application and
|
161
|
+
report it back to the Glimpse bar. A Glimpse item is just a custom class that
|
162
|
+
is responsible for fetching and building the data that should be reported back
|
163
|
+
to the user.
|
164
|
+
|
165
|
+
There are still some docs to be written, but if you'd like to checkout a simple
|
166
|
+
example of how to create your own, just checkout [glimpse-git](https://github.com/dewski/glimpse-git).
|
167
|
+
To just look at an example view, there is [Glimpse::Views::Git](https://github.com/dewski/glimpse-git/blob/master/lib/glimpse/views/git.rb).
|
168
|
+
|
154
169
|
## Contributing
|
155
170
|
|
156
171
|
1. Fork it
|
@@ -1,24 +1,22 @@
|
|
1
|
-
|
2
|
-
.tipsy {
|
3
|
-
.tipsy-inner { background-color: #000; color: #FFF; max-width: 200px; padding: 5px 8px 4px 8px; text-align: center; }
|
1
|
+
.tipsy { font-size: 10px; position: absolute; padding: 5px; z-index: 100000; }
|
2
|
+
.tipsy-inner { background-color: #000; color: #FFF; max-width: 200px; padding: 5px 8px 4px 8px; text-align: center; }
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
4
|
+
/* Rounded corners */
|
5
|
+
.tipsy-inner { border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
|
6
|
+
|
7
|
+
.tipsy-arrow { position: absolute; width: 0; height: 0; line-height: 0; border: 5px dashed #000; }
|
8
|
+
|
9
|
+
/* Rules to colour arrows */
|
10
|
+
.tipsy-arrow-n { border-bottom-color: #000; }
|
11
|
+
.tipsy-arrow-s { border-top-color: #000; }
|
12
|
+
.tipsy-arrow-e { border-left-color: #000; }
|
13
|
+
.tipsy-arrow-w { border-right-color: #000; }
|
14
|
+
|
15
|
+
.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; }
|
16
|
+
.tipsy-nw .tipsy-arrow { top: 0; left: 10px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent;}
|
17
|
+
.tipsy-ne .tipsy-arrow { top: 0; right: 10px; border-bottom-style: solid; border-top: none; border-left-color: transparent; border-right-color: transparent;}
|
18
|
+
.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; }
|
19
|
+
.tipsy-sw .tipsy-arrow { bottom: 0; left: 10px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
|
20
|
+
.tipsy-se .tipsy-arrow { bottom: 0; right: 10px; border-top-style: solid; border-bottom: none; border-left-color: transparent; border-right-color: transparent; }
|
21
|
+
.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; }
|
22
|
+
.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; }
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
.hidden {
|
11
11
|
display: none;
|
12
|
+
visibility: visible;
|
12
13
|
}
|
13
14
|
|
14
15
|
&.disabled {
|
@@ -55,4 +56,13 @@
|
|
55
56
|
strong {
|
56
57
|
color: #fff;
|
57
58
|
}
|
59
|
+
|
60
|
+
.view {
|
61
|
+
margin-right: 15px;
|
62
|
+
float: left;
|
63
|
+
|
64
|
+
&:last-child {
|
65
|
+
margin-right: 0;
|
66
|
+
}
|
67
|
+
}
|
58
68
|
}
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<div id="glimpse" class="<%= Glimpse.env %><%= ' disabled' if cookies[:glimpse] == 'false' %>">
|
3
3
|
<div class="wrapper">
|
4
4
|
<% Glimpse.views.each do |view| %>
|
5
|
-
<%=
|
5
|
+
<div id="<%= view.dom_id %>" class="view">
|
6
|
+
<%= render view.partial_path, :view => view %>
|
7
|
+
</div>
|
6
8
|
<% end %>
|
7
9
|
</div>
|
8
10
|
</div>
|
data/lib/glimpse/version.rb
CHANGED
data/lib/glimpse/views/view.rb
CHANGED
@@ -7,22 +7,81 @@ module Glimpse
|
|
7
7
|
setup_subscribers
|
8
8
|
end
|
9
9
|
|
10
|
+
# Conditionally enable views based on any gathered data. Helpful
|
11
|
+
# if you don't want views to show up when they return 0 or are
|
12
|
+
# touched during the request.
|
13
|
+
#
|
14
|
+
# Returns true.
|
10
15
|
def enabled?
|
11
16
|
true
|
12
17
|
end
|
13
18
|
|
19
|
+
# The path to the partial that will be rendered to the Glimpse bar.
|
20
|
+
#
|
21
|
+
# Examples:
|
22
|
+
#
|
23
|
+
# Glimpse::Views::PerformanceBar.partial_path => "glimpse/views/performance_bar"
|
24
|
+
# CustomResque.partial_path => "performance_bar"
|
25
|
+
#
|
26
|
+
# Returns String.
|
14
27
|
def partial_path
|
15
28
|
self.class.to_s.underscore
|
16
29
|
end
|
17
30
|
|
31
|
+
# The defer key that is derived from the classname.
|
32
|
+
#
|
33
|
+
# Examples:
|
34
|
+
#
|
35
|
+
# Glimpse::Views::PerformanceBar => "performance-bar"
|
36
|
+
# Glimpse::Views::Resque => "resque"
|
37
|
+
#
|
38
|
+
# Returns String.
|
18
39
|
def defer_key
|
19
40
|
self.class.to_s.split('::').last.underscore.gsub(/\_/, '-')
|
20
41
|
end
|
21
42
|
|
43
|
+
# The context dom id that is derived from the classname.
|
44
|
+
#
|
45
|
+
# Examples:
|
46
|
+
#
|
47
|
+
# Glimpse::Views::PerformanceBar => "glimpse-context-performance-bar"
|
48
|
+
# Glimpse::Views::Resque => "glimpse-context-resque"
|
49
|
+
#
|
50
|
+
# Returns String.
|
51
|
+
def context_dom_id
|
52
|
+
"glimpse-context-#{defer_key}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# The wrapper ID for the individual view in the Glimpse bar.
|
56
|
+
#
|
57
|
+
# Returns String.
|
58
|
+
def dom_id
|
59
|
+
"glimpse-view-#{defer_key}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Additional context for any view to render tooltips for.
|
63
|
+
#
|
64
|
+
# Returns Hash.
|
65
|
+
def context
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
|
69
|
+
def context?
|
70
|
+
context.any?
|
71
|
+
end
|
72
|
+
|
73
|
+
# The data results that are inserted at the end of the request for use in
|
74
|
+
# deferred placeholders in the Glimpse the bar.
|
75
|
+
#
|
76
|
+
# Returns Hash.
|
22
77
|
def results
|
23
78
|
{}
|
24
79
|
end
|
25
80
|
|
81
|
+
def results?
|
82
|
+
results.any?
|
83
|
+
end
|
84
|
+
|
26
85
|
def subscribe(*args)
|
27
86
|
ActiveSupport::Notifications.subscribe(*args) do |name, start, finish, id, payload|
|
28
87
|
yield name, start, finish, id, payload
|
@@ -11,6 +11,24 @@ describe Glimpse::Views::View do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
describe "dom_id" do
|
15
|
+
it "should return correct dom_id" do
|
16
|
+
assert_equal 'glimpse-view-view', @view.dom_id
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "defer_key" do
|
21
|
+
it "should return correct defer_key" do
|
22
|
+
assert_equal 'view', @view.defer_key
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "context" do
|
27
|
+
it "should return correct context_dom_id" do
|
28
|
+
assert_equal 'glimpse-context-view', @view.context_dom_id
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
14
32
|
describe "toggling off and on" do
|
15
33
|
it "should be enabled by default" do
|
16
34
|
assert @view.enabled?
|
data/test/glimpse_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimpse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|