Merge branch 'master' into merge-master

This commit is contained in:
Josh Harvey 2014-05-03 17:03:55 -04:00
commit 9ac399ea3b
2 changed files with 1 additions and 58 deletions

View file

@ -1,45 +0,0 @@
'use strict';
// TODO: refactor this with bitpay_ticker.js
var https = require('https');
var _ = require('underscore');
var CustomTicker = function(config) {
this.config = config;
};
CustomTicker.factory = function factory(config) {
return new CustomTicker(config);
};
CustomTicker.prototype.ticker = function ticker(currency, cb) {
var self = this;
https.get(this.config.uri, function(res) {
var buf = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
buf += chunk;
})
.on('end', function() {
var json = null;
try {
json = JSON.parse(buf);
} catch(e) {
cb(new Error('Couldn\'t parse JSON response'));
return;
}
var rec = _.findWhere(json, {code: currency});
if (!rec) {
cb(new Error('Currency not listed: ' + currency));
return;
}
cb(null, rec.rate);
});
}).on('error', function(e) {
cb(e);
});
};
module.exports = CustomTicker;

View file

@ -21,19 +21,7 @@ var Trader = module.exports = function (db) {
}; };
Trader.prototype._findExchange = function (name) { Trader.prototype._findExchange = function (name) {
var exchange; return require('lamassu-' + name);
try {
exchange = require('lamassu-' + name);
} catch (err) {
if (!err.message.match(/Cannot find module/)) {
throw err;
}
exchange = require(path.join(path.dirname(__dirname), 'exchanges', name));
}
return exchange;
}; };
Trader.prototype._findTicker = function (name) { Trader.prototype._findTicker = function (name) {