-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f773c4
commit 5108eda
Showing
6 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
default: install build start | ||
|
||
install: | ||
@npm install | ||
|
||
clean: | ||
@echo "clean task not implemented" | ||
|
||
build: | ||
@echo "build task not implemented" | ||
|
||
start: | ||
@npm start | ||
|
||
test: | ||
@npm test | ||
|
||
.PHONY: install clean build start test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var Pimm = require('../'), | ||
repl = require('repl'), | ||
prompt = repl.start({prompt: '> '}), | ||
|
||
http = new Pimm({dir: __dirname}); | ||
|
||
prompt.context.Pimm = Pimm; | ||
prompt.context.http = http; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var keylime = require('keylime'), | ||
mach = require('mach'), | ||
_ = require('lodash'), | ||
p = require('path'), | ||
|
||
Directory = require('./pimm/support/directory'), | ||
Path = require('./pimm/support/path'), | ||
|
||
Pimm = keylime('Pimm'); | ||
|
||
Pimm | ||
.attr('dir', '.' + p.sep) | ||
.attr('port', 3000) | ||
|
||
.attr('_stack', mach.stack) | ||
|
||
.method('_loadControllers', function loadControllers() { | ||
var controllerPath = new Path({value: this.dir}).resolve('controllers'), | ||
controllerDir = new Directory({path: controllerPath}); | ||
|
||
console.log(controllerPath); | ||
return controllerDir.load() | ||
.then(function() { | ||
_.forIn(controllerDir.files, function(path, Controller) { | ||
console.log(path); | ||
console.log(Controller); | ||
}); | ||
}); | ||
}) | ||
|
||
.method('start', function start() { | ||
mach.serve(this._stack, this.port); | ||
}); | ||
|
||
module.exports = Pimm; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var keylime = require('keylime'), | ||
Promise = require('bluebird'), | ||
fs = require('fs'), | ||
recursiveReaddir = require('recursive-readdir'), | ||
Path = require('./path'), | ||
readdir = Promise.promisify(recursiveReaddir), | ||
readfile = Promise.promisify(fs.readFile), | ||
|
||
Directory = keylime('Directory'); | ||
|
||
Directory | ||
.attr('path', './') | ||
.attr('files', {}) | ||
|
||
.method('load', function load() { | ||
var path = new Path({value: this.path}); | ||
|
||
return Promise.bind(this) | ||
.then(function() { | ||
return readdir(path.resolve()); | ||
}) | ||
.map(function processFile(file) { | ||
var filePath = new Path({value: file}), | ||
filePiece = filePath.relative(this.path), | ||
fileContent = (filePath.hasExtension('js')) ? require(filePath.resolve()) : readfile(filePath.resolve()); | ||
return Promise.join(filePiece, fileContent, function(name, content) { | ||
return { | ||
name: name, | ||
content: content | ||
}; | ||
}); | ||
}) | ||
.each(function populateFile(file) { | ||
this.files[file.name] = file.content; | ||
}); | ||
}); | ||
|
||
module.exports = Directory; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var keylime = require('keylime'), | ||
p = require('path'), | ||
_ = require('lodash'), | ||
|
||
Path = keylime('Path'); | ||
|
||
Path | ||
.attr('value', '') | ||
|
||
.method('resolve', function resolve() { | ||
return p.resolve(_.partial(p.join, this.value).apply(this, arguments)); | ||
}) | ||
|
||
.method('relative', function relative() { | ||
var from = '.' + p.sep, | ||
prefix = '.' + p.sep; | ||
return prefix + p.relative(from, _.partial(p.join, this.value).apply(this, arguments)); | ||
}) | ||
|
||
.method('extension', function extension() { | ||
return p.extname(this.value); | ||
}) | ||
|
||
.method('hasExtension', function hasExtension(val) { | ||
return (new RegExp(val, 'i').test(this.extension())); | ||
}); | ||
|
||
module.exports = Path; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "pimm", | ||
"version": "0.0.0", | ||
"homepage": "https://github.com/stevenschobert/pimm", | ||
"description": "An easy-going web framework for Node.", | ||
"main": "lib/pimm.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/jshint --reporter ./node_modules/jshint-stylish/stylish.js lib/** test/** && ./node_modules/.bin/mocha -R spec test/**" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/stevenschobert/pimm.git" | ||
}, | ||
"author": "Steven Schobert <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/stevenschobert/pimm/issues" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^2.2.2", | ||
"keylime": "git+ssh://[email protected]:ovenbits/keylime", | ||
"lodash": "^2.4.1", | ||
"mach": "^0.12.0", | ||
"recursive-readdir": "^1.1.3" | ||
}, | ||
"devDependencies": { | ||
"assert": "^1.1.1", | ||
"mocha": "^1.21.4", | ||
"jshint-stylish": "^0.4.0", | ||
"jshint": "^2.5.2", | ||
"supertest": "^0.13.0" | ||
} | ||
} |