Permalink
Browse files

Improved the route macro and added both-e and better show output.

  • Loading branch information...
1 parent 16725bf commit 57ed83af9137ee4a84cf633dece587fe227d179c Darrick Wiebe committed Aug 26, 2012
Showing with 20 additions and 6 deletions.
  1. +6 −4 src/pacer.clj
  2. +14 −2 src/pacer/graph.clj
View
@@ -37,8 +37,10 @@
[route]
(:pipe (build-pipe route)))
-(defn route [& steps]
- (vec steps))
-
(defmacro route [& steps]
- (vec (map #(if (list? %) % (list %)) steps)))
+ (vec (map (fn [step]
+ `(let [step# ~step]
+ (if (map? step#)
+ step#
+ ~(list step))))
+ steps)))
View
@@ -3,6 +3,7 @@
(com.tinkerpop.blueprints.impls.tg TinkerGraph)
(com.tinkerpop.gremlin.pipes.transform InEdgesPipe OutEdgesPipe))
(:use [clojure.pprint :only [pprint]]
+ [clojure.string :only [join]]
pacer.step))
(defn tg []
@@ -24,6 +25,7 @@
:element (.addEdge @(:raw-graph graph) nil (:element from) (:element to) (str label))
})
+
(defn v []
{ :source-type :graph
:type :vertex
@@ -41,14 +43,24 @@
(defn out-e [& labels]
{ :source-type :vertex
:type :edge
- :name "OutE"
+ :name (str "OutE (" (join ", " labels) ")")
+ :labels labels
:pipe (fn pipe [in]
(OutEdgesPipe. (into-array String (map str labels)))) })
(defn in-e [& labels]
{ :source-type :vertex
:type :edge
- :name "InE"
+ :name (str "InE (" (join ", " labels) ")")
+ :labels labels
:pipe (fn pipe [in]
(InEdgesPipe. (into-array String (map str labels)))) })
+(defn both-e [& labels]
+ { :source-type :vertex
+ :type :edge
+ :name (str "BothE (" (join ", " labels) ")")
+ :labels labels
+ :pipe (fn pipe [in]
+ (BothEdgesPipe. (into-array String (map str labels)))) })
+

0 comments on commit 57ed83a

Please sign in to comment.