Permalink
Browse files

Big commit, tests push function

  • Loading branch information...
1 parent 805f194 commit 44d1c4c63bffc941220e5eacc94f04bae490f134 @arnklint committed Apr 22, 2012
Showing with 31,837 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +19 −0 LICENSE
  3. +1 −1 Makefile
  4. +46 −0 README.md
  5. +17 −0 lib/helpers.js
  6. +2 −0 lib/index.js
  7. +84 −0 lib/prowl.js
  8. +1 −0 node_modules/.bin/_mocha
  9. +1 −0 node_modules/.bin/mocha
  10. +4 −0 node_modules/mocha/.npmignore
  11. +5 −0 node_modules/mocha/.travis.yml
  12. +263 −0 node_modules/mocha/History.md
  13. +22 −0 node_modules/mocha/LICENSE
  14. +99 −0 node_modules/mocha/Makefile
  15. +34 −0 node_modules/mocha/Readme.md
  16. +3,153 −0 node_modules/mocha/_mocha.js
  17. +320 −0 node_modules/mocha/bin/_mocha
  18. +28 −0 node_modules/mocha/bin/mocha
  19. +16 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet
  20. +16 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet
  21. +16 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet
  22. +16 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet
  23. +16 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet
  24. +16 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/Snippets/untitled.tmSnippet
  25. +19 −0 node_modules/mocha/editors/JavaScript mocha.tmbundle/info.plist
  26. BIN node_modules/mocha/images/error.png
  27. BIN node_modules/mocha/images/ok.png
  28. +2 −0 node_modules/mocha/index.js
  29. +6 −0 node_modules/mocha/lib/browser/debug.js
  30. +178 −0 node_modules/mocha/lib/browser/events.js
  31. 0 node_modules/mocha/lib/browser/fs.js
  32. 0 node_modules/mocha/lib/browser/path.js
  33. +125 −0 node_modules/mocha/lib/browser/progress.js
  34. +8 −0 node_modules/mocha/lib/browser/tty.js
  35. +30 −0 node_modules/mocha/lib/hook.js
  36. +86 −0 node_modules/mocha/lib/interfaces/bdd.js
  37. +60 −0 node_modules/mocha/lib/interfaces/exports.js
  38. +5 −0 node_modules/mocha/lib/interfaces/index.js
  39. +91 −0 node_modules/mocha/lib/interfaces/qunit.js
  40. +94 −0 node_modules/mocha/lib/interfaces/tdd.js
  41. +21 −0 node_modules/mocha/lib/mocha.js
  42. +236 −0 node_modules/mocha/lib/reporters/base.js
  43. +74 −0 node_modules/mocha/lib/reporters/doc.js
  44. +62 −0 node_modules/mocha/lib/reporters/dot.js
  45. +154 −0 node_modules/mocha/lib/reporters/html.js
  46. +13 −0 node_modules/mocha/lib/reporters/index.js
  47. +61 −0 node_modules/mocha/lib/reporters/json-stream.js
  48. +70 −0 node_modules/mocha/lib/reporters/json.js
  49. +97 −0 node_modules/mocha/lib/reporters/landing.js
  50. +64 −0 node_modules/mocha/lib/reporters/list.js
  51. +85 −0 node_modules/mocha/lib/reporters/progress.js
  52. +87 −0 node_modules/mocha/lib/reporters/spec.js
  53. +63 −0 node_modules/mocha/lib/reporters/tap.js
  54. +56 −0 node_modules/mocha/lib/reporters/teamcity.js
  55. +101 −0 node_modules/mocha/lib/reporters/xunit.js
  56. +163 −0 node_modules/mocha/lib/runnable.js
  57. +432 −0 node_modules/mocha/lib/runner.js
  58. +238 −0 node_modules/mocha/lib/suite.js
  59. +32 −0 node_modules/mocha/lib/test.js
  60. +175 −0 node_modules/mocha/lib/utils.js
  61. +133 −0 node_modules/mocha/mocha.css
  62. +3,290 −0 node_modules/mocha/mocha.js
  63. +4 −0 node_modules/mocha/node_modules/commander/.npmignore
  64. +4 −0 node_modules/mocha/node_modules/commander/.travis.yml
  65. +99 −0 node_modules/mocha/node_modules/commander/History.md
  66. +7 −0 node_modules/mocha/node_modules/commander/Makefile
  67. +263 −0 node_modules/mocha/node_modules/commander/Readme.md
  68. +2 −0 node_modules/mocha/node_modules/commander/index.js
  69. +992 −0 node_modules/mocha/node_modules/commander/lib/commander.js
  70. +13 −0 node_modules/mocha/node_modules/commander/package.json
  71. +4 −0 node_modules/mocha/node_modules/debug/.npmignore
  72. +41 −0 node_modules/mocha/node_modules/debug/History.md
  73. +5 −0 node_modules/mocha/node_modules/debug/Makefile
  74. +130 −0 node_modules/mocha/node_modules/debug/Readme.md
  75. +122 −0 node_modules/mocha/node_modules/debug/debug.js
  76. +19 −0 node_modules/mocha/node_modules/debug/example/app.js
  77. +24 −0 node_modules/mocha/node_modules/debug/example/browser.html
  78. +10 −0 node_modules/mocha/node_modules/debug/example/wildcards.js
  79. +22 −0 node_modules/mocha/node_modules/debug/example/worker.js
  80. +2 −0 node_modules/mocha/node_modules/debug/index.js
  81. +147 −0 node_modules/mocha/node_modules/debug/lib/debug.js
  82. +11 −0 node_modules/mocha/node_modules/debug/package.json
  83. +37 −0 node_modules/mocha/node_modules/growl/History.md
  84. +83 −0 node_modules/mocha/node_modules/growl/Readme.md
  85. +159 −0 node_modules/mocha/node_modules/growl/lib/growl.js
  86. +6 −0 node_modules/mocha/node_modules/growl/package.json
  87. +16 −0 node_modules/mocha/node_modules/growl/test.js
  88. +21 −0 node_modules/mocha/package.json
  89. +55 −0 node_modules/request/LICENSE
  90. +287 −0 node_modules/request/README.md
  91. +103 −0 node_modules/request/forever.js
  92. +913 −0 node_modules/request/main.js
  93. +152 −0 node_modules/request/mimetypes.js
  94. +34 −0 node_modules/request/oauth.js
  95. +15 −0 node_modules/request/package.json
  96. BIN node_modules/request/tests/googledoodle.png
  97. +38 −0 node_modules/request/tests/run.js
  98. +82 −0 node_modules/request/tests/server.js
  99. +77 −0 node_modules/request/tests/squid.conf
  100. +20 −0 node_modules/request/tests/ssl/ca/ca.cnf
  101. 0 node_modules/request/tests/ssl/ca/ca.crl
  102. +17 −0 node_modules/request/tests/ssl/ca/ca.crt
  103. +13 −0 node_modules/request/tests/ssl/ca/ca.csr
  104. +18 −0 node_modules/request/tests/ssl/ca/ca.key
  105. +1 −0 node_modules/request/tests/ssl/ca/ca.srl
  106. +19 −0 node_modules/request/tests/ssl/ca/server.cnf
  107. +16 −0 node_modules/request/tests/ssl/ca/server.crt
  108. +11 −0 node_modules/request/tests/ssl/ca/server.csr
  109. +28 −0 node_modules/request/tests/ssl/ca/server.js
  110. +9 −0 node_modules/request/tests/ssl/ca/server.key
  111. +16 −0 node_modules/request/tests/ssl/npm-ca.crt
  112. +15 −0 node_modules/request/tests/ssl/test.crt
  113. +15 −0 node_modules/request/tests/ssl/test.key
  114. +95 −0 node_modules/request/tests/test-body.js
  115. +29 −0 node_modules/request/tests/test-cookie.js
  116. +90 −0 node_modules/request/tests/test-cookiejar.js
  117. +68 −0 node_modules/request/tests/test-defaults.js
  118. +37 −0 node_modules/request/tests/test-errors.js
  119. +52 −0 node_modules/request/tests/test-headers.js
  120. +94 −0 node_modules/request/tests/test-httpModule.js
  121. +97 −0 node_modules/request/tests/test-https-strict.js
  122. +86 −0 node_modules/request/tests/test-https.js
  123. +117 −0 node_modules/request/tests/test-oauth.js
  124. +92 −0 node_modules/request/tests/test-params.js
  125. +202 −0 node_modules/request/tests/test-pipes.js
  126. +39 −0 node_modules/request/tests/test-proxy.js
  127. +28 −0 node_modules/request/tests/test-qs.js
  128. +154 −0 node_modules/request/tests/test-redirect.js
  129. +87 −0 node_modules/request/tests/test-timeout.js
  130. +14 −0 node_modules/request/tests/test-toJSON.js
  131. +61 −0 node_modules/request/tests/test-tunnel.js
  132. +229 −0 node_modules/request/tunnel.js
  133. +19 −0 node_modules/request/uuid.js
  134. +65 −0 node_modules/request/vendor/cookie/index.js
  135. +72 −0 node_modules/request/vendor/cookie/jar.js
  136. +3 −0 node_modules/should/.gitmodules
  137. +1 −0 node_modules/should/.npmignore
  138. +106 −0 node_modules/should/History.md
  139. +6 −0 node_modules/should/Makefile
  140. +367 −0 node_modules/should/Readme.md
  141. +53 −0 node_modules/should/examples/runner.js
  142. +2 −0 node_modules/should/index.js
  143. +91 −0 node_modules/should/lib/eql.js
  144. +701 −0 node_modules/should/lib/should.js
  145. +13 −0 node_modules/should/package.json
  146. +96 −0 node_modules/should/test/exist.test.js
  147. +557 −0 node_modules/should/test/should.test.js
  148. +2 −0 node_modules/xml2js/.npmignore
  149. +12 −0 node_modules/xml2js/Cakefile
  150. +19 −0 node_modules/xml2js/LICENSE
  151. +139 −0 node_modules/xml2js/README.md
  152. +152 −0 node_modules/xml2js/lib/xml2js.js
  153. +9 −0 node_modules/xml2js/node_modules/sax/AUTHORS
  154. +23 −0 node_modules/xml2js/node_modules/sax/LICENSE
  155. +215 −0 node_modules/xml2js/node_modules/sax/README.md
  156. +8,002 −0 node_modules/xml2js/node_modules/sax/examples/big-not-pretty.xml
  157. +41 −0 node_modules/xml2js/node_modules/sax/examples/example.js
  158. +58 −0 node_modules/xml2js/node_modules/sax/examples/get-products.js
  159. +4 −0 node_modules/xml2js/node_modules/sax/examples/hello-world.js
  160. +8 −0 node_modules/xml2js/node_modules/sax/examples/not-pretty.xml
  161. +74 −0 node_modules/xml2js/node_modules/sax/examples/pretty-print.js
  162. +2 −0 node_modules/xml2js/node_modules/sax/examples/shopping.xml
  163. +870 −0 node_modules/xml2js/node_modules/sax/examples/strict.dtd
  164. +45 −0 node_modules/xml2js/node_modules/sax/examples/switch-bench.js
  165. +15 −0 node_modules/xml2js/node_modules/sax/examples/test.html
  166. +1,254 −0 node_modules/xml2js/node_modules/sax/examples/test.xml
  167. +1,007 −0 node_modules/xml2js/node_modules/sax/lib/sax.js
  168. +10 −0 node_modules/xml2js/node_modules/sax/package.json
  169. +25 −0 node_modules/xml2js/node_modules/sax/test/buffer-overrun.js
  170. +47 −0 node_modules/xml2js/node_modules/sax/test/case.js
  171. +11 −0 node_modules/xml2js/node_modules/sax/test/cdata-chunked.js
  172. +15 −0 node_modules/xml2js/node_modules/sax/test/cdata-end-split.js
  173. +28 −0 node_modules/xml2js/node_modules/sax/test/cdata-fake-end.js
  174. +15 −0 node_modules/xml2js/node_modules/sax/test/cdata-multiple.js
  175. +10 −0 node_modules/xml2js/node_modules/sax/test/cdata.js
  176. +86 −0 node_modules/xml2js/node_modules/sax/test/index.js
  177. +43 −0 node_modules/xml2js/node_modules/sax/test/issue-23.js
  178. +24 −0 node_modules/xml2js/node_modules/sax/test/issue-30.js
  179. +15 −0 node_modules/xml2js/node_modules/sax/test/issue-35.js
  180. +13 −0 node_modules/xml2js/node_modules/sax/test/issue-47.js
  181. +31 −0 node_modules/xml2js/node_modules/sax/test/issue-49.js
  182. +28 −0 node_modules/xml2js/node_modules/sax/test/parser-position.js
  183. +12 −0 node_modules/xml2js/node_modules/sax/test/script.js
  184. +40 −0 node_modules/xml2js/node_modules/sax/test/self-closing-child-strict.js
  185. +40 −0 node_modules/xml2js/node_modules/sax/test/self-closing-child.js
  186. +25 −0 node_modules/xml2js/node_modules/sax/test/self-closing-tag.js
  187. +17 −0 node_modules/xml2js/node_modules/sax/test/stray-ending.js
  188. +17 −0 node_modules/xml2js/node_modules/sax/test/trailing-non-whitespace.js
  189. +17 −0 node_modules/xml2js/node_modules/sax/test/unquoted.js
  190. +67 −0 node_modules/xml2js/node_modules/sax/test/xmlns-issue-41.js
  191. +59 −0 node_modules/xml2js/node_modules/sax/test/xmlns-rebinding.js
  192. +71 −0 node_modules/xml2js/node_modules/sax/test/xmlns-strict.js
  193. +15 −0 node_modules/xml2js/node_modules/sax/test/xmlns-unbound.js
  194. +35 −0 node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js
  195. +20 −0 node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix.js
  196. +40 −0 node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-redefine.js
  197. +37 −0 node_modules/xml2js/package.json
  198. +142 −0 node_modules/xml2js/src/xml2js.coffee
  199. +34 −0 node_modules/xml2js/test/fixtures/sample.xml
  200. +154 −0 node_modules/xml2js/test/xml2js.test.coffee
  201. +4 −4 package.json
  202. +12 −0 test/all.js
View
@@ -0,0 +1 @@
+./node_modules
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright 2010, 2011. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
View
@@ -1,4 +1,4 @@
test:
- @./node_modules/.bin/mocha -w --reporter list --require tobi should --globals encoding --timeout 10000
+ @./node_modules/.bin/mocha -w --reporter list --require should --globals encoding --timeout 10000
.PHONY: test
View
@@ -0,0 +1,46 @@
+# Prowl Node.js API
+
+Be happy! Send push notifications to iDevices (iPad, iPhone etc) that
+has the [Prowl iPhone app](http://www.prowlapp.com/) installed. Simple,
+easy and clean.
+
+As of now this API supports push and only push.
+
+## Installation
+
+ npm install prowl
+
+or put it in your package.json as usual and hit npm install. It depends
+on xml2js and request.
+
+## Usage
+
+The API requires your API-key, which could be found or created on the
+"API Keys" tab on the [Prowl website](http://www.prowlapp.com/).
+
+Initialize it with your key and start pushing!
+
+ var prowl = new Prowl('MY-API-KEY');
+ prowl.push('YO, this is awesomez!', 'My app', function( err, remaining ){
+ if( err ) throw err;
+ console.log( 'I have ' + remaining + ' calls to the api during current hour. BOOM!' );
+ });
+
+## Contribute
+
+I´d be happy if you wanted to contribute with pull requests or tips.
+I´ll add you to the contributors list here and in the package.json file.
+
+## Testing
+
+While contributing, make sure to write a test and make it pass if you
+extend the library. Tests are written in the test directory, preferably
+in all.js, since its quite small right now. It uses should.js and mocha
+for tests.
+
+Test by installing mocha and should.js (dev dependencies) and then just
+hit:
+
+PROWL_KEY=[my key here] make
+
+And voila, it autotests for you.
View
@@ -0,0 +1,17 @@
+/**
+ * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
+ * @param obj1
+ * @param obj2
+ * @returns obj3 a new object based on obj1 and obj2
+ */
+
+function merge( obj1, obj2 ){
+ var obj3 = {};
+ for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
+ for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
+ return obj3;
+}
+
+module.exports = {
+ merge: merge
+}
View
@@ -0,0 +1,2 @@
+var prowl = require('./prowl');
+module.export = prowl;
View
@@ -0,0 +1,84 @@
+var request = require('request'),
+ querystring = require('querystring'),
+ helpers = require('./helpers'),
+ xml2js = require('xml2js'),
+ parser = new xml2js.Parser();
+
+/**
+ * Prowl - send PUSH notification to you iDevice (iPhone, iPad)
+ */
+function Prowl( apiKey ){
+ this.apiKey = apiKey || undefined;
+
+ this.endpoint = "https://api.prowlapp.com/publicapi/";
+}
+
+
+/**
+ * push - send push notification
+ *
+ * Example
+ *
+ * var prowl = new Prowl('MY-API-KEY');
+ * prowl.push('YO, this is awesomez!', 'My app', function( err, remaining ){
+ * if( err ) throw err;
+ * console.log( 'I have ' + remaining + ' calls to the api during current hour' );
+ * });
+ *
+ * @param {String} event - the event name
+ * @param {String} application - the name of your application or the application generating the event
+ * @optional {Object} options
+ * * providerkey: optional provider key
+ * * priority: from -2 to 2, Emergency priority messages may bypass quiet hours according to the user's settings.
+ * * url: The URL which should be attached to the notification.
+ * @param {Function} callback - calls back with to parameters; error message if any, and remaining api calls until you reach prowls limit
+ *
+ * @public
+ */
+
+var push = function( event, application, options, callback ){
+ if( !application ) throw new Error("Second parameter \'application\' is missing");
+
+ var me = this;
+ if( typeof options == 'function' ){
+ callback = options;
+ options = {};
+ }
+
+ var defaults = {
+ providerkey: null,
+ priority: 0,
+ url: null
+ }
+
+ var options = helpers.merge( defaults, options );
+
+ var query = { event: event,
+ application: application,
+ apikey: me.apiKey,
+ providerkey: options.providerkey,
+ priority: options.priority,
+ url: options.url
+ }
+
+ var url = me.endpoint + 'add?' + querystring.stringify( query );
+
+ request({
+ method: 'POST',
+ uri: url
+ }, function( err, res ){
+ parser.parseString(res.body, function (err, result) {
+ var error = null;
+ if( err ) error = err;
+ if( !result['success'] ) error = err;
+
+ callback( error, result['success']['@']['remaining']*1 );
+ });
+ })
+}
+
+Prowl.prototype = {
+ push: push
+}
+
+module.exports = Prowl;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 44d1c4c

Please sign in to comment.