Permalink
Browse files

More Interface Updates, removed the class and made it static now

  • Loading branch information...
1 parent 4cc3ba8 commit 43f8c416b93c38e661fb85750c60ecd0fe999113 @davglass davglass committed Jan 14, 2011
Showing with 52 additions and 33 deletions.
  1. +7 −7 examples/rls.js
  2. +4 −4 examples/versions.js
  3. +23 −18 lib/node-yui3.js
  4. +0 −1 lib/yui3-yui3.js
  5. +18 −3 tests/interface.js
View
@@ -2,25 +2,25 @@
var yui3 = require('yui3');
yui3.rls({
- m: 'yui,loader,dd,widget,autocomplete,gallery-yql,yui2-datatable',
- //m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
- //env: 'node,attribute',
- v: '3.3.0pr3',
+ //m: 'yui,loader,dd,widget,autocomplete,gallery-yql,yui2-datatable',
+ m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
+ env: 'node,attribute',
+ v: '3.3.0',
gv: '2010.09.22',
'2in3v': '0.0.3'//,
//filt: 'RAW',
}, function(js, css, data) {
console.log('Callback..');
console.log(js);
console.log(css);
- //console.log(data);
- /*
+ var size = 0;
for (var i in data) {
+ size += data[i].length;
console.log('i: ', i, (data[i].length));
}
- */
console.log('Total: ', [].concat(js, css).length);
console.log('Data: ', Object.keys(data).length);
+ console.log('Size: (bytes)', size);
});
@@ -18,7 +18,8 @@ npm.load(config, function() {
var installed = {};
for (var i in data) {
if (i.match(/yui3-/)) {
- installed[i] = data[i].versions;
+ var c = i.split('@');
+ installed[c[0]] = data[i].data.versions;
}
}
start(installed);
@@ -29,7 +30,6 @@ var express = require('express'),
app = express.createServer();
var start = function(mods) {
-
var qs = require('querystring');
@@ -79,9 +79,9 @@ var start = function(mods) {
YUIConfig['2in3'] = p.yui2;
}
var yui3 = require('yui3');
- var YUI = yui3.configure(YUIConfig);
+ var YUI = yui3.configure(YUIConfig).YUI;
- out += '<h1>YUI Loaded From Config</h1>'
+ out += '<h1>YUI Loaded From Config</h1>';
out += 'Core: ' + YUI.GlobalConfig.base + '<br>';
if (YUI.GlobalConfig.groups && YUI.GlobalConfig.groups.gallery) {
out += 'Gallery: ' + YUI.GlobalConfig.groups.gallery.base + '<br>';
View
@@ -1,9 +1,9 @@
var getYUI = function(c) {
var yui3 = require('./yui3-yui3');
var YUI = yui3.configure(c);
- if (c) {
+ //if (c) {
cleanCache();
- }
+ //}
return YUI;
}
@@ -20,46 +20,51 @@ var cleanCache = function() {
// var Y = yui3.useSync("io");
// var Y = yui3.configure({core:"3.3.0"}).useSync("io");
// See also: tests/interface.js
-
-function YInterface (config) {
- this.config = config || {};
-}
-
-var interface = YInterface.prototype;
+var interface = {};
interface.__defineGetter__('YUI', function() {
- var YUI = getYUI(this.config);
+ var YUI = getYUI();
return YUI;
});
-
-interface.sync = function() {
- var YUI = getYUI(this.config);
+interface.silent = function(c) {
+ var YUI = getYUI(c);
+ return YUI({ debug: false });
+};
+interface.sync = function(c) {
+ var YUI = getYUI(c);
YUI.loadSync = true;
return YUI();
};
-interface.async = function() {
- var YUI = getYUI(this.config);
+interface.async = function(c) {
+ var YUI = getYUI(c);
YUI.loadSync = false;
return YUI();
};
interface.useSync = function() {
- var YUI = getYUI(this.config);
+ var YUI = getYUI();
YUI.loadSync = true;
var Y = YUI();
return Y.use.apply(Y, arguments);
}
interface.use = function() {
- var YUI = getYUI(this.config);
+ var YUI = getYUI();
YUI.loadSync = false;
var Y = YUI();
return Y.use.apply(Y, arguments);
}
interface.configure = function (config) {
- return new YInterface(config);
+ var YUI = getYUI(config);
+ var Y = YUI();
+ //Workaround for old school .YUI access..
+ Y.__defineGetter__('YUI', function() {
+ var YUI = getYUI(config);
+ return YUI;
+ });
+ return Y;
};
/**
@@ -82,4 +87,4 @@ interface.rls = function(config, fn) {
}
-module.exports = new YInterface;
+module.exports = interface;
View
@@ -22,7 +22,6 @@ exports.configure = function(c) {
c[i] = '@' + c[i];
}
}
-
//Is gallery installed?
var gallery = false,
//Is the 2in3 project installed?
View
@@ -5,7 +5,7 @@ var assert = require("assert"),
module.exports = {
"yui3.useSync" : function () {
- var Y = yui3.useSync("loader");
+ var Y = yui3.silent().useSync("loader");
assert.ok(Y.Loader);
},
"yui3.configure({}).useSync" : function () {
@@ -18,12 +18,27 @@ module.exports = {
assert.isUndefined(Y.Loader);
},
"yui3.configure({}).YUI" : function () {
- var Y = yui3.configure({ debug: false }).YUI;
+ var Y = yui3.configure({}).YUI;
assert.ok(Y);
+ assert.ok(Y.GlobalConfig);
+ assert.isUndefined(Y.Loader);
+ },
+ "yui3.configure({ core: '3.2.0' }).YUI" : function () {
+ var Y = yui3.configure({ core: '3.2.0' }).YUI;
+ assert.ok(Y);
+ assert.ok(Y.GlobalConfig);
+ assert.notEqual(Y.GlobalConfig.base.indexOf('3.2.0'), -1);
+ assert.isUndefined(Y.Loader);
+ },
+ "yui3.configure({ core: '3.3.0pr3' }).YUI" : function () {
+ var Y = yui3.configure({ core: '3.3.0pr3' }).YUI;
+ assert.ok(Y);
+ assert.ok(Y.GlobalConfig);
+ assert.notEqual(Y.GlobalConfig.base.indexOf('3.3.0pr3'), -1);
assert.isUndefined(Y.Loader);
},
"yui3.use" : function () {
- yui3.use("loader", function (Y) {
+ yui3.silent().use("loader", function (Y) {
assert.ok(Y.Loader);
});
},

0 comments on commit 43f8c41

Please sign in to comment.