jubaclient
Advanced tools
Comparing version 0.1.1 to 0.1.2
17
app.js
@@ -0,1 +1,2 @@ | ||
const assert = require('assert'); | ||
const util = require('util'); | ||
@@ -18,2 +19,16 @@ const debug = util.debuglog('jubaclient'); | ||
} | ||
exports.request = request; | ||
exports.request = request; | ||
function assertServiceMethod(service, method) { | ||
assert.ok(typeof service === 'string', 'service is required.'); | ||
assert.ok(typeof method === 'string', 'method is required.'); | ||
const serviseName = toCamelCase('_' + service); | ||
const namespace = serviseName.toLowerCase(); | ||
assert.ok(Object.keys(jubatus).some(key => namespace === key), `${ namespace } is unspport service.`); | ||
const { [namespace]: { client: { [serviseName]: Service } } } = jubatus; | ||
const methodName = toCamelCase(method); | ||
assert.ok(Object.keys(Service.prototype).some(key => methodName === key), `${ methodName } is unspport method.`); | ||
} | ||
exports.assertServiceMethod = assertServiceMethod; |
@@ -17,2 +17,4 @@ #!/usr/bin/env node | ||
const { '_': [ service, method ], p: port, h: host, n: name, t: timeout } = argv; | ||
app.assertServiceMethod(service, method); | ||
const client = rpc.createClient(port, host, timeout); | ||
@@ -19,0 +21,0 @@ |
{ | ||
"name": "jubaclient", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Jubatus CLI client (unofficial)", | ||
"main": "index.js", | ||
"bin": "index.js", | ||
"man" : "./man/jubaclient.1", | ||
"scripts": { | ||
@@ -8,0 +9,0 @@ "test": "istanbul cover ./node_modules/mocha/bin/_mocha" |
@@ -83,2 +83,19 @@ const expect = require('chai').expect; | ||
}); | ||
}); | ||
describe('app#assertServiceMethod', () => { | ||
it('support', done => { | ||
expect(() => app.assertServiceMethod('classifier', 'get_status')).to.not.throw(); | ||
done(); | ||
}); | ||
it('unsupport service', done => { | ||
expect(() => app.assertServiceMethod('foo', 'get_status')).to.throw(/service/); | ||
done(); | ||
}); | ||
it('unsupport method', done => { | ||
expect(() => app.assertServiceMethod('classifier', 'bar')).to.throw(/method/); | ||
done(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16370
10
200