Permalink
Browse files

Repurpose repo

  • Loading branch information...
1 parent c3213c6 commit e9850569b7bad7f13c9f709271c3521a297ffa97 @bmavity committed May 3, 2013
Showing with 659 additions and 190 deletions.
  1. +1 −1 LICENSE
  2. +1 −1 README.md
  3. +0 −14 bin/papageno-cli.js
  4. +0 −3 entry.js
  5. +0 −3 lib/index.js
  6. +0 −43 lib/loader.js
  7. +0 −22 lib/matchers.js
  8. +0 −6 lib/papageno.js
  9. +0 −49 lib/runner.js
  10. +0 −9 module.js
  11. +11 −23 package.json
  12. +63 −0 papageno.js
  13. +8 −0 papageno.sublime-project
  14. +575 −0 papageno.sublime-workspace
  15. +0 −11 test/specCreation.js
  16. +0 −5 tester.js
View
@@ -1,4 +1,4 @@
-Copyright (c) 2010-2012 Brian Mavity (the "Original Author")
+Copyright (c) 2010-2013 Brian Mavity (the "Original Author")
MIT +no-false-attribs, +no-advertising License
View
@@ -1,2 +1,2 @@
# papageno
-## An asynchronous context/observation specification library
+## Command and Query handler discovery
View
@@ -1,14 +0,0 @@
-#!/usr/bin/env node
-
-var path = require('path')
- , cwd = process.cwd()
- , argv = require('optimist').argv
-
-require('../lib')
-
-var resolveFilePath = function(filePathSegment) {
- console.log(path.join(cwd, filePathSegment))
- return path.join(cwd, filePathSegment)
-}
-
-argv._.map(resolveFilePath).map(require)
View
@@ -1,3 +0,0 @@
-require('./module')
-
-console.log(require('./tester'))
View
@@ -1,3 +0,0 @@
-require('wagner')
-
-module.exports = exports = require('./papageno')
View
@@ -1,43 +0,0 @@
-;(function(module) { var exports = module.exports, define = module.define
- define(function() {
- var onSpecCb
-
- var onSpec = function(cb) {
- onSpecCb = cb
- }
-
- var subject = function(name, specs) {
- var observations = []
- , contextObj
-
- var context = function(description, contextFn) {
- contextObj = {
- description: description
- , fn: contextFn
- }
- }
-
- var observation = function(description, observationFn) {
- observations.push({
- description: description
- , fn: observationFn
- })
- }
-
- specs.apply({
- context: context
- , observation: observation
- })
-
- onSpecCb && onSpecCb({
- name: name
- , context: contextObj
- , observations: observations
- })
- }
-
-
- exports.onSpec = onSpec
- exports.subject = subject
- })
-})(new Module)
View
@@ -1,22 +0,0 @@
-;(function(module) { var exports = module.exports, define = module.define
- define(function() {
- var matchers = {}
-
- var addMatcher = function(name, fn) {
- matchers[name] = fn
- }
-
- var forEach = function(cb) {
- return Object.keys(matchers).forEach(function(key) {
- cb(matchers[key], key)
- })
- }
-
- addMatcher('be null', function() {
- return this === null
- })
-
- exports.addMatcher = addMatcher
- exports.forEach = forEach
- })
-})(new Module)
View
@@ -1,6 +0,0 @@
-;(function(module) { var exports = module.exports, define = module.define
- define(function(loader, runner) {
- loader.onSpec(runner.run)
- exports.subject = loader.subject
- })
-})(new Module)
View
@@ -1,49 +0,0 @@
-;(function(module) { var exports = module.exports, define = module.define
- define(function(matchers) {
- var run = function(spec) {
- var done = function(result) {
- spec.observations.forEach(function(observation) {
- var fullDescription = spec.name + ', ' + spec.context.description + ', ' + observation.description
- var reportResult = function(isSuccessful) {
- if(isSuccessful) {
- console.log('passed: ', fullDescription)
- } else {
- console.log('failed: ', fullDescription)
- }
- }
-
- var observe = function(actual) {
- var should = {}
- , not = {}
- matchers.forEach(function(matcher, name) {
- should[name] = function(expected) {
- reportResult(matcher.apply(actual, [ expected ]))
- }
- not[name] = function(expected) {
- reportResult(!matcher.apply(actual, [ expected ]))
- }
- })
-
- should.not = not
- return {
- should: should
- }
- }
-
- observation.fn.apply(observe, [ result ])
- })
- }
-
- try {
- spec.context.fn.apply(done)
- }
- catch(ex) {
- console.log(ex)
- }
-
- }
-
-
- exports.run = run
- })
-})(new Module)
View
@@ -1,9 +0,0 @@
-function Module() {
- var mod = Module.caller.arguments[2]
-
- this.require = mod.require
- this.exports = mod.exports
-}
-
-
-global.Module = Module
View
@@ -1,39 +1,27 @@
{
- "author": "Brian Mavity <brian@brianmavity.com> (http://www.brianmavity.com)"
-, "bin": {
- "papageno": "./bin/papageno-cli.js"
+ "name": "papageno"
+, "author": "Brian Mavity <brian@brianmavity.com> (http://www.brianmavity.com)"
+, "repository": {
+ "type": "git",
+ "url": "git://github.com/bmavity/papageno.git"
}
, "bugs": {
"url": "https://github.com/bmavity/papageno/issues"
}
, "contributors": [
"Brian Mavity <brian@brianmavity.com> (http://www.brianmavity.com)"
]
-, "description": "An experimental asynchronous context/observation specification library"
+, "description": "Command and Query handling for node.js"
, "dependencies": {
- "wagner": "0.1.x"
- , "optimist": "0.3.x"
}
-, "directories": {
- "bin": "./bin"
+, "devDependencies": {
}
, "engines": {
- "node": "0.8.x"
+ "node": "0.8.x, 0.10.x"
}
, "keywords": [
- "testing", "specification"
- ]
-, "licenses": [{
- "type": "MIT +no-false-attribs, +no-advertising"
- , "url": "https://raw.github.com/bmavity/papageno/master/LICENSE"
- }
]
-, "main": "./lib/index.js"
-, "name": "papageno"
-, "preferGlobal": true
-, "repository": {
- "type": "git"
- , "url": "git://github.com/bmavity/papageno.git"
- }
-, "version": "0.1.0"
+, "license": "MIT +no-false-attribs, +no-advertising License"
+, "main": "./papageno.js"
+, "version": "0.2.0"
}
View
@@ -0,0 +1,63 @@
+var path = require('path')
+ , url = require('url')
+ , fs = require('fs')
+ , commands = {}
+ , queries = {}
+ , resources = {}
+ , resourceArr = []
+
+function command(file) {
+
+}
+
+function query(name, handler, schema) {
+
+}
+
+function isJsFile(file) {
+ return path.extname(file) === '.js'
+}
+
+function removeExtension(file) {
+ return path.basename(file, path.extname(file))
+}
+
+function papageno(basePath) {
+ function isDir(file) {
+ return fs.statSync(path.resolve(basePath, file)).isDirectory()
+ }
+
+ function registerResource(resourceName) {
+ var resourceDir = path.resolve(basePath, resourceName)
+ , resourcePath = url.resolve('/', resourceName)
+ , resource = resources[resourceName] = resources[resourceName] || {}
+
+ function registerAction(actionFilename) {
+ var actionFile = path.resolve(resourceDir, actionFilename)
+ , actionName = removeExtension(actionFilename)
+ , isDefault = actionName === resourceName
+ , actionPath = isDefault ? resourcePath : url.resolve(resourcePath + '/', actionName)
+ , resourceAction = {
+ name: actionName
+ , id: resourceName + (isDefault ? '' : '.' + actionName)
+ , file: actionFile
+ , path: actionPath
+ , handler: require(actionFile)
+ }
+ resource[actionName] = resourceAction
+ resourceArr.push(resourceAction)
+ }
+
+ fs.readdirSync(resourceDir)
+ .filter(isJsFile)
+ .forEach(registerAction)
+ }
+
+ fs.readdirSync(basePath)
+ .filter(isDir)
+ .forEach(registerResource)
+ return resourceArr
+}
+
+
+module.exports = papageno
View
@@ -0,0 +1,8 @@
+{
+ "folders":
+ [
+ {
+ "path": "/Users/bmavity/node_projects/papageno"
+ }
+ ]
+}
Oops, something went wrong.

0 comments on commit e985056

Please sign in to comment.