{"_id":"tubesio","_rev":"39-1624b49ee4176a2822e1610bea51d827","name":"tubesio","description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","dist-tags":{"latest":"0.1.17"},"versions":{"0.1.0":{"name":"tubesio","version":"0.1.0","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"# tubes.io library for node\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. The [Command Line Interface](#command-line-interface) (CLI)\n2. The [tubes.io node lib](#tubesio-node-lib)\n\n## Installation\n\n### Installing NPM\n\n`curl http://npmjs.org/install.sh | sh`\n\n### Installing tubes.io CLI\n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nA command-line interface for interacting with the tubes.io API. \n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of hub scripts deployed on tubes.io. \n\n## Environment Setup\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\n## tubes.io node lib\n\n### Modules\n\n* tubesio.[http](#http)\n* tubesio.[logging](#logging)\n* tubesio.[utils](#utils)\n\n#### HTTP \n\nTODO\n\n#### Logging\n\nTODO\n\n#### Utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","_id":"tubesio@0.1.0","dist":{"shasum":"29ec536d68a32cb991f2d4beaf86fa1fec615940","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.0.tgz","integrity":"sha512-boLWyD++KBTN/AriLZOytpuW3L9IzMPGAufPItWJeclHf+Rn/JZjhE4m6SPFSQTCgrwB49xgu7jvJALH7BfHlQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB31d5f995SoM7DPStXKPgwHXri9oLRPkIrqCOjKsIMbAiA3Hat6oIL5uuYsTAz/GgP5SvnfZXEeq6zFTIY93bp7Qw=="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.1":{"name":"tubesio","version":"0.1.1","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.1","dist":{"shasum":"127f5a495020eadc08bc45ba52189b51f1c04203","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.1.tgz","integrity":"sha512-ybAvEExrpLA3INoKAHfBaups4Ef+95/cCGGGmjmdDfZg0yrA3+RPdzRYtX93LXh9hrb5kMmY6TkhZqrlRAHgGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDh2ehPRPTZhsFikMdkGiGTCgMDF8o5U7ZM0svwcQOjDAIgR+5GUVM6JWpye3fpxEJePCS2oclH8ufl2uPjc4im+jE="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.2":{"name":"tubesio","version":"0.1.2","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.2","dist":{"shasum":"f6f4dcaca502858cc7078779ac06b37f7c04966a","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.2.tgz","integrity":"sha512-gKU+1ynSokJhmUjUG64sEFsUsAlEcuKbpBmxIoWVdfULLAWrI+OQMAYJ27OYP8wmNMtYhBI+1RcCD4pCo9A6WQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDyvKIY3Xssy3vhkKGDpnw3tel2dn/m4EWUKZa1kiSyYQIhAOVdzibk3IX0tsNjTucffAPhUOaCy9cOTTh2QCKBjYKE"}]},"_npmVersion":"1.1.65","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.3":{"name":"tubesio","version":"0.1.3","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.3","dist":{"shasum":"35f94da1485d1ffbb8d8d7dea150ff68fc885cc1","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.3.tgz","integrity":"sha512-WMPxblphYOFAQVlpayaVYxu1vrolxcSSLoBWtpeNUzdvzc0bwlybQjiUbGcd1WkJ3ED5IYGb1auzI380/9P/dQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF1ytOuCf5Qwk1qlDjsCTKAxaD/jGWXAUvldzb8buA/BAiBN++30VveAdnLNCIkKo/2UReolBeCm3o31axaZeWUFcQ=="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.4":{"name":"tubesio","version":"0.1.4","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.4","dist":{"shasum":"87d574b4dc4cfb6d9d1f98c30cb56177a7cce51b","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.4.tgz","integrity":"sha512-XomsnUCkAEActV0GgpGuqNGxcqInAZ6CrBmvB6sOpNNA4ybTsGNlESPLQ8w6sq+aVoZn092Nj8VDJVEc9AoQ8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDwCJmQWe87IkC4b1lMis8zz8PZoA0eihApCbn6mwBuPAiA/Ar0i2h646G4WAxKYOmTiw2cwLyc3gZqBz5Ceknr+OQ=="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.5":{"name":"tubesio","version":"0.1.5","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.5","dist":{"shasum":"28654efb00241413bd37c1eff4548950338da222","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.5.tgz","integrity":"sha512-85xJUZ+891eLDSHI9WC9Oaqc8av8OpNRaXSpsMkJ0ej1hmiRU2fLMLlo6PKEpDOBOMdsz7ZCvViAnjlB9G6UwA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6Jo3iHwr7aelCqKKbkt9jGjlp0JFSAn2JW/6agbJwlAIhAIR4WSTQpu2yxy+6tF34excLKXZB4psHkKQaAhNgVolC"}]},"_npmVersion":"1.1.66","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.6":{"name":"tubesio","version":"0.1.6","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.6","dist":{"shasum":"e6d81f686e30eca8c20f3796139addf2fc064cca","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.6.tgz","integrity":"sha512-/Pe0Hux+1h63ZJWXsbdiTt/tdGFvL7Us9LwQ27oRrmHGzkmZM2gOxnh86RSu861o8XctCz6DHt2aqA8b+bNhMw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIETogaKMxuibEoYwZr8LflUMPCzaJVtgr39jue3cvvgYAiEAs+RY/7+0dbUEbxQ855U65RCruuqtDFtqrXpeAOBjCKQ="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.7":{"name":"tubesio","version":"0.1.7","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.7","dist":{"shasum":"793846757536a4d36ac8c4229fcf62658d17d542","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.7.tgz","integrity":"sha512-DAPpZm/v/hf7C0QH3kc6+gdVxdub94yjymHZNLzrBoz6l7sXhtA/dk8gJgBM0wuieHqmYa8BLKKLumnOqLId5w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaRTZsp6kkLEGWIJQB8OwWFKqBtFXQXWphwVHyP6CjDwIgdfwXaLvkOcR3VGaPKOl/bzZnMbFMfnnEhkVjcyXWsio="}]},"_from":".","_npmVersion":"1.2.9","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.8":{"name":"tubesio","version":"0.1.8","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.8","dist":{"shasum":"da98068849277f0e82cd1b132b46a7de42a62492","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.8.tgz","integrity":"sha512-B0Vq2b6bLd7EZbVIBv+H0J+8yPt9xG9JymPdwc0Cyn0Hc8RQkb9M38o6Xgy1zORD2NozeMqTuqqfDumc5r4sIA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEacP1w55AgePuEUg6WyKxLWATSrvs0ZSQpzfKNSQWMEAiEAtn8Js5V8YuUf1XsNNlxrfKTXL8A3PUqPnWdzG1Al+VM="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.9":{"name":"tubesio","version":"0.1.9","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.1.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.1.x","optimist":"0.1.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.9","dist":{"shasum":"e3bec5e94a7b8601b811905f48e4a66d66dab9fd","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.9.tgz","integrity":"sha512-mkCSvk3eW9Uc0zABt8xhkvgXzYNsBUR3rXv2L1s14h3u7MpwV7C8cfdznne5GJSVd32NO5fTlbrceYb9Zn2Lxg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGnZtFywuvKkanyp83Y0lDeN9xoXSvKHHELyGlUCm8woAiBGaRvo5r+cucWCpw3LToKM4fgfBi8pOnLOfpBsebo1fA=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.10":{"name":"tubesio","version":"0.1.10","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')(process.env.USERNAME, process.env.API_KEY);\n\n// Optional imports\nvar cheerio = require('cheerio'),\n    request = tubesio.http.request;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n       \n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text()\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies. By convention we can pass these details in directly\nmaking use of the fact that the node runtime environment has your username and \nAPI key set for your convenience. Of course these are just strings and can be\nhard-coded if you require it.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegent HTTP request method. Supports smart \nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.10","dist":{"shasum":"0c375575e6eb21f7ae0e88a544abd497ba2965a0","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.10.tgz","integrity":"sha512-V0EcOdEIJMV2qEB5sUYMnns0hAMhD2MSYj38LbnYGc20+juW+lyhhQxk5FVtKDDhWakLHNOg/v6eFQAXRrhrUQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGb6bnJbWvXiMWAJOHIWftR6k7Q/tYi/ujFtfCcNz6KzAiAdeujzcEN8ZFBWpoQhkoFLmAzuB979JBrj2LI2nb9FcA=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.11":{"name":"tubesio","version":"0.1.11","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be an empty object unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.11","dist":{"shasum":"16a081c1156eb9010bfeb85cb59bcbbf9cfb494a","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.11.tgz","integrity":"sha512-7X+H4/hKcSQLHyu3sIdTVgxwWkGw+zcRlE9cyyubf/dkqJDRuQXbkJ3NQwtD0xHUW7zunoTJhw8A7Uhd0yIuzg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG6c3DVQSW33nbslT9PbdlkBZSvhHv55kC1TLvrUO/ESAiEA/3c1x9M/EkfIeGzb1/fyVRxIfaE5sw4aQ4veIpEKw7k="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.12":{"name":"tubesio","version":"0.1.12","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be an empty object unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.12","dist":{"shasum":"5ce5e5ca3a73ef3bf431d5f57cd3293418788ace","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.12.tgz","integrity":"sha512-6P2hDXdkisgDcRSoOtwNyedXQ4nN7q6+17LyvSJ+dDsSgjaWmZPss/HRaxWDTU3bm2TGOsK3G2yX1mKQ2+2rRQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5jikCiJoNzUMHdfJeWr2axzA88fP5+PsVfkPtDFBprAIgFMqSvQTiQir6AUdC51QwW/HoI2zMrgPMAAtTLvbUSwI="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.13":{"name":"tubesio","version":"0.1.13","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish({ \n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio-finish) completes the request. It's \nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be null unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.13","dist":{"shasum":"0d790e4849c213266388ac61d2c661d2c7ef3f1f","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.13.tgz","integrity":"sha512-FUnkWmbEBfPNuNNPVjEZ97fliHcJcMCSS3q78jLT7tDw7fEjuihF8lYq/RE6/ElKpecQAIRuQYrdQ/8iYd1KcA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDF8tHfOrPK4V2eXboctLO9n1QiBZP87vL3K6QNlaBljwIgPHrXu/+PRorLUBQQ9tEvzUF34IoZ1C270XbpwtDSajE="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.14":{"name":"tubesio","version":"0.1.14","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish(null, {\n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio.finish) completes the request. It's\nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio](#tubesio)\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio\n\n##### tubesio.finish(err, result)\n\nExits the current script.\n\nThe `err` argument if defined and an instance of `Error` will cause the script\nto exit with a non-zero exit code and will print the error message to stderr. The\nexit code defaults to 1 but may be overridden by setting the exitCode property of\nthe err object.\n\nThe `result` argument should be a plain Javascript object representing the\ndata you wish to output. The result will be passed through JSON.stringify and\nprinted to stdout before exiting with exit code 0.\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be null unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.14","dist":{"shasum":"1c1b886fa3fcf427b814aa4c6e463a7fc69c1a03","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.14.tgz","integrity":"sha512-nQ5FdMkjlFbqigEmaS6FjTYW2ZmqV2Pei0BiBlVBgPKAHtm4H+E8KWDi88EHQhptd0cTyFWlxOWiXGUk17RBvQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICueMozxZMXg4e2sAoLF9L1QdqSvjtK3YyBZz2lAG0InAiEArxZ0H6EBl3om7pfz6mc0FmOwOLLAkyY2jNYDR1BpfeI="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.15":{"name":"tubesio","version":"0.1.15","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish(null, {\n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio.finish) completes the request. It's\nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio](#tubesio)\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio\n\n##### tubesio.finish(err, result)\n\nExits the current script.\n\nThe `err` argument if defined and an instance of `Error` will cause the script\nto exit with a non-zero exit code and will print the error message to stderr. The\nexit code defaults to 1 but may be overridden by setting the exitCode property of\nthe err object.\n\nThe `result` argument should be a plain Javascript object representing the\ndata you wish to output. The result will be passed through JSON.stringify and\nprinted to stdout before exiting with exit code 0.\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be null unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.15","dist":{"shasum":"875475c778dc0135e9693f9bd1bbee2d8173c384","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.15.tgz","integrity":"sha512-CrCo2I5tzSyzGycQrb16IDWNEsBlq/c9xuD937khqzTsnkd+qcmUbKwfI6DaVer+cdTy90dN/BBZKkWnVCWbSg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCKkCJFcc2xRkKAcMsJelSrjt34OGDqp95d+02f1FrGXwIhAKegUaxakMT64FUU+5LChTfIjVPOO+NgE1crTowa+5+a"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.16":{"name":"tubesio","version":"0.1.16","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","jsdom":"0.3.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","request":"2.16.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish(null, {\n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio.finish) completes the request. It's\nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio](#tubesio)\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio\n\n##### tubesio.finish(err, result)\n\nExits the current script.\n\nThe `err` argument if defined and an instance of `Error` will cause the script\nto exit with a non-zero exit code and will print the error message to stderr. The\nexit code defaults to 1 but may be overridden by setting the exitCode property of\nthe err object.\n\nThe `result` argument should be a plain Javascript object representing the\ndata you wish to output. The result will be passed through JSON.stringify and\nprinted to stdout before exiting with exit code 0.\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be null unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.16","dist":{"shasum":"975e1b1487f9c26323f693a6cc8e3b8aaa899de3","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.16.tgz","integrity":"sha512-2dchcv9dIQN6gKz0q4cM7k0SUifJjbEdNwbZeUK7LYlL2FBqWeh5p9lcv7hCkt4z2h3ARPXYahS0YtQ30f56OQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBHzOg0LOywKzk+3J23iJEpFyB7N+5qarYLGF62qj8iLAiEAndAYrKA/n+Qfd9+tDgRNS6OZ5vt+o0eCYoALxsp3CQM="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]},"0.1.17":{"name":"tubesio","version":"0.1.17","author":{"name":"tubes.io","email":"support@tubes.io"},"description":"A collection of clients and utilities for interacting with tubes.io services via Node JS.","homepage":"http://tubes.io","bugs":"https://github.com/kuhnza/node-tubesio/issues","contributors":[{"name":"Dave Kuhn","email":"david.s.kuhn@gmail.com"}],"main":"./lib/index.js","preferGlobal":"true","bin":{"tubesio":"./bin/tubesio"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"},"keywords":["tubesio"],"dependencies":{"async":"0.2.x","cheerio":"0.10.x","jsdom":"0.3.x","nconf":"0.6.x","npm":"1.2.x","optimist":"0.3.x","prompt":"0.2.x","request":"2.16.x","tunnel":"0.0.x","underscore":"1.4.x","underscore.string":"2.3.x"},"license":"MIT","engine":{"node":">=0.8.x"},"readme":"<pre>\n       ____   \n______|    |  \n      |    |    __        __                _        \n      |    |   / /___  __/ /_  ___  _____  (_)___   \n      |    |  / __/ / / / __ \\/ _ \\/ ___/ / / __ \\  \n      |    | / /_/ /_/ / /_/ /  __(__  ) / / /_/ /  \n      |    | \\__/\\__,_/_.___/\\___/____(_)_/\\____/   \n______|    |                                        \n      |____|                                         \n</pre>\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. [Command Line Interface](#command-line-interface) (CLI)\n2. [tubesio lib](#tubesio-lib)\n\nThe CLI is used to manage scripts and deployments while the library is meant to be included\nin your node or coffee scripts to provide access to essential tubes.io services such as \nthe proxy servers and other commonly used tools.\n\n## Installation\n\n#### Installing npm\n\n`curl http://npmjs.org/install.sh | sh`\n\n#### Installing tubesio \n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of scripts deployed on tubes.io. This is \nwhat you'll want to use if you plan on developing scripts using\nyour own IDE and storing scripts in some kind of version control\ninstead of the web-based interface.\n\n## Getting Started\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed. It will also create a .tubesio\nfile in the current working directory containing your environment\nconfiguration.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\nYou can test the deployed script by running:\n\n`curl <endpoint URL>`\n\n> Note: be sure to include your API key in the querystring and any other args your tube requires.\n\n## tubesio lib\n\nUsage of the tubesio node library is probably best demonstrated by example. Here's a simple node\nscript that performs a HTTP request, parses the resulting HTML and extracts the page title:\n\n```javascript\n// Required import\nvar tubesio = require('tubesio')('<username>', '<apiKey>');\n\n// Optional imports\nvar cheerio = require('cheerio');\n\n// Shortcuts\nrequest = tubesio.http.request,\nargs = tubesio.utils.args.demand('name'),\nlast = tubesio.utils.lastResult;\n\nrequest('http://tubes.io/', {\n    complete: function (err, body) {\n       if (err) {           \n           return tubesio.finish(err);\n       }\n\n       var $ = cheerio.load(body);\n       tubesio.finish(null, {\n           title: $('title').text(),\n           hello: args.name,\n           lastHello: last.hello\n       });            \n    }\n});\n```\n\nThe first line imports the tubesio lib. Notice the two arguments passed to the\ncall to require. This is required for authentication against tubesio services\nsuch as the HTTP proxies.\n\nNext we import [cheerio](https://github.com/MatthewMueller/cheerio) which is a\nnice, lightweight DOM parsing and normalizing library with support for jQuery\nlike selectors and syntax. We also create a shortcut reference to the tubesio\n[request](#request) method.\n\nAfter that we set up some additional shortcuts to the request method for brevity,\nthe tube arguments (passed as either GET or POST parameters) and the result of\nthe last tube run (this will be populated if you turn on \"Cache Last Result\" in\nyour tube settings).\n\nCalling the request method we pass the URL and attach a callback to the `complete` \nproperty of the request settings object. The callback is passed the body of\nthe resulting HTTP response. We then load the body into cheerio and extract the\ntitle text out. \n\nLastly a call to the [finish](#tubesio.finish) completes the request. It's\nimportant that all code paths eventually call `finish`. Neglecting to do so\nwill cause your script to timeout as the node runtime won't know when\nyour script is finished. The `finish` method is also important because the \ndata you pass to it is what gets returned from the API. \n\n> Note: `finish` only accepts objects that are JSON serializable (i.e. passing \n> a naked number or string won't work).\n\n\n### Modules\n\n* [tubesio](#tubesio)\n* [tubesio.http](#tubesiohttp)\n* [tubesio.logging](#tubesiologging)\n* [tubesio.utils](#tubesioutils)\n\n#### tubesio\n\n##### tubesio.finish(err, result)\n\nExits the current script.\n\nThe `err` argument if defined and an instance of `Error` will cause the script\nto exit with a non-zero exit code and will print the error message to stderr. The\nexit code defaults to 1 but may be overridden by setting the exitCode property of\nthe err object.\n\nThe `result` argument should be a plain Javascript object representing the\ndata you wish to output. The result will be passed through JSON.stringify and\nprinted to stdout before exiting with exit code 0.\n\n#### tubesio.http \n\n##### request(location, [settings])\n\nA vastly simplified and elegant HTTP request method. Supports smart\nswitching between HTTP/HTTPS based on URL, automatic GZIP and DEFLATE \ndecompression, object serialization and proxy servers. \n\n> Important: It's strongly advised that you use this function over \n> node's raw http.request or other third party libraries as it automatically \n> proxies requests via our IP rotation service. We will not provide support\n> for people wishing to use other methods.\n\nThe `location` argument should be a string containing a URL or an object \ncontaining a `location` property set to the URL being requested.\n\nThe `settings` argument can be either a callback function or an object\ncontaining a `complete` property set to the callback function to call\nwhen the request completes.\n\nSettings:\n\n* complete: a callback function that takes the arugments err, body.\n* cookieJar: an instance of CookieJar for cookie support. Defaults to null.\n* data: a string or object. Strings are sent verbatim whilst objects are serialized \naccording to the content-type set in the headers. Method will also be set to `POST` \nwhere method is not explicitly set. Currently detects `application/x-www-form-urlencoded` \nand `application/json`. Where no content-type header exists defaults to form encoding. \n* headers: an object containing key-value pairs of headers to send with request.\n* method: the HTTP method to perform the request with. Defaults to `GET`.\n\n##### setProxy(config)\n\nSets the global proxy configuration object. This will impact all requests during the lifetime\nof the script. Under normal circumstances calling setProxy is not required. Importing\nthe tubesio library automatically configures the correct proxy.\n\nThe `config` argument can be a string, object or function. Strings are processed using\nnode's [url.parse](http://nodejs.org/docs/latest/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost)\nmethod. When passing a function it should produce either a string or configuration object.\n\nConfiguration objects should conform to the following structure:\n\n```javascript\n{\n    host: 'hostname',\n    port: 80,\n    proxyAuth: 'user:pass'\n}\n```\n\n> Note: port and proxyAuth are optional. Defaults to port 80 and no authentication.\n\n##### Class: CookieJar\n\nCookieJar provides cookie support and persistance across HTTP requests. It behaves like\na browser for the most part, simply accepting cookies and storing their values as well \nas passing cookie values with subsequent requests.\n\nAs a rule you shouldn't need to use the CookieJar class directly. Creating a CookieJar\ninstance and passing it with your requests is all that's required.\n\nExample:\n\n```javascript\nvar cookieJar = tubesio.http.CookieJar();\n\nrequest('http://tubes.io', { \n    cookieJar: cookieJar,\n    complete: function () { ... }\n});\n```\n\n> Note: you should create the CookieJar instance in the global scope in order to persist\n> and reuse it across requests.\n\n###### cookieJar.get(key)\n\n###### cookieJar.getValue(key)\n\n###### cookieJar.set(cookieString)\n\n###### cookieJar.toString()\n\n#### tubesio.logging\n\n##### Class: Logger\n\nA logger that logs exclusively to stderr. Includes timestamps in log output \nand supports log level filtering.\n\n###### logger.log(level, message)\n\n###### logger.verbose(message)\n\n###### logger.info(message)\n\n###### logger.warn(message)\n\n###### logger.error(message)\n\n#### tubesio.utils\n\nUtility functions and helpful properties.\n\n##### args\n\nAn object containing your GET or POST parameters.\n\n##### lastResult\n\nAn object containing the result of the last successful run of your tube. One of it's uses is for diffing against the\ncurrent result set to see if anything has changed.\n\nThis property will be null unless \"Cache Last Result\" is turned on within the tube meta/settings.\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","readmeFilename":"README.md","_id":"tubesio@0.1.17","dist":{"shasum":"17a98d3305346832c3cff08a13317224a9b92344","tarball":"https://registry.npmjs.org/tubesio/-/tubesio-0.1.17.tgz","integrity":"sha512-ee4MMcuRapeDl0haZLNSpLecgRxcjyiKTFRyTxsjfzZY7mRBuksuc24IfeUbQanAcXWEL/oVdFyKWoQSVPMKTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDdOYa2kvDj6445IHfMquaSTh1Bb9rwEoGJWlWU+c+uTAiAoxS37pGuRIZOqYBlD2zRHQ6GbC+F/rxQZCc1BqMovJg=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"kuhnza","email":"david.s.kuhn@gmail.com"},"maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}]}},"readme":"# tubes.io library for node\n\nThe tubes.io library for [node](http://nodejs.org) is a collection of clients and utilities for \ninteracting with tubes.io services. The library consists of two parts:\n\n1. The [Command Line Interface](#command-line-interface) (CLI)\n2. The [tubes.io node lib](#tubesio-node-lib)\n\n## Installation\n\n### Installing NPM\n\n`curl http://npmjs.org/install.sh | sh`\n\n### Installing tubes.io CLI\n\n`[sudo] npm install -g tubesio`\n\n\n## Command Line Interface\n\nA command-line interface for interacting with the tubes.io API. \n\nThe tubes.io CLI simplifies the process of environment setup and \nsubsequent management of hub scripts deployed on tubes.io. \n\n## Environment Setup\n\nCreate a working directory where your scripts will live:\n\n`$ mkdir my_username && cd my_username`\n\nThen run:\n\n`$ tubesio init`\n\nThis command will prompt you for your tubes.io username and API\nkey. Your API key can be found on the edit profile page once\nlogged in over at [tubes.io](tubes.io).\n\nThis will download both the necessary and available libraries\nfor your script once deployed.\n\n## Development Workflow\n\nThe current feature set is quite limited. Only automated \ndeployments are supported which means you will need to copy/paste\nexisting scripts from tubes.io to your local environment. Creating\nnew tubes must also be done from the tubes.io website.\n\nBy convention scripts should be named `<slug>.js` where slug\nis the slugified version of your tube's name. For example if your\ntube's name is My 1st Tube then your script name should be\n`my-1st-tube.js`. This generally means replacing spaces and\nspecial charachters with dashes. If you're unsure of what your\ntube's slug name is you should take a look at your tube's endpoint. \nThe slug will be the portion after the last \"/\" and before the format\n\".json\" (e.g. http://tubes.io/username/tube/_my-1st-tube_.json)\n\nOnce you've copied your hub down into your local work directory\nyou can deploy by running:\n\n`$ tubesio deploy my-1st-tube`\n\n> A word of warning: The change will take effect immediately. In\n> case you need to rollback, a backup of the previous script is \n> created with the .bak extension in your working directory. This\n> can be deployed using the `-f` switch to specify an alternate\n> file to use instead of the default. For example:\n>    `$ tubes.io deploy -f my-1st-tube.js.bak my-1st-tube`\n\n## tubes.io node lib\n\n### Modules\n\n* tubesio.[http](#http)\n* tubesio.[logging](#logging)\n* tubesio.[utils](#utils)\n\n#### HTTP \n\nTODO\n\n#### Logging\n\nTODO\n\n#### Utils\n\nTODO\n\n## Supported Languages\n\nOnly JavaScript and CoffeeScript running atop node is supported at present but we have \nplans to add more languages in future. If you'd like a particular language added then\n[let us know](mailto:ideas@tubes.io). The more support we get for a language the greater \nthe chance it will be added.\n\n\n","maintainers":[{"name":"kuhnza","email":"david.s.kuhn@gmail.com"}],"time":{"modified":"2022-06-27T23:08:11.337Z","created":"2012-11-02T20:16:37.474Z","0.1.0":"2012-11-02T20:16:38.454Z","0.1.1":"2012-11-13T04:34:36.487Z","0.1.2":"2012-11-13T23:05:51.044Z","0.1.3":"2012-11-13T23:38:23.978Z","0.1.4":"2012-11-27T20:58:30.909Z","0.1.5":"2012-11-27T22:31:39.322Z","0.1.6":"2012-11-28T05:14:55.749Z","0.1.7":"2013-02-12T02:54:48.769Z","0.1.8":"2013-02-19T02:00:04.806Z","0.1.9":"2013-02-19T02:09:14.649Z","0.1.10":"2013-02-19T03:27:05.852Z","0.1.11":"2013-03-19T03:31:04.090Z","0.1.12":"2013-03-20T00:45:59.565Z","0.1.13":"2013-03-20T02:52:26.782Z","0.1.14":"2013-03-20T06:02:42.443Z","0.1.15":"2013-03-20T14:22:45.428Z","0.1.16":"2013-04-06T00:49:22.071Z","0.1.17":"2013-05-05T13:56:28.829Z"},"author":{"name":"tubes.io","email":"support@tubes.io"},"repository":{"type":"git","url":"https://github.com/kuhnza/node-tubesio.git"}}