Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

standardise a bit, mocha tests

  • Loading branch information...
commit f776c04d293a1bd668565b820a8aeb892e9d1753 1 parent 40444b6
@rjrodger authored
View
11 .gitignore
@@ -0,0 +1,11 @@
+*~
+.DS_Store
+test/db
+*.old
+*.bak
+node_modules
+README.html
+*.off
+*-off
+.DS_Store
+npm-debug.log
View
3  .npmignore
@@ -0,0 +1,3 @@
+*~
+*.off
+*-off
View
21 LICENSE.txt
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2010 Richard Rodger
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
8 README.md
@@ -2,9 +2,9 @@
If you're using this library, feel free to contact me on twitter if you have any questions! :) [@rjrodger](http://twitter.com/rjrodger)
-Current Version: 0.0.3
+Current Version: 0.1.1
-Tested on: node 0.4 and 0.6
+Tested on: node 0.8
Glob expressions for JavaScript
@@ -78,7 +78,3 @@ The unit tests use [expresso](https://github.com/visionmedia/expresso)
The tests are in test/gex.test.js
-## Hacking around with real time charts
-
-![](http://chartaca.com/point/adb6995d-b4b3-4edf-8892-a6d1a2324831/s.gif)
-[Chartaca Hit Chart](http://chartaca.com/adb6995d-b4b3-4edf-8892-a6d1a2324831)
View
7 lib/gex.js
@@ -1,8 +1,11 @@
+/* Copyright (c) 2011-2013 Richard Rodger, MIT License */
+"use strict";
+
var _ = require('underscore')
-function Gex(gexexp) {
+function Gex(gexspec) {
var self = this
function dodgy(obj) {
@@ -123,7 +126,7 @@ function Gex(gexexp) {
return str
}
- var str = gexstr(gexexp)
+ var str = gexstr(gexspec)
var re = self.re(str)
}
View
4 man/makepackage.sh
@@ -1,4 +0,0 @@
-# run in parent of gex folder
-
-mkdir -p gex/dist
-tar -czf gex/dist/gex.tgz gex/package.json gex/README.md gex/lib/gex.js
View
12 package.json
@@ -2,14 +2,15 @@
"name": "gex",
"description": "Glob expressions for JavaScript",
"keywords": ["glob","star","question","mark","expression","regular"],
- "version": "0.0.3",
+ "version": "0.1.1",
"homepage": "https://github.com/rjrodger/gex",
"author": "Richard Rodger <richard@ricebridge.com> (http://richardrodger.com/)",
"contributors": [
"Richard Rodger <richard@ricebridge.com> (http://richardrodger.com/)"
],
+ "license": "MIT",
"dependencies": {
- "underscore": ">=1.1.4"
+ "underscore": "~1.4.4"
},
"main": "lib/gex",
"directories": {
@@ -18,5 +19,10 @@
"repository": { "type" : "git", "url" : "https://github.com/rjrodger/gex.git" },
"engines": {
"node": "*"
- }
+ },
+ "files":[
+ "README.md",
+ "LICENSE.txt",
+ "lib/gex.js"
+ ]
}
View
44 test/gex.test.js
@@ -1,15 +1,24 @@
+/* Copyright (c) 2011-2013 Richard Rodger, MIT License */
+"use strict";
+
+
+// mocha gex.test.js
+
var assert = require('assert')
-var gex = require('../lib/gex.js')
+
+var gex = require('..')
function s(obj){
return JSON.stringify(obj)
}
-module.exports = {
- happy: function() {
+
+
+describe('gex', function() {
+ it('happy', function() {
var ab = gex('ab')
assert.equal( 'ab', ab.on('ab') )
assert.equal( null, ab.on('a') )
@@ -52,25 +61,28 @@ module.exports = {
assert.equal( 'aabb', a_b.on('aabb') )
assert.equal( 'abbb', a_b.on('abbb') )
- },
+ })
- arrays: function() {
+
+ it('arrays', function() {
var a_ = gex('a*')
assert.equal( s(['ab','ac']), s(a_.on(['ab','ac'])) )
assert.equal( s(['ab','ac']), s(a_.on(['ab','dd','ac'])) )
assert.equal( s(['ab']), s(a_.on(['ab','dd','ee'])) )
assert.equal( s([]), s(a_.on(['ff','dd','ee'])) )
assert.equal( s([]), s(a_.on([])) )
- },
+ })
+
- objects: function() {
+ it('objects', function() {
var foo_ = gex('foo*')
assert.equal( s({foo:1}), s(foo_.on({foo:1})) )
assert.equal( s({foo:1}), s(foo_.on({foo:1,doo:2})) )
assert.equal( s({foo:1,food:3}), s(foo_.on({foo:1,doo:2,food:3})) )
- },
+ })
+
- dodgy: function() {
+ it('dodgy', function() {
assert.equal( null, gex().on('aaa') )
assert.equal( null, gex(null).on('aaa') )
assert.equal( null, gex(NaN).on('aaa') )
@@ -86,9 +98,10 @@ module.exports = {
assert.equal( s([]), s(g.on([null])) )
assert.equal( s([]), s(g.on([NaN])) )
assert.equal( s([]), s(g.on([undefined])) )
- },
+ })
- escapes: function() {
+
+ it('escapes', function() {
var g = gex('a**b')
assert.equal('a**b',g+'')
assert.equal('/^a\\*b$/',''+g.re())
@@ -100,13 +113,14 @@ module.exports = {
assert.equal('/^a\\?b$/',''+g.re())
assert.equal( 'a?b', g.on('a?b') )
assert.equal( null, g.on('a*?b') )
- },
+ })
+
- newlines: function() {
+ it('newlines', function() {
var g = gex('a*b')
assert.equal('/^a[\\s\\S]*b$/',''+g.re())
assert.equal( 'a\nb', g.on('a\nb') )
- }
+ })
-}
+})
Please sign in to comment.
Something went wrong with that request. Please try again.