Permalink
Browse files

linter and coverage

  • Loading branch information...
serby committed Nov 22, 2013
1 parent b6f4aec commit 29a6fefcc0757891d43d192045e2faad97d319bd
View
@@ -32,5 +32,4 @@ Icon?
/pids
*.sock
-# ZSH Cake plugin cache
-/.cake_task_cache
+/coverage
View
@@ -0,0 +1,2 @@
+node_modules
+coverage
View
@@ -0,0 +1,41 @@
+{ "asi": true
+, "boss": true
+, "browser": true
+, "camelcase": true
+, "curly": false
+, "devel": false
+, "devel": true
+, "eqeqeq": true
+, "eqnull": true
+, "es5": false
+, "evil": false
+, "immed": false
+, "indent": 2
+, "jquery": true
+, "latedef": false
+, "laxbreak": true
+, "laxcomma": true
+, "maxcomplexity": 6
+, "maxdepth": 4
+, "maxstatements": 25
+, "maxlen": 120
+, "newcap": true
+, "node": true
+, "noempty": false
+, "nonew": true
+, "quotmark": "single"
+, "nonew": true
+, "predef":
+ [ "describe"
+ , "it"
+ , "before"
+ , "beforeEach"
+ , "after"
+ , "afterEach"
+ ]
+, "smarttabs": true
+, "strict": false
+, "trailing": false
+, "undef": true
+, "unused": true
+}
View
@@ -1,12 +0,0 @@
-test:
- @./node_modules/.bin/mocha \
- -r should \
- -R spec
-
-lint-changed:
- @jshint `git status --porcelain | sed -e "s/^...//g"`
-
-lint:
- @jshint lib test
-
-.PHONY: test lint lint-changed
@@ -1 +1 @@
-alert(document.location);
+alert(document.location)
@@ -1,13 +1,12 @@
var version = '0.1'
, connect = require('connect')
, versionator = require('../../')
- ;
connect(
versionator.createBasic('v' + version).middleware,
connect.static(__dirname + '/public', { maxAge: 2592000000 }),
function(req, res) {
- res.setHeader('Content-Type', 'text/html');
- res.end('<script src="/js/v' + version + '/example.js"></script>');
+ res.setHeader('Content-Type', 'text/html')
+ res.end('<script src="/js/v' + version + '/example.js"></script>')
}
-).listen(3000);
+).listen(3000)
@@ -1,14 +1,13 @@
-var
- express = require('express'),
+var express = require('express'),
stylus = require('stylus'),
versionator = require('../../'),
- app = module.exports = express.createServer();
+ app = module.exports = express.createServer()
-app.version = '0.1';
+app.version = '0.1'
versionator.createMapFromPath(__dirname + '/public', function(error, staticFileMap) {
- var mappedVersion = versionator.createMapped(staticFileMap);
+ var mappedVersion = versionator.createMapped(staticFileMap)
// Define a custom compile so versionPath can be got from inside the .styl
function stylusCompile(str, path) {
@@ -17,15 +16,15 @@ versionator.createMapFromPath(__dirname + '/public', function(error, staticFileM
.set('warn', true)
.set('compress', true)
.define('versionPath', function(urlPath) {
- return new stylus.nodes.Literal('url(' + mappedVersion.versionPath(urlPath) + ')');
- });
+ return new stylus.nodes.Literal('url(' + mappedVersion.versionPath(urlPath) + ')')
+ })
}
// Configuration
app.configure(function(){
app.locals({
versionPath: mappedVersion.versionPath
- });
+ })
app
.set('views', __dirname + '/views')
@@ -35,28 +34,25 @@ versionator.createMapFromPath(__dirname + '/public', function(error, staticFileM
.use(mappedVersion.middleware)
.use(stylus.middleware({
src: __dirname + '/public/',
- compile: stylusCompile }))
+ compile: stylusCompile
+ }))
.use(app.router)
- .use(express.static(__dirname + '/public', { maxAge: 2592000000 }));
- });
-
-
-
+ .use(express.static(__dirname + '/public', { maxAge: 2592000000 }))
+ })
app.configure('development', function(){
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
- });
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
+ })
// Routes
app.get('/', function(req, res){
res.render('index', {
layout: false,
title: 'Versionator'
- });
- });
-
- app.listen(3000);
- console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
+ })
+ })
-});
+ app.listen(3000)
+ console.log('Express server listening on port %d in %s mode', app.address().port, app.settings.env)
+})
View
@@ -2,18 +2,18 @@ var express = require('express')
, stylus = require('stylus')
, versionator = require('../../')
, app = module.exports = express.createServer()
- ;
-app.version = '0.1';
+
+app.version = '0.1'
// Configuration
app.configure(function(){
- var basic = versionator.createBasic('v' + app.version);
+ var basic = versionator.createBasic('v' + app.version)
app.locals({
versionPath: basic.versionPath
- });
+ })
// Define a custom compile so version can be got from inside the .styl
function stylusCompile(str, path) {
@@ -22,8 +22,8 @@ app.configure(function(){
.set('warn', true)
.set('compress', true)
.define('versionPath', function(urlPath) {
- return new stylus.nodes.Literal('url(' + basic.versionPath(urlPath) + ')');
- });
+ return new stylus.nodes.Literal('url(' + basic.versionPath(urlPath) + ')')
+ })
}
app
@@ -34,23 +34,24 @@ app.configure(function(){
.use(basic.middleware)
.use(stylus.middleware({
src: __dirname + '/public/',
- compile: stylusCompile }))
+ compile: stylusCompile
+ }))
.use(app.router)
- .use(express.static(__dirname + '/public', { maxAge: 2592000000 }));
-});
+ .use(express.static(__dirname + '/public', { maxAge: 2592000000 }))
+})
app.configure('development', function(){
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
-});
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
+})
// Routes
app.get('/', function(req, res){
res.render('index', {
layout: false,
title: 'Versionator'
- });
-});
+ })
+})
-app.listen(3000);
-console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
+app.listen(3000)
+console.log('Express server listening on port %d in %s mode', app.address().port, app.settings.env)
@@ -1 +1 @@
-alert('Example script loaded');
+alert('Example script loaded')
View
@@ -1,4 +1,4 @@
-module.exports.create = require('./lib/middleware/basic');
-module.exports.createBasic = require('./lib/middleware/basic');
-module.exports.createMapped = require('./lib/middleware/mapped');
-module.exports.createMapFromPath = require('./lib/map-path');
+module.exports.create = require('./lib/middleware/basic')
+module.exports.createBasic = require('./lib/middleware/basic')
+module.exports.createMapped = require('./lib/middleware/mapped')
+module.exports.createMapFromPath = require('./lib/map-path')
View
@@ -1,19 +1,18 @@
-var url = require('url')
- , path = require('path');
+var path = require('path')
module.exports = function(version) {
if (!version) {
- throw new Error('version is required');
+ throw new Error('version is required')
}
function versionSinglePath(urlPath) {
- urlPath = urlPath.toString();
- var pos = urlPath.lastIndexOf('/');
+ urlPath = urlPath.toString()
+ var pos = urlPath.lastIndexOf('/')
if (pos !== -1) {
- return path.normalize(urlPath.substring(0, pos) + '/' + version + urlPath.substring(pos)).replace(/\\/g, '/');
+ return path.normalize(urlPath.substring(0, pos) + '/' + version + urlPath.substring(pos)).replace(/\\/g, '/')
} else {
- return urlPath;
+ return urlPath
}
}
@@ -25,33 +24,33 @@ module.exports = function(version) {
versionPath: function(urlPath) {
if (!Array.isArray(urlPath)) {
- return versionSinglePath(urlPath);
+ return versionSinglePath(urlPath)
}
return urlPath.map(function(singleUrl) {
- return versionSinglePath(singleUrl);
- });
+ return versionSinglePath(singleUrl)
+ })
},
middleware: function(req, res, next) {
if (req.method !== 'GET') {
- return next();
+ return next()
}
// Ensure version is a string
- version = '' + version;
+ version = '' + version
- var vPos = req.url.indexOf(version);
+ var vPos = req.url.indexOf(version)
// If version isn't in path then move on.
if (vPos === -1) {
- return next();
+ return next()
}
// Rebuild the URL without the version and set the request url.
- req.url = req.url.substring(0, vPos - 1) + req.url.substring(vPos + version.length);
- next();
+ req.url = req.url.substring(0, vPos - 1) + req.url.substring(vPos + version.length)
+ next()
}
- };
-};
+ }
+}
Oops, something went wrong.

0 comments on commit 29a6fef

Please sign in to comment.