Permalink
Browse files

initial commit

  • Loading branch information...
1 parent be38488 commit 6ccf1727de320136ab1c3047beba90bbe8b3b5a0 @hueniverse hueniverse committed Feb 9, 2013
Showing with 203 additions and 3 deletions.
  1. +18 −0 .gitignore
  2. +5 −0 .travis.yml
  3. +24 −0 LICENSE
  4. +33 −0 Makefile
  5. +6 −3 README.md
  6. +1 −0 index.js
  7. +27 −0 lib/index.js
  8. +37 −0 package.json
  9. +52 −0 test/index.js
View
@@ -0,0 +1,18 @@
+.idea
+*.iml
+npm-debug.log
+dump.rdb
+node_modules
+results.tap
+results.xml
+npm-shrinkwrap.json
+config.json
+.DS_Store
+*/.DS_Store
+*/*/.DS_Store
+._*
+*/._*
+*/*/._*
+coverage.*
+lib-cov
+
View
@@ -0,0 +1,5 @@
+language: node_js
+
+node_js:
+ - 0.8
+
View
24 LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2013, Walmart.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Walmart nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL WALMART BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -0,0 +1,33 @@
+REPORTER = dot
+
+test:
+ @#lib-cov
+ @NODE_ENV=test ./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --ignore-leaks --timeout 3000
+ @#$(MAKE) rm-lib-cov
+
+tests: test
+
+lib-cov: rm-lib-cov
+ @jscoverage lib lib-cov
+
+rm-lib-cov:
+ @rm -rf ./lib-cov/
+
+test-cov: lib-cov
+ @$(MAKE) test TEST_COV=1 REPORTER=json-cov > coverage.json
+ @$(MAKE) rm-lib-cov
+
+test-cov-html: lib-cov
+ @$(MAKE) test TEST_COV=1 REPORTER=html-cov > coverage.html
+ @$(MAKE) rm-lib-cov
+
+tap: lib-cov
+ @NODE_ENV=test ./node_modules/.bin/mocha -R tap > results.tap
+ @$(MAKE) rm-lib-cov
+
+unit:
+ @#lib-cov
+ @NODE_ENV=test ./node_modules/.bin/mocha --recursive -R xunit --ignore-leaks > results.xml --timeout 3000
+ @#$(MAKE) rm-lib-cov
+
+.PHONY: test tap test-cov test-cov-html unit lib-cov rm-lib-cov
View
9 README.md 100644 → 100755
@@ -1,4 +1,7 @@
-scooter
-=======
+<a href="https://github.com/walmartlabs/blammo"><img src="https://raw.github.com/walmartlabs/blammo/master/images/from.png" align="right" /></a>
+![scooter Logo](/images/scooter.png)
+
+User-agent information plugin for [**hapi**](https://github.com/walmartlabs/hapi)
+
+[![Build Status](https://secure.travis-ci.org/walmartlabs/scooter.png)](http://travis-ci.org/walmartlabs/scooter)
-User-agent information plugin for hapi
View
@@ -0,0 +1 @@
+module.exports = require('./lib');
View
@@ -0,0 +1,27 @@
+// Load modules
+
+var Hoek = require('hoek');
+
+
+// Declare internals
+
+var internals = {};
+
+internals.config = {
+};
+
+
+exports.register = function (pack, options, next) {
+
+ Hoek.merge(internals.config, options);
+
+ pack.ext('onRequest', internals.onRequest);
+
+ next();
+};
+
+
+internals.onRequest = function (request, next) {
+
+ next();
+};
View
@@ -0,0 +1,37 @@
+{
+ "name": "scooter",
+ "description": "User-agent information plugin for hapi",
+ "version": "0.0.0",
+ "author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",
+ "contributors": [],
+ "repository": "git://github.com/walmartlabs/scooter",
+ "main": "index",
+ "keywords": [
+ "hapi",
+ "plugin",
+ "user-agent"
+ ],
+ "engines": {
+ "node": ">=0.8.0"
+ },
+ "dependencies": {
+ "hoek": "0.4.x"
+ },
+ "devDependencies": {
+ "hapi": "0.x.x",
+ "mocha": "1.x.x",
+ "chai": "1.x.x"
+ },
+ "scripts": {
+ "test": "make test && make unit"
+ },
+ "licenses": [
+ {
+ "type": "BSD",
+ "url": "http://github.com/hueniverse/scooter/raw/master/LICENSE"
+ }
+ ],
+ "hapi": {
+ "plugin": "1.x.x"
+ }
+}
View
@@ -0,0 +1,52 @@
+// Load modules
+
+var Chai = require('chai');
+var Hapi = require('hapi');
+var Scooter = process.env.TEST_COV ? require('../lib-cov') : require('../lib');
+
+
+// Declare internals
+
+var internals = {};
+
+
+// Test shortcuts
+
+var expect = Chai.expect;
+
+
+describe('Scooter', function () {
+
+ // Wrapper is required for coverage
+
+ var plugin = {
+ name: 'scooter',
+ version: Hapi.utils.loadPackage().version,
+ hapi: {
+ plugin: '1.x.x'
+ },
+ register: Scooter.register
+ };
+
+ it('parses and sets user-agent information for an incoming request', function (done) {
+
+ var options = {
+ permissions: {
+ ext: true
+ }
+ };
+
+ var server = new Hapi.Server();
+
+ server.plugin().register(plugin, options, function (err) {
+
+ expect(err).to.not.exist;
+ server.inject({ method: 'GET', url: '/no-found' }, function (res) {
+
+ done();
+ });
+ });
+ });
+});
+
+

0 comments on commit 6ccf172

Please sign in to comment.