diff --git a/.gitignore b/.gitignore index 5e89640..8765e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,12 @@ -build -typings +node_modules # Logs logs *.log npm-debug.log* -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul +# Typescript stuff +typings +build +docs coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -node_modules - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history \ No newline at end of file diff --git a/.npmignore b/.npmignore index 2f28e28..2476d0e 100644 --- a/.npmignore +++ b/.npmignore @@ -24,4 +24,23 @@ node_modules .npm # Optional REPL history -.node_repl_history \ No newline at end of file +.node_repl_history + + +# Typescript stuff +typings +build +docs +coverage + +# Files +*.ts +!*.d.ts +*.js.map +*.spec.js +*.spec.ts +*.spec.d.ts +*.spec.js.map + +.travis.yml +.testdata diff --git a/.travis.yml b/.travis.yml index b5dc9e1..7352e42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,20 @@ language: node_js node_js: - - "5" \ No newline at end of file +- '5' +- '4.2' + +script: npm run citest +after_script: npm install coveralls@^2.11.9 && cat ./coverage/lcov.info | coveralls + +before_deploy: +- npm run bootstrap +- tsc --outDir . + +deploy: + provider: npm + email: christoph.buehler@bluewin.ch + api_key: + secure: rZpdXuZORp8oQWogOXlRJjBPSwPJxxHXYoJY/2iqw/0OAVB65UPKEPX7+F2u33KrodWSR/vf/D4AUFnbJaGzLEecQnCJjIcvaFOhsbmoZxVWM2LWuboH2CfKhxVrcN2c4LBmlo+sItuVarqqvbGakb9BmkwWEsD4VSU6mjoBJ9QQfdDyyXCB64sPLabbd9apah096lOb4KXqxcs0A4GMYVR54MuEf/+nhEiw34pqMJrwI2CHPD2Z0FujHFNj8cT7c4ZbyqvMQY/uoQzbOyeJMUfQ579jVhUEDC/gs2O/OZGbjSwU91t9Pm+keFCWYzUakOaNz1JM5y8zgSQH3n26iCmp+nFPxP0rioIAnI0QL04JgXxnZHOgVo0R+Oz+/B1vCPqnr6C5G2V+flQCht5BDHtCne5Q+roiMaRL7nmrxeHd3qlQ53l7RewKu+qgllVYiyWRUmVFmcs84NwmcYJQauwObkaKOrEvOSi77taqQDD9WKIEY0F156+1gAdzKFl1oLyMCbLDy/MmLrOejCCl88HH/+JD44hDBlgM/SpcENci5MjP24V0WXYJDkhcgFjDCBO+uc4seZYvrg0kMLRhg5hSxTIT93zHZNvrRkAw1TD73tV/tafXrO588ZI+/eJBIcTCc2kRg2FuDnrsspEBO66obsmpAeuf49dipD4oGTg= + on: + tags: true + repo: smartive/proc-that-rest-extractor diff --git a/README.md b/README.md index 214a6e7..2368d71 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ -# RestExtractor [![Build Status](https://travis-ci.org/buehler/proc-that-rest-extractor.svg?branch=master)](https://travis-ci.org/buehler/proc-that-rest-extractor) +# RestExtractor Modular extractor for `proc-that`. Loads items from REST APIs via http requests. Uses [restler](https://github.com/danwrong/restler) for downloading resources. +##### A bunch of badges + +[![Build Status](https://travis-ci.org/smartive/proc-that-rest-extractor.svg?maxAge=3600)](https://travis-ci.org/smartive/proc-that-rest-extractor) [![npm](https://img.shields.io/npm/v/proc-that-rest-extractor.svg?maxAge=3600)](https://www.npmjs.com/package/proc-that-rest-extractor) [![Coverage status](https://img.shields.io/coveralls/smartive/proc-that-rest-extractor.svg?maxAge=3600)](https://coveralls.io/github/smartive/proc-that-rest-extractor) [![license](https://img.shields.io/github/license/smartive/proc-that-rest-extractor.svg?maxAge=2592000)](https://github.com/smartive/proc-that-rest-extractor) + ## Installation ```bash diff --git a/RestExtractor.ts b/RestExtractor.ts index cefb00b..6f32f1d 100644 --- a/RestExtractor.ts +++ b/RestExtractor.ts @@ -1,4 +1,4 @@ -import {IExtract} from 'proc-that/dist/interfaces/IExtract'; +import {IExtract} from 'proc-that'; import {Observable, Observer} from 'rxjs'; export enum RestExtractorMethod { diff --git a/dist/RestExtractor.d.ts b/dist/RestExtractor.d.ts deleted file mode 100644 index 7faa9ea..0000000 --- a/dist/RestExtractor.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { IExtract } from 'proc-that/dist/interfaces/IExtract'; -import { Observable } from 'rxjs'; -export declare enum RestExtractorMethod { - Get = 0, - Post = 1, - Put = 2, -} -export declare class RestExtractor implements IExtract { - private url; - private method; - private resultSelector; - private rest; - constructor(url: string, method?: RestExtractorMethod, resultSelector?: (obj: any) => any); - read(): Observable; - private getUrlMethod(); -} diff --git a/dist/RestExtractor.js b/dist/RestExtractor.js deleted file mode 100644 index c0f9784..0000000 --- a/dist/RestExtractor.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -var rxjs_1 = require('rxjs'); -(function (RestExtractorMethod) { - RestExtractorMethod[RestExtractorMethod["Get"] = 0] = "Get"; - RestExtractorMethod[RestExtractorMethod["Post"] = 1] = "Post"; - RestExtractorMethod[RestExtractorMethod["Put"] = 2] = "Put"; -})(exports.RestExtractorMethod || (exports.RestExtractorMethod = {})); -var RestExtractorMethod = exports.RestExtractorMethod; -var RestExtractor = (function () { - function RestExtractor(url, method, resultSelector) { - if (method === void 0) { method = RestExtractorMethod.Get; } - if (resultSelector === void 0) { resultSelector = function (o) { return o; }; } - this.url = url; - this.method = method; - this.resultSelector = resultSelector; - this.rest = require('restler'); - } - RestExtractor.prototype.read = function () { - var _this = this; - return rxjs_1.Observable.create(function (observer) { - _this.rest - .request(_this.url, { - method: _this.getUrlMethod() - }) - .on('error', function (err) { - observer.error(err); - }) - .on('complete', function (result) { - try { - var json = typeof result === 'string' ? JSON.parse(result) : result; - json = _this.resultSelector(json); - if (json instanceof Array || json.constructor === Array) { - json.forEach(function (element) { return observer.next(element); }); - } - else { - observer.next(json); - } - } - catch (e) { - observer.error(e); - } - finally { - observer.complete(); - } - }); - }); - }; - RestExtractor.prototype.getUrlMethod = function () { - switch (this.method) { - case RestExtractorMethod.Post: - return 'post'; - case RestExtractorMethod.Put: - return 'put'; - default: - return 'get'; - } - }; - return RestExtractor; -}()); -exports.RestExtractor = RestExtractor; -//# sourceMappingURL=RestExtractor.js.map \ No newline at end of file diff --git a/dist/RestExtractor.js.map b/dist/RestExtractor.js.map deleted file mode 100644 index e101551..0000000 --- a/dist/RestExtractor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"RestExtractor.js","sourceRoot":"","sources":["../RestExtractor.ts"],"names":[],"mappings":";AACA,qBAAmC,MAAM,CAAC,CAAA;AAE1C,WAAY,mBAAmB;IAC3B,2DAAG,CAAA;IACH,6DAAI,CAAA;IACJ,2DAAG,CAAA;AACP,CAAC,EAJW,2BAAmB,KAAnB,2BAAmB,QAI9B;AAJD,IAAY,mBAAmB,GAAnB,2BAIX,CAAA;AAKD;IASI,uBAAoB,GAAU,EAAU,MAAoD,EAAU,cAAwC;QAA9G,sBAA4D,GAA5D,SAAqC,mBAAmB,CAAC,GAAG;QAAE,8BAAgD,GAAhD,iBAA0C,UAAA,CAAC,IAAI,OAAA,CAAC,EAAD,CAAC;QAA1H,QAAG,GAAH,GAAG,CAAO;QAAU,WAAM,GAAN,MAAM,CAA8C;QAAU,mBAAc,GAAd,cAAc,CAA0B;QARtI,SAAI,GAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAStC,CAAC;IAEM,4BAAI,GAAX;QAAA,iBAyBC;QAxBG,MAAM,CAAC,iBAAU,CAAC,MAAM,CAAC,UAAC,QAAsB;YAC5C,KAAI,CAAC,IAAI;iBACJ,OAAO,CAAC,KAAI,CAAC,GAAG,EAAE;gBACf,MAAM,EAAE,KAAI,CAAC,YAAY,EAAE;aAC9B,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,UAAA,GAAG;gBACZ,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC,CAAC;iBACD,EAAE,CAAC,UAAU,EAAE,UAAA,MAAM;gBAClB,IAAI,CAAC;oBACD,IAAI,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;oBACpE,IAAI,GAAG,KAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBACjC,EAAE,CAAC,CAAC,IAAI,YAAY,KAAK,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC;wBACtD,IAAI,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAtB,CAAsB,CAAC,CAAC;oBACpD,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBACvB,CAAC;gBACL,CAAE;gBAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACT,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,CAAC;wBAAS,CAAC;oBACP,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACxB,CAAC;YACL,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,oCAAY,GAApB;QACI,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAClB,KAAK,mBAAmB,CAAC,IAAI;gBACzB,MAAM,CAAC,MAAM,CAAC;YAClB,KAAK,mBAAmB,CAAC,GAAG;gBACxB,MAAM,CAAC,KAAK,CAAC;YACjB;gBACI,MAAM,CAAC,KAAK,CAAC;QACrB,CAAC;IACL,CAAC;IACL,oBAAC;AAAD,CAAC,AAjDD,IAiDC;AAjDY,qBAAa,gBAiDzB,CAAA"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 6ecc3df..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './RestExtractor'; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f2227e2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -__export(require('./RestExtractor')); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 687f059..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;AAAA,iBAAc,iBAAiB,CAAC,EAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 6f76afe..922ec8c 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,16 @@ { "name": "proc-that-rest-extractor", - "version": "0.3.1", + "version": "0.3.2", "description": "extractor for proc-that which loads results from REST apis.", - "main": "dist/index.js", + "main": "index.js", "scripts": { "clean": "rimraf build", - "pretest": "npm install && typings install && npm run clean && tsc", + "bootstrap": "npm install && typings install", + "pretest": "npm run bootstrap && npm run clean && tsc", "test": "mocha --ui bdd --recursive ./build", - "develop": "npm run clean && tsc -w", - "build": "rimraf build dist && tsc --outDir dist -d && del './dist/**/*.spec*'" + "precitest": "npm run bootstrap && npm run clean && tsc", + "citest": "istanbul cover -x \"**/*.spec.*\" _mocha --report lcovonly -- --ui bdd --recursive ./build", + "develop": "npm run clean && tsc -w" }, "keywords": [ "etl", @@ -19,16 +21,18 @@ ], "repository": { "type": "git", - "url": "git@github.com:buehler/proc-that-rest-extractor.git" + "url": "git@github.com:smartive/proc-that-rest-extractor.git" }, - "bugs": "https://github.com/buehler/proc-that-rest-extractor/issues", + "bugs": "https://github.com/smartive/proc-that-rest-extractor/issues", "author": "Christoph Bühler ", "license": "MIT", "devDependencies": { "chai": "^3.5.0", "chai-as-promised": "^5.3.0", "del-cli": "^0.2.0", + "istanbul": "^0.4.3", "mocha": "^2.4.5", + "mocha-lcov-reporter": "^1.2.0", "rimraf": "^2.5.2", "sinon": "^1.17.3", "sinon-chai": "^2.8.0", @@ -36,7 +40,7 @@ "typings": "^0.7.9" }, "dependencies": { - "proc-that": "^0.3.0", + "proc-that": "^0.3.2", "restler": "^3.4.0", "rxjs": "5.0.0-beta.4" } diff --git a/tsconfig.json b/tsconfig.json index 1f102a4..57a4b95 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,14 +3,14 @@ "target": "es5", "module": "commonjs", "moduleResolution": "node", - "removeComments": true, + "removeComments": false, "outDir": "./build", - "sourceMap": true + "declaration": true, + "sourceMap": false }, "exclude": [ "node_modules", "build", - "dist", "typings/browser.d.ts", "typings/browser" ]