Skip to content

Commit

Permalink
Initial add of the Edge Inspect Javascript API Code.
Browse files Browse the repository at this point in the history
  • Loading branch information
DuaneOBrien committed Jun 14, 2013
1 parent 91accdf commit c31ba02
Show file tree
Hide file tree
Showing 15 changed files with 3,465 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Contributions to this code are covered by the Adobe contributors
license agreeent. Developers must sign and submit the Adobe CLA in
order to contribute to this project.
62 changes: 62 additions & 0 deletions Examples/Grunt/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* edge-inspect
*
* Copyright (c) 2013 Adobe Systems Inc
* Licensed under the MIT license.
*/

/*jslint node:true */
/*global module */


module.exports = function (grunt) {
'use strict';

// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>'
],
options: {
jshintrc: '.jshintrc'
}
},

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp']
},

// Configuration to be run (and then tested).
edge_inspect: {
default_options: {
delay: 5000,
urls: ['http://html.adobe.com', 'http://adobe.com', 'http://html.adobe.com/edge/inspect' ]
}
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
}
});

// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'edge_inspect', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);

};
4 changes: 4 additions & 0 deletions Examples/Grunt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Grunt task
========================

This is an example of how to use the Edge Inspect JavaScript API in a Grunt task. It's not necessarily the best example of how to write a Grunt task.
42 changes: 42 additions & 0 deletions Examples/Grunt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "edge-inspect",
"description": "Grunt Task to consume Adobe's Edge Inspect JavaScript API",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Duane O'Brien",
"email": "duaneo@adobe.com",
"url": "http://html.adobe.com/edge/inspect"
},
"bugs": {
"url": ""
},
"licenses": [
{
"type": "MIT",
"url": "/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt": "~0.4.1",
"cryptojs": "~2.5.3",
"node-localstorage": "~0.3.3",
"ws": "~0.4.25"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"gruntplugin"
]
}
58 changes: 58 additions & 0 deletions Examples/Grunt/tasks/edge_inspect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* edge_inspect
*
*
* Copyright (c) 2013 Adobe Systems Inc
* Licensed under the MIT license.
*/
/*jslint node: true */
'use strict';

module.exports = function (grunt) {

// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks

grunt.registerMultiTask('edge_inspect', 'Grunt Task to consume the Edge Inspect JavaScript API.', function () {
var EdgeInspect = require('../tasks/lib/edge-inspect-api-1.0.0').EdgeInspect,
EI = new EdgeInspect(),
LocalStorage = require('node-localstorage').LocalStorage,
localStorage = new LocalStorage('./EdgeInspect'),
uuid = localStorage.getItem('uuid'),
urlCount = 0,
done = this.async(),
urls = this.data.urls,
delay = this.data.delay;

if (!uuid) {
uuid = EI.generateUUID();
localStorage.setItem('uuid', uuid);
}

function runUrl(index) {
if (urls[index] !== undefined) {
grunt.log.writeln("Sending " + urls[index] + " To Edge Inspect");
EI.sendURL(urls[index]);
urlCount = index + 1;
// Give it a few seconds to load before taking the screenshot
setTimeout(function () { EI.takeScreenshot(true, true); setTimeout(function () { runUrl(urlCount); }, delay); }, delay);
} else {
// We've hit the end. Done now.
done();
}
}

EI.subscribe(EI.CONNECTED_EVENT, function () {
// wait half a second before sending the first URL
grunt.log.writeln("Connected!");
if (urls.length > 0) {
grunt.log.writeln("Kicking off the URL chain!");
setTimeout(function () { runUrl(urlCount); }, 500);
}
});
grunt.log.writeln("Connecting");

EI.connect('Grunt Task', '5591944b-b354-404e-b714-70652e94ef03', '2bcf6b8854e61983b87b7756754ec6a694ce667aa1a2e2181c5d6dd949823d99');
});

};
Loading

0 comments on commit c31ba02

Please sign in to comment.