Skip to content

Commit

Permalink
Rebuild SimpleYUI without the Node.js modules included.
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Apr 5, 2012
1 parent 24de82a commit 6ec2ebd
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 402 deletions.
136 changes: 0 additions & 136 deletions build/simpleyui/simpleyui-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -19583,142 +19583,6 @@ YUI.add('dump', function(Y) {


}, '@VERSION@' ,{requires:['yui-base']});
YUI.add('io-nodejs', function(Y) {

/*global Y: false, Buffer: false, clearInterval: false, clearTimeout: false, console: false, exports: false, global: false, module: false, process: false, querystring: false, require: false, setInterval: false, setTimeout: false, __filename: false, __dirname: false */

/**
* Passthru to the NodeJS <a href="https://github.com/mikeal/request">request</a> module.
* This method is return of `require('request')` so you can use it inside NodeJS without
* the IO abstraction.
* @method request
* @static
*/
if (!Y.IO.request) {
Y.IO.request = require('request');
}

Y.log('Loading NodeJS Request Transport', 'info', 'io');

/**
NodeJS IO transport, uses the NodeJS <a href="https://github.com/mikeal/request">request</a>
module under the hood to perform all network IO.
@method transports.nodejs
@static
@returns {Object} This object contains only a `send` method that accepts a
`transaction object`, `uri` and the `config object`.
@example

Y.io('https://somedomain.com/url', {
method: 'PUT',
data: '?foo=bar',
//Extra request module config options.
request: {
maxRedirects: 100,
strictSSL: true,
multipart: [
{
'content-type': 'application/json',
body: JSON.stringify({
foo: 'bar',
_attachments: {
'message.txt': {
follows: true,
length: 18,
'content_type': 'text/plain'
}
}
})
},
{
body: 'I am an attachment'
}
]
},
on: {
success: function(id, e) {
Y.log(e.responseText);
}
}
});
*/

var flatten = function(o) {
var str = [];
Object.keys(o).forEach(function(name) {
str.push(name + ': ' + o[name]);
});
return str.join('\n');
};

Y.IO.transports.nodejs = function() {
return {
send: function (transaction, uri, config) {

Y.log('Starting Request Transaction', 'info', 'io');
config.notify('start', transaction, config);
config.method = config.method || 'GET';

var rconf = {
method: config.method,
uri: uri
};
if (config.data) {
rconf.body = config.data;
}
if (config.headers) {
rconf.headers = config.headers;
}
if (config.timeout) {
rconf.timeout = config.timeout;
}
if (config.request) {
Y.mix(rconf, config.request);
}
Y.log('Initiating ' + rconf.method + ' request to: ' + rconf.uri, 'info', 'io');
Y.IO.request(rconf, function(err, data) {
Y.log('Request Transaction Complete', 'info', 'io');

if (err) {
Y.log('An IO error occurred', 'warn', 'io');
transaction.c = err;
config.notify(((err.code === 'ETIMEDOUT') ? 'timeout' : 'failure'), transaction, config);
return;
}
if (data) {
transaction.c = {
status: data.statusCode,
statusCode: data.statusCode,
headers: data.headers,
responseText: data.body,
responseXML: null,
getResponseHeader: function(name) {
return this.headers[name];
},
getAllResponseHeaders: function() {
return flatten(this.headers);
}
};
}
Y.log('Request Transaction Complete', 'info', 'io');

config.notify('complete', transaction, config);
config.notify(((data && (data.statusCode >= 200 && data.statusCode <= 299)) ? 'success' : 'failure'), transaction, config);
});

var ret = {
io: transaction
};
return ret;
}
};
};

Y.IO.defaultTransport('nodejs');



}, '@VERSION@' ,{requires:['io-base']});
YUI.add('transition-timer', function(Y) {

/*
Expand Down
Loading

0 comments on commit 6ec2ebd

Please sign in to comment.