Skip to content

Commit

Permalink
Replaced cljx with cljc. cljs tests are passing but lein test runs no…
Browse files Browse the repository at this point in the history
… tests.
  • Loading branch information
bensu committed Jun 18, 2015
1 parent 5bd8c4f commit 1318cec
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 299 deletions.
37 changes: 7 additions & 30 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,24 @@
[org.clojure/clojurescript "0.0-3196"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]]
:plugins [[lein-cljsbuild "1.0.5"]
[com.keminglabs/cljx "0.6.0" :exclusions [org.clojure/clojure
com.cemerick/piggieback
net.cgrand/parsley]]
[com.cemerick/clojurescript.test "0.3.3"]]
:jar-exclusions [#"\.cljx"]
:aliases {"repl" ["with-profile" "repl" "repl"]
"clj-test" ["with-profile" "clj" "test"]
"cljs-test" ["do" "cljx" ["cljsbuild" "test"]]
"cljs-autotest" ["do" "cljx" ["cljsbuild" "auto" "test"]]
"all-tests" ["do" "clean" ["clj-test"] ["cljs-test"]]}
:aliases {"cljs-test" ["cljsbuild" "test"]
"cljs-autotest" ["cljsbuild" "auto" "test"]
"all-tests" ["do" "clean" ["test"] ["cljs-test"]]}
:profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.10"]
[org.clojure/tools.nrepl "0.2.10"]
[com.cemerick/piggieback "0.2.0"]
[net.cgrand/parsley "0.9.3" :exclusions [org.clojure/clojure]]]
:source-paths ["target/classes"]}
:repl [:dev {:source-paths ["repl" "target/classes" "target/generated/test/clj" "target/generated/test/cljs"]
:test-paths ["target/generated/test/clj" "target/generated/test/cljs"]}]
:clj [:dev {:source-paths ["target/classes"]
:test-paths ["target/generated/test/clj"]}]
:cljs [:dev]}
:prep-tasks [["cljx" "once"] "javac" "compile"]
:source-paths ["src"]}}
:prep-tasks ["javac" "compile"]
:cljsbuild {:test-commands {"phantom" ["phantomjs" :runner "target/testable.js"]
"node" ["node" :node-runner "target/testable.js"]}
:builds [{:id "test"
:source-paths ["target/classes" "target/generated/test/clj" "target/generated/test/cljs"]
:source-paths ["src" "test"]
:notify-command ["phantomjs" :cljs.test/runner "target/testable.js"]
:compiler {:output-to "target/testable.js"
:libs [""]
; node doesn't like source maps I guess?
;:source-map "target/testable.js.map"
:optimizations :simple
:pretty-print true}}]}
:cljx {:builds [{:source-paths ["src/cljx"]
:output-path "target/classes"
:rules :clj}
{:source-paths ["src/cljx"]
:output-path "target/classes"
:rules :cljs}
{:source-paths ["test/cljx"]
:output-path "target/generated/test/clj"
:rules :clj}
{:source-paths ["test/cljx"]
:output-path "target/generated/test/cljs"
:rules :cljs}]})
:pretty-print true}}]})
File renamed without changes.
57 changes: 0 additions & 57 deletions src/cljx/jamesmacaulay/zelkova/window.cljx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#+clj
(ns jamesmacaulay.async-tools.core
(:refer-clojure :exclude [concat])
(:require [clojure.core.async :as async :refer [go go-loop >! <! chan]]
[clojure.core.async.impl.protocols :as impl]
[clojure.core.async.impl.channels :as channels]))

#+cljs
(ns jamesmacaulay.async-tools.core
(:refer-clojure :exclude [concat])
(:require [cljs.core.async :as async :refer [>! <! chan]]
[cljs.core.async.impl.protocols :as impl]
[cljs.core.async.impl.channels :as channels])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
#?(:cljs (:require [cljs.core.async :as async :refer [>! <! chan]]
[cljs.core.async.impl.protocols :as impl]
[cljs.core.async.impl.channels :as channels])
:clj (:require [clojure.core.async :as async :refer [go go-loop >! <! chan]]
[clojure.core.async.impl.protocols :as impl]
[clojure.core.async.impl.channels :as channels]))
#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]])))

(defn concat
[& chs]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns jamesmacaulay.async-tools.test
(:require [jamesmacaulay.async-tools.core :as tools]
[cemerick.cljs.test]
#+clj [clojure.test]))
[clojure.test]))

#+clj
(defmacro deftest-async
[name & body]
(let [deftest-sym (if (:ns &env)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
(ns jamesmacaulay.zelkova.impl.signal
"Implementation details for `jamesmacaulay.zelkova.signal`."
#+clj
(:require [jamesmacaulay.async-tools.core :as tools]
[jamesmacaulay.zelkova.impl.time :as time]
[clojure.zip :as zip]
[clojure.set]
[alandipert.kahn :as kahn]
[clojure.core.async :as async :refer [go go-loop <! >!]]
[clojure.core.async.impl.protocols :as async-impl])
#+cljs
(:require [jamesmacaulay.async-tools.core :as tools]
[jamesmacaulay.zelkova.impl.time :as time]
[clojure.zip :as zip]
[clojure.set]
[alandipert.kahn :as kahn]
[cljs.core.async :as async :refer [<! >!]]
[cljs.core.async.impl.protocols :as async-impl])
#+cljs
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
#?(:cljs (:require [jamesmacaulay.async-tools.core :as tools]
[jamesmacaulay.zelkova.impl.time :as time]
[clojure.zip :as zip]
[clojure.set]
[alandipert.kahn :as kahn]
[cljs.core.async :as async :refer [<! >!]]
[cljs.core.async.impl.protocols :as async-impl])

:clj (:require [jamesmacaulay.async-tools.core :as tools]
[jamesmacaulay.zelkova.impl.time :as time]
[clojure.zip :as zip]
[clojure.set]
[alandipert.kahn :as kahn]
[clojure.core.async :as async :refer [go go-loop <! >!]]
[clojure.core.async.impl.protocols :as async-impl]))
#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]])))

(defprotocol BoxedValueProtocol
(value [boxed]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns jamesmacaulay.zelkova.impl.time
"Implementation details for `jamesmacaulay.zelkova.time`.")

#+clj
(defn now [] (System/currentTimeMillis))
#+cljs
(defn now [] (.valueOf (js/Date.)))
(defn now []
#?(:clj (System/currentTimeMillis)
:cljs (.valueOf (js/Date.))))
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
(ns jamesmacaulay.zelkova.keyboard
"This namespace provides keyboard-related signals."
(:refer-clojure :exclude [meta])
#+clj
(:require [jamesmacaulay.zelkova.signal :as z]
[clojure.core.async :as async])
#+cljs
(:require [jamesmacaulay.zelkova.signal :as z]
[goog.events :as events]
[cljs.core.async :as async :refer [>! <!]])
#+cljs
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))

#+cljs
(defn- listen
[el type & args]
(let [out (apply async/chan 1 args)]
(events/listen el type (fn [e] (async/put! out e)))
out))
#?(:clj (:require [jamesmacaulay.zelkova.signal :as z]
[clojure.core.async :as async])
:cljs (:require [jamesmacaulay.zelkova.signal :as z]
[goog.events :as events]
[cljs.core.async :as async :refer [>! <!]]))
#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]])))

#?(:cljs
(defn- listen
[el type & args]
(let [out (apply async/chan 1 args)]
(events/listen el type (fn [e] (async/put! out e)))
out)))

(defn- keydown-channel
[graph opts]
#+cljs
(listen js/document "keydown")
#+clj
(async/chan))
#?(:cljs (listen js/document "keydown")
:clj (async/chan)))

(defn- keyup-channel
[graph opts]
#+cljs
(listen js/document "keyup")
#+clj
(async/chan))
#?(:cljs (listen js/document "keyup")
:clj (async/chan)))

(defn- blur-channel
[graph opts]
#+cljs
(listen js/window "blur")
#+clj
(async/chan))
#?(:cljs (listen js/window "blur")
:clj (async/chan)))

(def ^:private down-events
(z/input 0 ::down-events keydown-channel))
Expand Down Expand Up @@ -141,7 +132,7 @@ depressed."}
enter
(down? 13))

#+cljs
(def ^{:doc "A signal of the code of the last pressed key."}
last-pressed
(z/map #(.-keyCode %) down-events))
#?(:cljs
(def ^{:doc "A signal of the code of the last pressed key."}
last-pressed
(z/map #(.-keyCode %) down-events)))
Original file line number Diff line number Diff line change
@@ -1,62 +1,51 @@
(ns jamesmacaulay.zelkova.mouse
"This namespace provides keyboard-related signals."
#+cljs
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [jamesmacaulay.zelkova.signal :as z]
[goog.events :as events]
[cljs.core.async :as async :refer [>! <!]])
#+cljs
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
[cljs.core.async :as async :refer [>! <!]]))

#+cljs
(defn- listen
[el type & args]
(let [out (apply async/chan 1 args)]
(events/listen el type (fn [e] (async/put! out e)))
out))

#+cljs
(defn- position-channel
[graph opts]
(listen js/document
"mousemove"
(map (fn [e] [(.-pageX (.-event_ e)) (.-pageY (.-event_ e))]))))

#+cljs
(def ^{:doc "A signal of mouse positions as `[x y]` vectors. Initial value is `[0 0]`."}
position
(z/input [0 0] ::position position-channel))

#+cljs
(def ^{:doc "A signal of mouse x-coordinates. Initial value is 0."}
x
(z/map first position))

#+cljs
(def ^{:doc "A signal of mouse y-coordinates. Initial value is 0."}
y
(z/map second position))

#+cljs
(defn- clicks-channel
[graph opts]
(listen js/document
"click"
(map (constantly :click))))

#+cljs
(def ^{:doc "A signal which is updated every time the mouse is clicked. The
value of the signal is always the keyword `:click`."}
clicks
(z/input :click ::clicks clicks-channel))

#+cljs
(defn- down?-channel
[graph opts]
(let [down-events (listen js/document "mousedown" (map (constantly true)))
up-events (listen js/document "mouseup" (map (constantly false)))]
(async/merge [down-events up-events])))

#+cljs
(def ^{:doc "A signal of boolean values, true when the primary mouse button is
depressed."}
down?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
(ns jamesmacaulay.zelkova.signal
"This is Zelkova's core namespace."
(:refer-clojure :exclude [map merge count reductions])
#+clj
(:require [clojure.core :as core]
[clojure.core.async :as async :refer [go go-loop <! >!]]
[clojure.core.async.impl.protocols :as async-impl]
[jamesmacaulay.zelkova.impl.signal :as impl])
#+cljs
(:require [cljs.core :as core]
[cljs.core.async :as async :refer [<! >!]]
[cljs.core.async.impl.protocols :as async-impl]
[jamesmacaulay.zelkova.impl.signal :as impl])
#+cljs
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
#?(:clj (:require [clojure.core :as core]
[clojure.core.async :as async :refer [go go-loop <! >!]]
[clojure.core.async.impl.protocols :as async-impl]
[jamesmacaulay.zelkova.impl.signal :as impl])
:cljs (:require [cljs.core :as core]
[cljs.core.async :as async :refer [<! >!]]
[cljs.core.async.impl.protocols :as async-impl]
[jamesmacaulay.zelkova.impl.signal :as impl]))
#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]])))

(defn input
"Returns an input signal with initial value `init`. The signal propagates values
Expand Down
Loading

0 comments on commit 1318cec

Please sign in to comment.