Permalink
Browse files

- amd support

- major clean up
- use global smoosh for build
- remove entire build directory
- add devDependencies
- rebuild and bump version to 0.0.3
  • Loading branch information...
ded committed Jan 13, 2012
1 parent c9e9562 commit d204af84ad9bfc798523594f05d72e174a1cc3c9
Showing with 725 additions and 534 deletions.
  1. +1 −1 Makefile
  2. +0 −99 Makefile.js
  3. +0 −1 build/UglifyJS
  4. +0 −1 build/gzip
  5. +0 −1 build/jshint
  6. +0 −1 build/json
  7. +0 −1 build/scriptjs
  8. +0 −1 build/sink
  9. +0 −199 dist/kizzy.js
  10. +0 −5 dist/kizzy.min.js
  11. +94 −91 kizzy.js
  12. +4 −3 kizzy.min.js
  13. +25 −22 make/build.js
  14. +14 −11 package.json
  15. +3 −2 src/header.js
  16. +91 −89 src/kizzy.js
  17. +487 −0 tests/json.js
  18. +6 −6 tests/test.html
View
@@ -1,2 +1,2 @@
boosh:
- node make/build.js
+ smoosh make make/build.js
View
@@ -1,99 +0,0 @@
-#!/usr/bin/env node
-/**
- * building $kizzy.js requires node
- * to install node try "port install node"
- * if that doesn't work. see the instructions
- * https://github.com/ry/node/wiki/Installation
- */
-var fs = require('fs'),
- uglifyJs = require('./build/UglifyJS'),
- jshint = require('./build/jshint/jshint').JSHINT,
- gzip = require('./build/gzip/lib/gzip'),
-
- BUILD_DIR = 'build',
- DIST_DIR = 'dist',
- SRC_DIR = 'src';
-
-console.log("Loading Kizzy source...");
-
-var $kizzy = fs.readFileSync(SRC_DIR + '/kizzy.js', 'UTF-8'),
- header = fs.readFileSync(SRC_DIR + '/header.js', 'UTF-8');
-
-console.log("Testing Kizzy against jshint...");
-
-jshint($kizzy, {
- boss: true,
- forin: true,
- browser: true
-});
-
-var errors = [];
-jshint.errors.forEach(function (err) {
- //ignore these errors until jshint resolves https://github.com/jshint/jshint/issues#issue/20
- if (err.reason != 'Expected an assignment or function call and instead saw an expression.') {
- errors.push(err);
- }
-});
-
-if (!errors.length) {
- console.log('Congratulations. No Errors. <3 JSHint.');
-} else {
- console.log(
- 'JSHint is NOT happy with '
- + errors.length
- + ' thing' + (errors.length > 1 ? 's' : '')
- + '!'
- );
- errors.forEach(function (err) {
- console.log(err.id + " line " + err.line + ": " + err.reason);
- });
- console.log('---------------------------------');
-}
-
-var $oldFile = fs.readFileSync(DIST_DIR + '/kizzy.min.js', 'UTF-8');
-var ast = uglifyJs.parser.parse($kizzy); // parse code and get the initial AST
-ast = uglifyJs.uglify.ast_mangle(ast); // get a new AST with mangled names
-ast = uglifyJs.uglify.ast_squeeze(ast); // get an AST with compression optimizations
-var $kizzyUgly = uglifyJs.uglify.gen_code(ast);
-
-console.log('Kizzy minified with UglifyJs');
-
-try {
- fs.statSync(DIST_DIR);
-} catch (e) {
- fs.mkdirSync(DIST_DIR, 0775);
-}
-
-var $uglyFile = [header, $kizzyUgly].join('');
-fs.writeFileSync(DIST_DIR + '/kizzy.js', [header, $kizzy].join('\n'));
-fs.writeFileSync(DIST_DIR + '/kizzy.min.js', $uglyFile);
-
-
-//gzip everything
-console.log('gzipping...');
-gzip($oldFile, function(err, data){
- var oldLen = $oldFile.length,
- oldGzipLen = data.length;
- gzip($uglyFile, function(err, data){
- var newLen = $uglyFile.length,
- newGzipLen = data.length;
- messageLength(oldLen, oldGzipLen, newLen, newGzipLen);
- });
-});
-
-function messageLength(oldLen, oldGzipLen, newLen, newGzipLen){
- var fileDiff = Math.abs(oldLen - newLen),
- gzipDiff = oldGzipLen - newGzipLen,
- gzipMsg = '(' + Math.abs(gzipDiff) + ' ' + (gzipDiff < 0 ? 'more' : 'less') + ' gzipped.)';
-
- console.log("Done! kizzy.js is now " + newLen + ' bytes. (Only ' + newGzipLen + ' gzipped.)');
- if (newLen < oldLen) {
- console.log('You are a very special, handsome person. Now go do a shot of whiskey');
- console.log('That\'s ' + fileDiff + ' bytes less! ' + gzipMsg);
- } else if (newLen > oldLen) {
- console.log('Dude! You made it worse!');
- console.log('That\'s ' + fileDiff + ' bytes more! ' + gzipMsg);
- } else {
- console.log('Not bad. But how does it feel to do all that work and make no difference');
- }
-};
Submodule UglifyJS deleted from cc9e94
Submodule gzip deleted from a6bfe3
Submodule jshint deleted from 3b018b
Submodule json deleted from ad6079
Submodule scriptjs deleted from dccd4c
Submodule sink deleted from 035b52
View
@@ -1,199 +0,0 @@
-/*! Kizzy v1.0
- * https://github.com/polvero/kizzy
- * Copyright: @ded Dustin Diaz 2011
- * License: CC Attribution: http://creativecommons.org/licenses/by/3.0/
- */
-!function(win, doc, localStorage, store) {
-
- var hasLocalStorage,
- html5 = 0,
- writeThrough = function() {
- return 1;
- }
- try {
- // HTML5 local storage
- hasLocalStorage = !!localStorage || !!globalStorage;
- localStorage = localStorage || globalStorage[store];
- html5 = 1;
- } catch (ex1) {
- html5 = 0;
- // IE local storage
- try {
- // this try / if is required. trust me
- if (doc.documentElement.addBehavior) {
- html5 = 0;
- hasLocalStorage = 1;
- var dataStore = doc.documentElement;
- dataStore.addBehavior('#default#userData');
- dataStore.load(store);
- var xmlDoc = dataStore.xmlDocument;
- var xmlDocEl = xmlDoc.documentElement;
- }
- } catch (ex2) {
- hasLocalStorage = false;
- }
- }
-
- function noop () {
-
- }
-
- function time () {
- return +new Date();
- }
-
- function checkExpiry(inst, k) {
- if (inst._[k] && inst._[k].e && inst._[k].e < time()) {
- inst.remove(k);
- }
- }
-
- function isNumber(n) {
- return typeof n === 'number' && isFinite(n);
- }
-
- function html5getLocalStorage(k) {
- return localStorage[k];
- }
-
- function html5setLocalStorage(k, v) {
- localStorage[k] = v;
- return v;
- }
-
- function html5removeLocalStorage(k) {
- delete localStorage[k];
- }
-
- function html5clearLocalStorage() {
- localStorage.clear();
- }
-
- function getNodeByName(name) {
- var childNodes = xmlDocEl.childNodes,
- node,
- returnVal = null;
-
- for (var i = 0, len = childNodes.length; i < len; i++) {
- node = childNodes.item(i);
- if (node.getAttribute("key") == name) {
- returnVal = node;
- break;
- }
- }
- return returnVal;
- }
-
- function getUserData(name) {
- var node = getNodeByName(name);
- var returnVal = null;
- if (node) {
- returnVal = node.getAttribute("value");
- }
- return returnVal;
- }
-
- function setUserData(name, value) {
- var node = getNodeByName(name);
- if (!node) {
- node = xmlDoc.createNode(1, "item", "");
- node.setAttribute("key", name);
- node.setAttribute("value", value);
- xmlDocEl.appendChild(node);
- }
- else {
- node.setAttribute("value", value);
- }
- dataStore.save(store);
- return value;
- }
-
- function removeUserData(name) {
- getNodeByName(name) && xmlDocEl.removeChild(node);
- dataStore.save(store);
- }
-
- function clearUserData() {
- while (xmlDocEl.firstChild) {
- xmlDocEl.removeChild(xmlDocEl.firstChild);
- }
- dataStore.save(store);
- }
-
- function _Kizzy() {
- this._ = {};
- }
-
- _Kizzy.prototype = {
-
- set: function(k, v, optTtl) {
- this._[k] = {
- value: v,
- e: isNumber(optTtl) ? time() + optTtl : 0
- };
- writeThrough(this) || this.remove(k);
- return v;
- },
-
- get: function(k) {
- checkExpiry(this, k);
- return this._[k] ? this._[k].value : undefined;
- },
-
- remove: function(k) {
- delete this._[k];
- writeThrough(this);
- },
-
- clear: function() {
- this._ = {};
- writeThrough(this);
- }
- };
-
- function Kizzy(ns) {
- this.ns = ns;
- this._ = JSON.parse(getLocalStorage(ns) || '{}');
- }
-
- Kizzy.prototype = _Kizzy.prototype;
-
- win.Kizzy = function(ns) {
- return new Kizzy(ns);
- };
-
- win.Kizzy.remove = function(ns) {
- removeLocalStorage(ns);
- };
-
- win.Kizzy.clear = function() {
- clearLocalStorage();
- };
-
- if (hasLocalStorage) {
- var setLocalStorage = html5 ? html5setLocalStorage : setUserData,
- getLocalStorage = html5 ? html5getLocalStorage : getUserData,
- removeLocalStorage = html5 ? html5removeLocalStorage : removeUserData,
- clearLocalStorage = html5 ? html5clearLocalStorage : clearUserData;
-
- writeThrough = function(inst) {
- try {
- setLocalStorage(inst.ns, JSON.stringify(inst._));
- return 1;
- } catch (x) {
- return 0;
- }
- };
- } else {
- var setLocalStorage = noop,
- getLocalStorage = noop,
- removeLocalStorage = function(ns) {
-
- },
- clearLocalStorage = function() {
-
- };
-
- }
-
-}(window, document, localStorage, document.domain);
View

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

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

0 comments on commit d204af8

Please sign in to comment.