Comparing version 0.2.1 to 1.0.0
@@ -0,1 +1,8 @@ | ||
2/22/2016 - 1.0.0 | ||
================== | ||
* Updated cheerio and request. | ||
* Updated tests and dev dependencies. | ||
* Bumped version to 1.0.0. | ||
* Added license | ||
7/11/2014 - 0.2.1 | ||
@@ -2,0 +9,0 @@ ================== |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.3 | ||
// Generated by CoffeeScript 1.10.0 | ||
var Tanto, cheerio, request, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
@@ -10,8 +10,8 @@ request = require('request'); | ||
Tanto = (function() { | ||
function Tanto(options, cb) { | ||
var _base; | ||
this.options = options; | ||
this.cb = cb; | ||
this.process = __bind(this.process, this); | ||
(_base = this.options).timeout || (_base.timeout = 30000); | ||
function Tanto(options1, cb1) { | ||
var base1; | ||
this.options = options1; | ||
this.cb = cb1; | ||
this.process = bind(this.process, this); | ||
(base1 = this.options).timeout || (base1.timeout = 30000); | ||
this.initSchema(); | ||
@@ -22,10 +22,10 @@ this.scrape(); | ||
Tanto.prototype.initSchema = function() { | ||
var key, value, _base, _ref, _results; | ||
var base1, key, ref, results, value; | ||
this.schema = this.options.schema; | ||
_ref = this.schema; | ||
_results = []; | ||
for (key in _ref) { | ||
value = _ref[key]; | ||
ref = this.schema; | ||
results = []; | ||
for (key in ref) { | ||
value = ref[key]; | ||
if (typeof value === "string") { | ||
_results.push(this.schema[key] = { | ||
results.push(this.schema[key] = { | ||
selector: value, | ||
@@ -35,6 +35,6 @@ type: "text" | ||
} else { | ||
_results.push((_base = this.schema[key]).type || (_base.type = "text")); | ||
results.push((base1 = this.schema[key]).type || (base1.type = "text")); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -63,11 +63,11 @@ | ||
Tanto.prototype.readValues = function() { | ||
var error, key, val, value, _ref, _results; | ||
_ref = this.schema; | ||
_results = []; | ||
for (key in _ref) { | ||
val = _ref[key]; | ||
var error, error1, key, ref, results, val, value; | ||
ref = this.schema; | ||
results = []; | ||
for (key in ref) { | ||
val = ref[key]; | ||
try { | ||
value = this.data.$(val.selector); | ||
} catch (_error) { | ||
error = _error; | ||
} catch (error1) { | ||
error = error1; | ||
this.addSchemaError(key, error); | ||
@@ -77,8 +77,8 @@ continue; | ||
if (value.length !== 0) { | ||
_results.push(this.setKey(key, this.getValue(value, val))); | ||
results.push(this.setKey(key, this.getValue(value, val))); | ||
} else { | ||
_results.push(this.addSchemaError(key, new Error("Value not found"))); | ||
results.push(this.addSchemaError(key, new Error("Value not found"))); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -114,7 +114,7 @@ | ||
Tanto.prototype.setKey = function(key, val) { | ||
var base, last, level, levels, _i, _len; | ||
var base, i, last, len, level, levels; | ||
base = this.data.values; | ||
levels = key.split('.'); | ||
for (_i = 0, _len = levels.length; _i < _len; _i++) { | ||
level = levels[_i]; | ||
for (i = 0, len = levels.length; i < len; i++) { | ||
level = levels[i]; | ||
last = base; | ||
@@ -121,0 +121,0 @@ base = base[level] = base[level] || {}; |
{ | ||
"name": "tanto", | ||
"version": "0.2.1", | ||
"version": "1.0.0", | ||
"author": "Charles Moncrief", | ||
@@ -11,8 +11,8 @@ "description": "Lightweight web scraping library", | ||
"dependencies": { | ||
"cheerio": "^0.17.0", | ||
"request": "^2.37.0" | ||
"cheerio": "^0.20.0", | ||
"request": "^2.69.0" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "~1.6.3", | ||
"mocha": "~1.12.0" | ||
"coffee-script": "^1.10.0", | ||
"mocha": "^2.4.5" | ||
}, | ||
@@ -19,0 +19,0 @@ "scripts": { |
@@ -21,3 +21,3 @@ # Tantō | ||
of the response and the `$` object, which allows extracting data out of the response with all of the jQuery syntax available in the [cheerio module](https://npmjs.org/package/cheerio) | ||
var tanto = require('tanto'); | ||
@@ -42,3 +42,3 @@ | ||
tanto(options, function(err, data) { | ||
console.log(data.$('title').text()); | ||
console.log(data.$('title').text()); | ||
}); | ||
@@ -128,3 +128,3 @@ | ||
Transformation functions take `data` and `context` as parameters and return | ||
the new value. Use the `context` parameter to alter or create other keys in the returned values. | ||
the new value. Use the `context` parameter to alter or create other keys in the returned values. | ||
@@ -159,3 +159,3 @@ The following is an example of a transform function that sets the scraped name | ||
(The MIT License) | ||
(The ISC License) | ||
@@ -181,2 +181,2 @@ Copyright (c) 2013 Charles Moncrief <<cmoncrief@gmail.com>> | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
178
16003
10
1
+ Addedabab@1.0.4(transitive)
+ Addedacorn@2.7.0(transitive)
+ Addedacorn-globals@1.0.9(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedcheerio@0.20.0(transitive)
+ Addedcss-select@1.2.0(transitive)
+ Addedcss-what@2.1.3(transitive)
+ Addedcssom@0.3.8(transitive)
+ Addedcssstyle@0.2.37(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addeddom-serializer@0.1.1(transitive)
+ Addeddomelementtype@1.3.1(transitive)
+ Addeddomhandler@2.3.0(transitive)
+ Addedescodegen@1.14.3(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedestraverse@4.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedhtmlparser2@3.8.3(transitive)
+ Addedjsdom@7.2.2(transitive)
+ Addedlevn@0.3.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addednth-check@1.0.2(transitive)
+ Addednwmatcher@1.4.4(transitive)
+ Addedoptionator@0.8.3(transitive)
+ Addedparse5@1.5.1(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsymbol-tree@3.2.4(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addedwebidl-conversions@2.0.1(transitive)
+ Addedwhatwg-url-compat@0.6.5(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedxml-name-validator@2.0.1(transitive)
- RemovedCSSselect@0.4.1(transitive)
- RemovedCSSwhat@0.4.7(transitive)
- Removedcheerio@0.17.0(transitive)
- Removeddom-serializer@0.0.1(transitive)
- Removeddomelementtype@1.1.3(transitive)
- Removeddomhandler@2.2.1(transitive)
- Removeddomutils@1.4.3(transitive)
- Removedhtmlparser2@3.7.3(transitive)
- Removedlodash@2.4.2(transitive)
Updatedcheerio@^0.20.0
Updatedrequest@^2.69.0