From 2792a09ded4eed856ec2f4b2f78d44003e6f4dad Mon Sep 17 00:00:00 2001 From: Roman Gonzalez Date: Fri, 30 Nov 2012 22:45:44 +0000 Subject: [PATCH 01/14] Upgrading to Clojure v1.4.0 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index e86be63..b2c4c87 100644 --- a/project.clj +++ b/project.clj @@ -1,6 +1,6 @@ (defproject clout "1.1.0" :description "A HTTP route matching library" :url "http://github.com/weavejester/clout" - :dependencies [[org.clojure/clojure "1.2.1"]] + :dependencies [[org.clojure/clojure "1.4.0"]] :profiles {:dev {:dependencies [[ring-mock "0.1.1"]]}}) From a174a0bffaf43bbee726531ab3911dedd46009d9 Mon Sep 17 00:00:00 2001 From: Roman Gonzalez Date: Mon, 3 Dec 2012 19:49:40 +0000 Subject: [PATCH 02/14] First half-way clout translation to cljs --- buster.js | 13 + dalap_rules.clj | 7 + project.clj | 40 +- resources/js/clout_browser_test.js | 14503 +++++++++++++++++++++++++++ resources/js/clout_dev.js | 14285 ++++++++++++++++++++++++++ resources/js/clout_node_test.js | 14503 +++++++++++++++++++++++++++ src/{ => clj}/clout/core.clj | 47 +- src/cljs/clout/core.cljs | 21 + test/clj/clout/test/core.clj | 134 + test/cljs/clout/test/core.cljs | 22 + test/clout/test/core.clj | 105 - 11 files changed, 43569 insertions(+), 111 deletions(-) create mode 100644 buster.js create mode 100644 dalap_rules.clj create mode 100644 resources/js/clout_browser_test.js create mode 100644 resources/js/clout_dev.js create mode 100644 resources/js/clout_node_test.js rename src/{ => clj}/clout/core.clj (72%) create mode 100644 src/cljs/clout/core.cljs create mode 100644 test/clj/clout/test/core.clj create mode 100644 test/cljs/clout/test/core.cljs delete mode 100644 test/clout/test/core.clj diff --git a/buster.js b/buster.js new file mode 100644 index 0000000..b13012c --- /dev/null +++ b/buster.js @@ -0,0 +1,13 @@ +var config = exports; + +config['Browser Tests'] = { + environment: 'browser', + sources: [], + tests: ["resources/js/clout_browser_test.js"] +}; + + config['Server Tests'] = { + environment: 'node', + sources: [], + tests: ["resources/js/clout_node_test.js"] + }; diff --git a/dalap_rules.clj b/dalap_rules.clj new file mode 100644 index 0000000..0681bea --- /dev/null +++ b/dalap_rules.clj @@ -0,0 +1,7 @@ +{ + ["src/clj/clout/core.clj" "src/cljs/clout/core.cljs"] + [] + + ["test/clj/clout/test/core.clj" "test/cljs/clout/test/core.cljs"] + [] +} \ No newline at end of file diff --git a/project.clj b/project.clj index b2c4c87..59af18f 100644 --- a/project.clj +++ b/project.clj @@ -1,6 +1,42 @@ (defproject clout "1.1.0" :description "A HTTP route matching library" :url "http://github.com/weavejester/clout" - :dependencies [[org.clojure/clojure "1.4.0"]] + :dependencies [[org.clojure/clojure "1.4.0"] + [buster-cljs "0.1.0-SNAPSHOT"]] + :plugins [[lein-cljsbuild "0.2.9"] + [lein-dalap "0.1.0-SNAPSHOT"]] + :hooks [leiningen.dalap] :profiles - {:dev {:dependencies [[ring-mock "0.1.1"]]}}) + {:dev {:dependencies [[org.clojure/tools.namespace "0.2.1"] + [ring-mock "0.1.1"]]}} + + :source-paths ["src/clj"] + :test-paths ["test/clj"] + + :cljsbuild + {:builds + [{:id "dev" + :source-path "src/cljs" + :compiler + {:optimizations :simple + :pretty-print true + :output-to "resources/js/clout_dev.js"}} + ;; + {:id "browser-test" + :source-path "test/cljs" + :compiler + {:optimizations :simple + :pretty-print true + :externs ["externs/buster.js"] + :libraries ["resources/js/clout_dev.js"] + :output-to "resources/js/clout_browser_test.js"}} + ;; + {:id "node-test" + :source-path "test/cljs" + :compiler + {:optimizations :simple + :pretty-print true + :target :node + :externs ["externs/buster.js"] + :libraries ["resources/js/clout_dev.js"] + :output-to "resources/js/clout_node_test.js"}}]}) diff --git a/resources/js/clout_browser_test.js b/resources/js/clout_browser_test.js new file mode 100644 index 0000000..f2a1e82 --- /dev/null +++ b/resources/js/clout_browser_test.js @@ -0,0 +1,14503 @@ +var COMPILED = !0, goog = goog || {}; +goog.global = this; +goog.DEBUG = !0; +goog.LOCALE = "en"; +goog.provide = function(a) { + if(!COMPILED) { + if(goog.isProvided_(a)) { + throw Error('Namespace "' + a + '" already declared.'); + } + delete goog.implicitNamespaces_[a]; + for(var b = a;(b = b.substring(0, b.lastIndexOf("."))) && !goog.getObjectByName(b);) { + goog.implicitNamespaces_[b] = !0 + } + } + goog.exportPath_(a) +}; +goog.setTestOnly = function(a) { + if(COMPILED && !goog.DEBUG) { + throw a = a || "", Error("Importing test-only code into non-debug environment" + a ? ": " + a : "."); + } +}; +COMPILED || (goog.isProvided_ = function(a) { + return!goog.implicitNamespaces_[a] && !!goog.getObjectByName(a) +}, goog.implicitNamespaces_ = {}); +goog.exportPath_ = function(a, b, c) { + a = a.split("."); + c = c || goog.global; + !(a[0] in c) && c.execScript && c.execScript("var " + a[0]); + for(var d;a.length && (d = a.shift());) { + !a.length && goog.isDef(b) ? c[d] = b : c = c[d] ? c[d] : c[d] = {} + } +}; +goog.getObjectByName = function(a, b) { + for(var c = a.split("."), d = b || goog.global, e;e = c.shift();) { + if(goog.isDefAndNotNull(d[e])) { + d = d[e] + }else { + return null + } + } + return d +}; +goog.globalize = function(a, b) { + var c = b || goog.global, d; + for(d in a) { + c[d] = a[d] + } +}; +goog.addDependency = function(a, b, c) { + if(!COMPILED) { + for(var d, a = a.replace(/\\/g, "/"), e = goog.dependencies_, f = 0;d = b[f];f++) { + e.nameToPath[d] = a; + a in e.pathToNames || (e.pathToNames[a] = {}); + e.pathToNames[a][d] = true + } + for(d = 0;b = c[d];d++) { + a in e.requires || (e.requires[a] = {}); + e.requires[a][b] = true + } + } +}; +goog.ENABLE_DEBUG_LOADER = !0; +goog.require = function(a) { + if(!COMPILED && !goog.isProvided_(a)) { + if(goog.ENABLE_DEBUG_LOADER) { + var b = goog.getPathFromDeps_(a); + if(b) { + goog.included_[b] = true; + goog.writeScripts_(); + return + } + } + a = "goog.require could not find: " + a; + goog.global.console && goog.global.console.error(a); + throw Error(a); + } +}; +goog.basePath = ""; +goog.nullFunction = function() { +}; +goog.identityFunction = function(a) { + return a +}; +goog.abstractMethod = function() { + throw Error("unimplemented abstract method"); +}; +goog.addSingletonGetter = function(a) { + a.getInstance = function() { + return a.instance_ || (a.instance_ = new a) + } +}; +!COMPILED && goog.ENABLE_DEBUG_LOADER && (goog.included_ = {}, goog.dependencies_ = {pathToNames:{}, nameToPath:{}, requires:{}, visited:{}, written:{}}, goog.inHtmlDocument_ = function() { + var a = goog.global.document; + return typeof a != "undefined" && "write" in a +}, goog.findBasePath_ = function() { + if(goog.global.CLOSURE_BASE_PATH) { + goog.basePath = goog.global.CLOSURE_BASE_PATH + }else { + if(goog.inHtmlDocument_()) { + for(var a = goog.global.document.getElementsByTagName("script"), b = a.length - 1;b >= 0;--b) { + var c = a[b].src, d = c.lastIndexOf("?"), d = d == -1 ? c.length : d; + if(c.substr(d - 7, 7) == "base.js") { + goog.basePath = c.substr(0, d - 7); + break + } + } + } + } +}, goog.importScript_ = function(a) { + var b = goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_; + !goog.dependencies_.written[a] && b(a) && (goog.dependencies_.written[a] = true) +}, goog.writeScriptTag_ = function(a) { + if(goog.inHtmlDocument_()) { + goog.global.document.write('