surfnperf 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -6
- data/lib/surfnperf.rb +15 -0
- data/lib/surfnperf/extension.rb +14 -0
- data/lib/utils.rb +8 -0
- data/vendor/assets/javascripts/surfnperf.js +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c65e50b4eeb919e418862f9841b3f3ed7e6dd80
|
4
|
+
data.tar.gz: 6e81022eac756e5eac332ebd2ed73a939f8d5488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c411bcec8cf7ac6d148d0addb2074612ffac622078e9d0ba09cc363e1fabaa73dd80b74a99cea64c7e301abe86510b0167dc144b4b8e1143a1f107a40574062
|
7
|
+
data.tar.gz: 4f847eb324ef4a10c62a6c25d7bd3ebc8a30ea4083b34af78324f6126953677b0fd4725fd16836f03c46c8d128bb834e748ef4dd399351e7e402e8c587b4ab34
|
data/README.md
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
-
Surf-N-Perf
|
1
|
+
Surf-N-Perf
|
2
2
|
==============
|
3
3
|
|
4
|
-
Micro-library for gathering frontend web page performance data.
|
4
|
+
Micro-library for gathering frontend web page performance data.
|
5
|
+
|
6
|
+
Surf-N-Perf provides a simple to use API to gather [User Timing](http://www.w3.org/TR/user-timing/) and other important performance data in any browser.
|
7
|
+
|
8
|
+
Tired of typing `window.performance.getEntriesByName('foo')[0].startTime;` with your User Timing Polyfill?
|
9
|
+
|
10
|
+
With Surf-N-Perf, all you need is `surfnperf.getMark('foo')';`, and that's just the start!
|
11
|
+
|
12
|
+
Check out the [JavaScript API](https://github.com/Comcast/Surf-N-Perf/wiki/JavaScript-API) to see all of its features and the [full documentation](http://comcast.github.io/Surf-N-Perf/docs/SurfNPerf.html) for a list of methods & how to use them.
|
13
|
+
|
14
|
+
Available as both an [NPM Module](https://www.npmjs.com/package/surfnperf) and a [Ruby Gem](https://rubygems.org/gems/surfnperf).
|
5
15
|
|
6
16
|
[![Build Status](https://travis-ci.org/Comcast/Surf-N-Perf.svg?branch=master)](https://travis-ci.org/Comcast/Surf-N-Perf)
|
7
17
|
|
@@ -63,7 +73,7 @@ Details in the [JavaScript API](https://github.com/Comcast/Surf-N-Perf/wiki/Java
|
|
63
73
|
|
64
74
|
### Using within a Rails project
|
65
75
|
|
66
|
-
The [surfnperf Ruby Gem](https://rubygems.org/gems/surfnperf) allows you to quickly & easily integrate Surf-N-Perf into your Rails projects. To include the necessary files, add `surfnperf` to your `Gemfile`:
|
76
|
+
The [surfnperf Ruby Gem](https://rubygems.org/gems/surfnperf) allows you to quickly & easily integrate Surf-N-Perf into your [Rails](http://rubyonrails.org/) projects. To include the necessary files, add `surfnperf` to your `Gemfile`:
|
67
77
|
|
68
78
|
```ruby
|
69
79
|
gem 'surfnperf'
|
@@ -83,9 +93,40 @@ The necessary script for the ```<head>``` of your HTML document is also availabl
|
|
83
93
|
|
84
94
|
Those 3 lines of code are all your need to get started using Surf-N-Perf in Rails!
|
85
95
|
|
96
|
+
|
97
|
+
### Using within a Middleman project
|
98
|
+
|
99
|
+
The [surfnperf Ruby Gem](https://rubygems.org/gems/surfnperf) also allows you to quickly & easily integrate Surf-N-Perf into your [Middleman](https://middlemanapp.com/) projects. Instructions are similar to the Rails instructions above, with one extra step. Start by adding at least v1.1.0 of `surfnperf` to your Middleman project's `Gemfile`:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
gem "surfnperf", ">=1.1.0"
|
103
|
+
```
|
104
|
+
|
105
|
+
After a `$ bundle install`, you'll be able to include the [main JavaScript file](https://github.com/Comcast/Surf-N-Perf/blob/master/surfnperf.js) in your JavaScript manifest by simply adding:
|
106
|
+
|
107
|
+
```
|
108
|
+
//= require surfnperf
|
109
|
+
```
|
110
|
+
|
111
|
+
The necessary script for the ```<head>``` of your HTML document is also available to you via a [custom defined helper](https://middlemanapp.com/basics/helper_methods/#custom-defined-helpers) that you can include in the appropriate layout file for your page, such as `source/layouts/layout.erb` by adding this line:
|
112
|
+
|
113
|
+
```erb
|
114
|
+
<%= surfnperf_head %>
|
115
|
+
```
|
116
|
+
|
117
|
+
You will also have to configure the extension for that helper to be recognized by Middleman by adding this line to your `config.rb`:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
activate :surfnperf
|
121
|
+
```
|
122
|
+
|
123
|
+
You'll want to do that **outside** of your build-specific configuration (i.e. outside the `configure :build do` block) so that it is available when you run `$ bundle exec middleman server`
|
124
|
+
|
125
|
+
Those 4 lines of code are all your need to get started using Surf-N-Perf in Middleman!
|
126
|
+
|
86
127
|
### Using within other Ruby projects that integrate with Sprockets
|
87
128
|
|
88
|
-
[Sprockets](https://github.com/sstephenson/sprockets) is what powers the [Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html) in Rails,
|
129
|
+
[Sprockets](https://github.com/sstephenson/sprockets) is what powers the [Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html) in Rails, Middleman, and other Ruby website tools. For these other Ruby projects that use [Sprockets](https://middlemanapp.com/advanced/asset_pipeline/), integration is similar to the Rails instructions above, with one extra step:
|
89
130
|
|
90
131
|
Add `surfnperf` to your `Gemfile`:
|
91
132
|
|
@@ -99,7 +140,7 @@ After a `$ bundle install`, include [surfnperf.js](https://github.com/Comcast/Su
|
|
99
140
|
//= require surfnperf
|
100
141
|
```
|
101
142
|
|
102
|
-
For now, you'll have to manually include the [necessary script](#including-the-code-in-your-project) for the ```<head>``` of your HTML document.
|
143
|
+
For now, you'll have to manually include the [necessary script](#including-the-code-in-your-project) for the ```<head>``` of your HTML document.
|
103
144
|
|
104
145
|
## Running Tests & Other Development Tools
|
105
146
|
|
@@ -110,6 +151,7 @@ Install the dependencies by executing this command from the root of your Surf-N-
|
|
110
151
|
```bash
|
111
152
|
$ npm install
|
112
153
|
```
|
154
|
+
If Grunt CLI has not been already installed, [go install it](http://gruntjs.com/getting-started).
|
113
155
|
|
114
156
|
And then run the tests, JSHint, beautify your code & generate the minified file with:
|
115
157
|
|
@@ -119,7 +161,7 @@ $ grunt dev
|
|
119
161
|
|
120
162
|
By default, it will run the tests using [PhantomJS](http://phantomjs.org/). You can also run the tests in any browser by going to http://localhost:9876/
|
121
163
|
|
122
|
-
|
164
|
+
The `grunt dev` process will watch for file updates, so as you modify surfnperf.js or the test files, it will automatically run jshint, jsbeautifier, uglify & the tests. To stop the watch process, press control + C
|
123
165
|
|
124
166
|
## License
|
125
167
|
|
data/lib/surfnperf.rb
CHANGED
@@ -4,17 +4,32 @@ module SurfNPerf
|
|
4
4
|
if rails?
|
5
5
|
register_rails_engine
|
6
6
|
end
|
7
|
+
if middleman?
|
8
|
+
regsister_middleman_extension
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
def rails?
|
10
13
|
defined?(::Rails)
|
11
14
|
end
|
12
15
|
|
16
|
+
def middleman?
|
17
|
+
defined?(::Middleman)
|
18
|
+
end
|
19
|
+
|
13
20
|
private
|
14
21
|
|
15
22
|
def register_rails_engine
|
16
23
|
require 'surfnperf/rails'
|
17
24
|
end
|
25
|
+
|
26
|
+
def regsister_middleman_extension
|
27
|
+
require 'middleman_extension'
|
28
|
+
::Middleman::Extensions.register(:surfnperf) do
|
29
|
+
require "surfnperf/extension"
|
30
|
+
::Middleman::SurfNPerf
|
31
|
+
end
|
32
|
+
end
|
18
33
|
end
|
19
34
|
end
|
20
35
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../utils'
|
2
|
+
# Extension namespace
|
3
|
+
module Middleman
|
4
|
+
class SurfNPerf < Extension
|
5
|
+
|
6
|
+
helpers do
|
7
|
+
def surfnperf_head
|
8
|
+
filePath = File.join(::SurfNPerf::Utils.gem_libdir,'../app/views/surfnperf/_head.html.erb')
|
9
|
+
f = File.open(filePath, 'r')
|
10
|
+
f.read()
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/utils.rb
ADDED
@@ -26,7 +26,7 @@
|
|
26
26
|
define('surfnperf', factory);
|
27
27
|
} else if(typeof exports === 'object') {
|
28
28
|
// For Browserify
|
29
|
-
module.exports = factory(
|
29
|
+
module.exports = factory();
|
30
30
|
} else {
|
31
31
|
// Browser global if not using Require.js or Browserify
|
32
32
|
root.surfnperf = factory();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surfnperf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Riviello
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: Micro-library for gathering frontend web page performance data
|
41
|
+
description: Micro-library for gathering frontend web page performance data. Includes
|
42
|
+
helpers for Rails, Middleman & other frameworks that use Sprockets.
|
42
43
|
email:
|
43
44
|
- john_riviello@comcast.com
|
44
45
|
executables: []
|
@@ -48,9 +49,11 @@ files:
|
|
48
49
|
- README.md
|
49
50
|
- app/views/surfnperf/_head.html.erb
|
50
51
|
- lib/surfnperf.rb
|
52
|
+
- lib/surfnperf/extension.rb
|
51
53
|
- lib/surfnperf/rails.rb
|
54
|
+
- lib/utils.rb
|
52
55
|
- vendor/assets/javascripts/surfnperf.js
|
53
|
-
homepage:
|
56
|
+
homepage: http://comcast.github.io/Surf-N-Perf/
|
54
57
|
licenses:
|
55
58
|
- MIT
|
56
59
|
metadata: {}
|