Matt Ryall avatar Matt Ryall committed 4fe7c32

Include node_modules directory, but ignore the fact that it's in git

Comments (0)

Files changed (7)

node_modules/node-restclient/LICENSE

+Copyright 2009, Chris Williams. http://voodootikigod.com 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.

node_modules/node-restclient/README.md

+Node RestClient
+===============
+
+Sometimes dabbling in HTTP Client connection and body processing can get messy. Never fear, Node-RestClient is here! Sporting a spiffy "jQuery" style familiar API, Node-RestClient bends to your every whim.
+
+Examples
+--------
+
+
+	var restclient = require('./restclient'), sys = require("sys");
+	restclient.get("http://twitter.com/statuses/show/4.json", function(result) { sys.puts(result); }, "json");
+	restclient.post("http://username:password@twitter.com/statuses/update.json", {status: "I love Node.js"}, function(result) { sys.puts(result);  }, "json");
+
+API
+---
+
+`
+restclient.get( url, [data], [callback], [type] )
+`
+
+**url** A standard URL or a Basic Authentication encoded URL (as shown above), it will automatically figure out what to do! Optional.
+
+**data** Key/value pairs that will be sent to the server. Optional.
+
+**callback** A function to be executed whenever the data is loaded successfully. Optional.
+
+**type** Either "text" or "json". Optional.
+
+
+Summary
+-------
+
+And just like that you can consume web-services with the elegance of a ruby, but the speed of a V8! Due note that just like jQuery, the result returned will be a JSON object if "json" is specified as the type.

node_modules/node-restclient/lib/base64.js

+/**
+ * Refactored variant in order to properly encapsulate private/protected 
+ * methods within a functional scope and make things look a lot cleaner 
+ * and lintier for greater good. 
+ *
+ * @voodootikigod
+ */
+
+ 
+/**
+ *
+ *  Base64 encode / decode
+ *  Adapted from: http://www.webtoolkit.info/
+ *
+ **/
+
+var Base64 = (function() {
+ 
+  // private property
+  var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+
+  // private method for UTF-8 encoding
+  var _utf8_encode = function (string) {
+    string = string.replace(/\r\n/g,"\n");
+    var utftext = "";
+    for (var n = 0; n < string.length; n++) {
+      var c = string.charCodeAt(n);
+      if (c < 128) {
+        utftext += String.fromCharCode(c);
+      }
+      else if((c > 127) && (c < 2048)) {
+        utftext += String.fromCharCode((c >> 6) | 192);
+        utftext += String.fromCharCode((c & 63) | 128);
+      }
+      else {
+        utftext += String.fromCharCode((c >> 12) | 224);
+        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+        utftext += String.fromCharCode((c & 63) | 128);
+      }
+    }
+    return utftext;
+  };
+ 
+  // private method for UTF-8 decoding
+  var _utf8_decode = function (utftext) {
+    var string = "";
+    var i = 0;
+    var c = c1 = c2 = 0;
+    while ( i < utftext.length ) {
+      c = utftext.charCodeAt(i);
+      if (c < 128) {
+        string += String.fromCharCode(c);
+        i++;
+      }
+      else if((c > 191) && (c < 224)) {
+        c2 = utftext.charCodeAt(i+1);
+        string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
+        i += 2;
+      }
+      else {
+        c2 = utftext.charCodeAt(i+1);
+        c3 = utftext.charCodeAt(i+2);
+        string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+        i += 3;
+      }
+    }
+    return string;
+  };
+
+
+  return {
+    encode : function (input) {
+      var output = "";
+      var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
+      var i = 0;
+ 
+      input = _utf8_encode(input);
+ 
+      while (i < input.length) {
+ 
+        chr1 = input.charCodeAt(i++);
+        chr2 = input.charCodeAt(i++);
+        chr3 = input.charCodeAt(i++);
+ 
+        enc1 = chr1 >> 2;
+        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+        enc4 = chr3 & 63;
+ 
+        if (isNaN(chr2)) {
+          enc3 = enc4 = 64;
+        } else if (isNaN(chr3)) {
+          enc4 = 64;
+        }
+
+        output = output +
+        _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
+        _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
+ 
+      }
+ 
+      return output;
+    },
+ 
+    // public method for decoding
+    decode : function (input) {
+      var output = "";
+      var chr1, chr2, chr3;
+      var enc1, enc2, enc3, enc4;
+      var i = 0;
+ 
+      input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
+ 
+      while (i < input.length) {
+ 
+        enc1 = _keyStr.indexOf(input.charAt(i++));
+        enc2 = _keyStr.indexOf(input.charAt(i++));
+        enc3 = _keyStr.indexOf(input.charAt(i++));
+        enc4 = _keyStr.indexOf(input.charAt(i++));
+ 
+        chr1 = (enc1 << 2) | (enc2 >> 4);
+        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+        chr3 = ((enc3 & 3) << 6) | enc4;
+ 
+        output = output + String.fromCharCode(chr1);
+ 
+        if (enc3 != 64) {
+          output = output + String.fromCharCode(chr2);
+        }
+        if (enc4 != 64) {
+          output = output + String.fromCharCode(chr3);
+        }
+ 
+      }
+ 
+      output = _utf8_decode(output);
+ 
+      return output;
+ 
+    }
+  }
+})()
+
+exports.encode = Base64.encode;
+exports.decode = Base64.decode;

node_modules/node-restclient/lib/restclient.js

+/**
+ * restclient.js
+ *
+ * Getting down with the funkiness that is the HTTP Client of node.js and making
+ * it shine like jQuery. This library wraps up all the complexities of using node.js
+ * to process HTTP requests and presents them in a simple format of:
+ *
+ * client.VERB(url, [data], [callback], [type])
+ *
+ * If you provide data it will be encoded and sent as part of the body. If you provide
+ * a callback it will automatically be passed the resulting body message. If you provide
+ * a type of "json", it will attempt to convert prior to issueing the callback.
+ *
+ * Oh and it wraps up Basic Auth as if it were bacon!
+ *
+ * @voodootikigod
+ */
+ 
+var http = require("http"), base64 = require("./base64"), URL = require("url");
+
+
+var RestClient = (function () {  
+  
+  /*!
+   * param function is adapted from the 
+   * jQuery JavaScript Library v1.3.2
+   * http://jquery.com/
+   *
+   * param function is Copyright (c) 2009 John Resig
+   * Dual licensed under the MIT and GPL licenses.
+   * http://docs.jquery.com/License
+   */
+  var params = function( a ) {
+    var s = [ ];
+    function isArray( obj ) {
+      return toString.call(obj) === "[object Array]";
+    }
+    function isFunction( obj ) {
+      return toString.call(obj) === "[object Function]";
+    }
+    function add( key, value ){
+      s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
+    };
+    // Serialize the key/values
+    for ( var j in a )
+      // If the value is an array then the key names need to be repeated
+      if ( isArray(a[j]) ) {
+        var l = a[j].length;
+        for(var i=0; i<l; i++) {
+          add( j, a[j][i] );
+        }
+      } else {
+        add( j, isFunction(a[j]) ? a[j]() : a[j] );
+      }
+    // Return the resulting serialization
+    return s.join("&").replace(/%20/g, "+");
+  };
+  
+  
+  var rest_call = function (method, url, data, callback, type, headers) {
+    if (typeof data === "function")  {
+      type = callback;
+      callback = data;
+      data = null;
+    }
+    if (typeof callback === "string") {
+      type = callback;
+    }
+    var uri = URL.parse(url);
+    headers = headers || {};
+    if (!headers["Host"] && uri.hostname) {
+      headers["Host"] = uri.hostname;
+    }
+    if (!headers["User-Agent"]) {
+      headers["User-Agent"] = "Node.js HTTP Client";
+    }
+    if (!headers["Authorization"] && uri.auth) {
+      headers["Authorization"] = "Basic "+base64.encode(uri.auth);
+    }
+    if (!headers["Accept"] && type == "json") {
+      headers["Accept"] = "application/json";
+    }
+    var path = (uri.pathname || "/");
+    var port = uri.port || (uri.protocol == "https:" ? 443 : 80);
+    var client = http.createClient(port, uri.hostname);
+    var encoded_data = typeof data === "object" ? params(data) : data;
+    if (uri.search) {
+      path += uri.search;
+    } else if ((method == "GET" || method == "DELETE") && encoded_data) {
+      path += "?" + encoded_data;
+    } else if (method == "POST" || method == "PUT") {
+      headers["Content-Length"] = encoded_data.length;
+    }
+    
+    var request = client.request(method, path, headers);
+    if ((method == "POST" || method == "PUT") && encoded_data) {
+      request.write(encoded_data);
+    }
+    if (typeof callback === "function") {
+      request.on("response", function (response) {
+        var body = "";
+        response.addListener("data", function (chunk) {
+          body += chunk;
+        });
+        response.addListener("end", function () {
+          if (type == "json") {
+            callback(body.length > 0 ? JSON.parse(body) : {}, response.statusCode);
+          } else {
+            callback(body, response.statusCode);
+          }
+        });
+      });
+    }
+    request.end();
+    return request;
+  };
+  return {
+    get: function(url, data, callback, type, headers) {
+      var res = rest_call('GET', url, data, callback, type, headers);
+      return res;
+    },
+    post: function(url, data, callback, type, headers) {
+      var res = rest_call('POST',url, data, callback, type, headers);
+      return res;
+    },
+    head: function(url, data, callback, type, headers) {
+      var res = rest_call('HEAD', url, data, callback, type, headers);
+      return res;
+    },
+    put: function(url, data, callback, type, headers) {
+      var res = rest_call('PUT', url, data, callback, type, headers);  
+      return res;
+    },
+    del: function(url, data, callback, type, headers) {
+      var res = rest_call('DELETE', url, data, callback, type, headers);
+      return res;
+    }
+  }
+  
+})()
+
+exports.get = RestClient.get;
+exports.post = RestClient.post;
+exports.head = RestClient.head;
+exports.put = RestClient.put;
+exports.del = RestClient.del;

node_modules/node-restclient/package.json

+{
+  "name" : "node-restclient",
+  "version" : "0.0.1",
+  "description" : "node-restclient adds easy-to-use api for basic http methods",
+  "keywords": ["rest", "http"],
+  "engines": ["node"],
+  "directories": {"lib" : "./lib"},
+  "main" : "./lib/restclient.js"
+}

node_modules/node-restclient/test/twitter.js

+var sys = require('sys');
+var restclient = require('../lib/restclient');
+var fail = false
+
+
+// Test JSON encoding
+var res = restclient.get("http://twitter.com/statuses/public_timeline.json", function(result) {
+  if ((typeof result !== "object")) {
+    fail = true;
+  }
+}, "json");
+
+
+// Test Non-JSON encoding
+restclient.get("http://twitter.com/statuses/public_timeline.json", function(result) {
+  if ((typeof result !== "string")) {
+    fail = true;
+  }
+});
+
+
+// Test sending data encoding
+restclient.get("http://search.twitter.com/search.json",  {q: "node", show_user: "true"}, function(result) {
+  if ((typeof result !== "object")) {
+    fail = true;
+  }
+}, "json");
+
+
+
+process.addListener("exit", function () {
+  if (fail) {
+    sys.puts("Get it right -- or else!!!");
+  }
+});
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.