Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
42 lib/sources/adrbymellon.js
@@ -31,13 +31,15 @@
_this = this;
handler = new htmlparser.DefaultHandler(function(error, dom) {
var container, cusip_data, delisted, delisted_epoch, exchange, name_el, security_name, security_type, ticker, ticker_el;
- security_name = null;
- ticker = null;
- exchange = null;
- security_type = null;
- delisted = null;
- delisted_epoch = null;
- if (error == null) {
+ if (error != null) {
+ return callback(null, null);
+ } else {
+ security_name = null;
+ ticker = null;
+ exchange = null;
+ security_type = null;
+ delisted = null;
+ delisted_epoch = null;
container = select(dom, 'body')[0];
name_el = select(container, '.inforSection');
if (!_.isEmpty(name_el)) {
@@ -47,19 +49,19 @@
if (!_.isEmpty(ticker_el)) {
ticker = _.last(ticker_el[0].attribs.href.split('symb='));
}
- }
- if (security_name != null) {
- cusip_data = {
- name: security_name,
- ticker: ticker,
- exchange: exchange,
- securityType: security_type,
- delisted: delisted,
- found: true
- };
- return callback(null, cusip_data);
- } else {
- return callback(null, null);
+ if (security_name != null) {
+ cusip_data = {
+ name: security_name,
+ ticker: ticker,
+ exchange: exchange,
+ securityType: security_type,
+ delisted: delisted,
+ found: true
+ };
+ return callback(null, cusip_data);
+ } else {
+ return callback(null, null);
+ }
}
});
parser = new htmlparser.Parser(handler);
View
30 lib/sources/fidelity.js
@@ -32,19 +32,25 @@
var handler, parser,
_this = this;
handler = new htmlparser.DefaultHandler(function(error, dom) {
- var cells, check_cell, name, row, ticker;
- row = select(dom, 'table[width=516] tr')[2];
- check_cell = select(row, 'td[nowrap]');
- if (!_.isEmpty(check_cell)) {
- cells = select(row, 'td');
- name = select(cells[0], 'font')[0].children[0].raw;
- ticker = select(cells[1], 'font a')[0].children[0].raw;
- return callback(null, {
- name: name,
- ticker: ticker
- });
- } else {
+ var cells, check_cell, cusip_data, name, row, ticker;
+ if (error != null) {
return callback(null, null);
+ } else {
+ cusip_data = null;
+ row = select(dom, 'table[width=516] tr')[2];
+ if (row != null) {
+ check_cell = select(row, 'td[nowrap]');
+ if (!_.isEmpty(check_cell)) {
+ cells = select(row, 'td');
+ name = select(cells[0], 'font')[0].children[0].raw;
+ ticker = select(cells[1], 'font a')[0].children[0].raw;
+ cusip_data = {
+ name: name,
+ ticker: ticker
+ };
+ }
+ }
+ return callback(null, cusip_data);
}
});
parser = new htmlparser.Parser(handler);
View
42 lib/sources/forbes.js
@@ -31,13 +31,15 @@
_this = this;
handler = new htmlparser.DefaultHandler(function(error, dom) {
var container, cusip_data, delisted, delisted_epoch, exchange, info_el, name_el, security_name, security_type, ticker, _ref;
- security_name = null;
- ticker = null;
- exchange = null;
- security_type = null;
- delisted = null;
- delisted_epoch = null;
- if (error == null) {
+ if (error != null) {
+ return callback(null, null);
+ } else {
+ security_name = null;
+ ticker = null;
+ exchange = null;
+ security_type = null;
+ delisted = null;
+ delisted_epoch = null;
container = select(dom, 'table[width=761] td[width=391]')[0];
name_el = select(container, 'span.mainsubindextitle');
if (!_.isEmpty(name_el)) {
@@ -47,19 +49,19 @@
if (!_.isEmpty(info_el)) {
_ref = info_el[0].children[0].raw.replace('(', '').replace(')', '').split(": "), exchange = _ref[0], ticker = _ref[1];
}
- }
- if (security_name != null) {
- cusip_data = {
- name: security_name,
- ticker: ticker,
- exchange: exchange,
- securityType: security_type,
- delisted: delisted,
- found: true
- };
- return callback(null, cusip_data);
- } else {
- return callback(null, null);
+ if (security_name != null) {
+ cusip_data = {
+ name: security_name,
+ ticker: ticker,
+ exchange: exchange,
+ securityType: security_type,
+ delisted: delisted,
+ found: true
+ };
+ return callback(null, cusip_data);
+ } else {
+ return callback(null, null);
+ }
}
});
parser = new htmlparser.Parser(handler);
View
42 lib/sources/quantum.js
@@ -31,13 +31,15 @@
_this = this;
handler = new htmlparser.DefaultHandler(function(error, dom) {
var container, cusip_data, day, day_str, delisted, delisted_epoch, delisting_date_el, delisting_date_raw, exchange, full_year, info_el, info_text, month, month_str, name_el, security_name, security_type, security_type_el, ticker, year, _ref, _ref1;
- security_name = null;
- ticker = null;
- exchange = null;
- security_type = null;
- delisted = null;
- delisted_epoch = null;
- if (error == null) {
+ if (error != null) {
+ return callback(null, null);
+ } else {
+ security_name = null;
+ ticker = null;
+ exchange = null;
+ security_type = null;
+ delisted = null;
+ delisted_epoch = null;
container = select(dom, 'table[bgcolor=#DCFDD7] td');
name_el = select(container, 'font[size=+1] center b');
if (!_.isEmpty(name_el)) {
@@ -65,19 +67,19 @@
full_year = year + (year >= 50 ? 1900 : 2000);
delisted = new Date("" + full_year + "-" + month_str + "-" + day_str);
}
- }
- if (security_name != null) {
- cusip_data = {
- name: security_name,
- ticker: ticker,
- exchange: exchange,
- securityType: security_type,
- delisted: delisted,
- found: true
- };
- return callback(null, cusip_data);
- } else {
- return callback(null, null);
+ if (security_name != null) {
+ cusip_data = {
+ name: security_name,
+ ticker: ticker,
+ exchange: exchange,
+ securityType: security_type,
+ delisted: delisted,
+ found: true
+ };
+ return callback(null, cusip_data);
+ } else {
+ return callback(null, null);
+ }
}
});
parser = new htmlparser.Parser(handler);
View
43 src/sources/adrbymellon.coffee
@@ -13,14 +13,17 @@ exports.AdrByMellonCusipSource = class AdrByMellonCusipSource extends CusipSourc
parse: (content, callback) ->
handler = new htmlparser.DefaultHandler (error, dom) =>
- security_name = null
- ticker = null
- exchange = null
- security_type = null
- delisted = null
- delisted_epoch = null
-
- unless error?
+ if error?
+ callback(null, null)
+
+ else
+ security_name = null
+ ticker = null
+ exchange = null
+ security_type = null
+ delisted = null
+ delisted_epoch = null
+
container = select(dom, 'body')[0]
name_el = select(container, '.inforSection')
@@ -31,20 +34,20 @@ exports.AdrByMellonCusipSource = class AdrByMellonCusipSource extends CusipSourc
unless _.isEmpty(ticker_el)
ticker = _.last(ticker_el[0].attribs.href.split('symb='))
- if security_name?
- cusip_data =
- name: security_name,
- ticker: ticker,
- exchange: exchange,
- securityType: security_type
- delisted: delisted
- found: true
+ if security_name?
+ cusip_data =
+ name: security_name,
+ ticker: ticker,
+ exchange: exchange,
+ securityType: security_type
+ delisted: delisted
+ found: true
- callback(null, cusip_data)
+ callback(null, cusip_data)
- # CUSIP was not found.
- else
- callback(null, null)
+ # CUSIP was not found.
+ else
+ callback(null, null)
parser = new htmlparser.Parser(handler)
parser.parseComplete(content)
View
23 src/sources/fidelity.coffee
@@ -13,15 +13,22 @@ exports.FidelityCusipSource = class FidelityCusipSource extends CusipSource
parse: (content, callback) ->
handler = new htmlparser.DefaultHandler (error, dom) =>
- row = select(dom, 'table[width=516] tr')[2]
- check_cell = select(row, 'td[nowrap]')
- unless _.isEmpty(check_cell)
- cells = select(row, 'td')
- name = select(cells[0], 'font')[0].children[0].raw
- ticker = select(cells[1], 'font a')[0].children[0].raw
- callback(null, {name: name, ticker: ticker})
- else
+ if error?
callback(null, null)
+ else
+ cusip_data = null
+
+ row = select(dom, 'table[width=516] tr')[2]
+ if row?
+ check_cell = select(row, 'td[nowrap]')
+ unless _.isEmpty(check_cell)
+ cells = select(row, 'td')
+ name = select(cells[0], 'font')[0].children[0].raw
+ ticker = select(cells[1], 'font a')[0].children[0].raw
+ cusip_data = {name: name, ticker: ticker}
+
+ callback(null, cusip_data)
+
parser = new htmlparser.Parser(handler)
parser.parseComplete(content)
View
43 src/sources/forbes.coffee
@@ -13,14 +13,17 @@ exports.ForbesCusipSource = class ForbesCusipSource extends CusipSource
parse: (content, callback) ->
handler = new htmlparser.DefaultHandler (error, dom) =>
- security_name = null
- ticker = null
- exchange = null
- security_type = null
- delisted = null
- delisted_epoch = null
-
- unless error?
+ if error?
+ callback(null, null)
+
+ else
+ security_name = null
+ ticker = null
+ exchange = null
+ security_type = null
+ delisted = null
+ delisted_epoch = null
+
container = select(dom, 'table[width=761] td[width=391]')[0]
name_el = select(container, 'span.mainsubindextitle')
@@ -31,20 +34,20 @@ exports.ForbesCusipSource = class ForbesCusipSource extends CusipSource
unless _.isEmpty(info_el)
[exchange, ticker] = info_el[0].children[0].raw.replace('(', '').replace(')', '').split(": ")
- if security_name?
- cusip_data =
- name: security_name,
- ticker: ticker,
- exchange: exchange,
- securityType: security_type
- delisted: delisted
- found: true
+ if security_name?
+ cusip_data =
+ name: security_name,
+ ticker: ticker,
+ exchange: exchange,
+ securityType: security_type
+ delisted: delisted
+ found: true
- callback(null, cusip_data)
+ callback(null, cusip_data)
- # CUSIP was not found.
- else
- callback(null, null)
+ # CUSIP was not found.
+ else
+ callback(null, null)
parser = new htmlparser.Parser(handler)
parser.parseComplete(content)
View
41 src/sources/quantum.coffee
@@ -13,14 +13,17 @@ exports.QuantumCusipSource = class QuantumCusipSource extends CusipSource
parse: (content, callback) ->
handler = new htmlparser.DefaultHandler (error, dom) =>
- security_name = null
- ticker = null
- exchange = null
- security_type = null
- delisted = null
- delisted_epoch = null
+ if error?
+ callback(null, null)
+
+ else
+ security_name = null
+ ticker = null
+ exchange = null
+ security_type = null
+ delisted = null
+ delisted_epoch = null
- unless error?
container = select(dom, 'table[bgcolor=#DCFDD7] td')
name_el = select(container, 'font[size=+1] center b')
@@ -45,20 +48,20 @@ exports.QuantumCusipSource = class QuantumCusipSource extends CusipSource
full_year = year + (if year >= 50 then 1900 else 2000)
delisted = (new Date("#{full_year}-#{month_str}-#{day_str}"))
- if security_name?
- cusip_data =
- name: security_name,
- ticker: ticker,
- exchange: exchange,
- securityType: security_type
- delisted: delisted
- found: true
+ if security_name?
+ cusip_data =
+ name: security_name,
+ ticker: ticker,
+ exchange: exchange,
+ securityType: security_type
+ delisted: delisted
+ found: true
- callback(null, cusip_data)
+ callback(null, cusip_data)
- # CUSIP was not found.
- else
- callback(null, null)
+ # CUSIP was not found.
+ else
+ callback(null, null)
parser = new htmlparser.Parser(handler)
parser.parseComplete(content)
View
2 tests/run.js
@@ -2,7 +2,7 @@
(function() {
var Cusip, cusip_code;
- Cusip = require('../lib/cusip');
+ Cusip = require('../index');
cusip_code = '079860101';
View
2 tests/src/run.coffee
@@ -1,4 +1,4 @@
-Cusip = require('../lib/cusip')
+Cusip = require('../index')
cusip_code = '079860101'

No commit comments for this range

Something went wrong with that request. Please try again.