Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
charud committed Aug 29, 2012
0 parents commit 296098a
Show file tree
Hide file tree
Showing 380 changed files with 57,287 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
support
test
examples
*.sock
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

0.0.1 / 2010-01-03
==================

* Initial release
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

test:
@./node_modules/.bin/mocha \
--require should \
--reporter spec

.PHONY: test
29 changes: 29 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# get

Get stuff

## License

(The MIT License)

Copyright (c) 2012 Charlie Rudenstål <[email protected]>

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.
13 changes: 13 additions & 0 deletions bin/get
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env node

/**
* get
* Copyright(c) 2012 Charlie Rudenstål <[email protected]>
* MIT Licensed
*/

var get = require('../');
get(process.argv, function(err, r) {
console.log(r);
//process.stdout.write(r + '\n');
});
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require('streamline').register({
fibers: false,
cache: true,
verbose: true
});

module.exports = require('./lib/get');
53 changes: 53 additions & 0 deletions lib/get._js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* get
* Copyright(c) 2012 Charlie Rudenstål <[email protected]>
* MIT Licensed
*/
module.exports = get;

function get(args, _) {

// Remove first argument: engine executing this app 'node'
args.shift();

// Remove second argument: name/alias of this executable
args.shift();

// Get source name, ie tvnu
var name = args.shift();

try {
// Prepare helpers
var helpers = {};
helpers.request = require('request');
helpers.json = require('../lib/helpers/json');

// Get source
var source = require('../sources/' + name);

// Call action in source, call index if it doesn't exist
action = action in source ? action : 'index';

// Get source action, default to index if it doesn't exist
var action = args.shift();
if(action in source == false) {
args.unshift(action); // probably a param if not a valid action. leave args alone.
action = 'index';
}

// Get source parameter
var param = args.join(' ');

// Call source with action and parameter
var respon = source[action].apply_(_, helpers, [param]);

// Autoresolve if this is a response from the
// get helper that hasn't been resolved
if(typeof respon === 'object' && 'get' in respon) respon = respon.get();

} catch(e) {
console.log(e);
}

return respon;
}
29 changes: 29 additions & 0 deletions lib/helpers/json._js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var request = require('request');
module.exports = function(url, _) {
var r = JSON.parse(request(url, _).body);
return {
get: function(keyORmapFunc) {
if(typeof keyORmapFunc == 'string') {
r = r[keyORmapFunc] || [];
return this;
}
else if(typeof keyORmapFunc == 'function') {
r = r.map(keyORmapFunc);
r = r.filter(function(x) {
return x !== null &&
x !== undefined &&
(typeof x !== 'object' || Object.keys(x).length !== 0) // don't include empty objects/arrays
});
return this;
}
return r;
},
getEach: function(key) {
if(typeof key == 'string' || typeof key == 'number') {
return this.get(function(x) {
return x[key] || {};
});
}
}
}
}
1 change: 1 addition & 0 deletions node_modules/.bin/_coffee

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/_node

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/coffee-streamline

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-streamline

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/mocha/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions node_modules/mocha/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 296098a

Please sign in to comment.