Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn file-extension [f] ("Dude the cow didn't implemented me yet"))
  2.  
  3. (defn pipe
  4.   ([node]
  5.    (let [flow (:flow node)]
  6.      (when (= flow "command")
  7.        ((println "pipel")
  8.         (:command node))
  9.        ((println "pipen " flow)
  10.         (pipe (:childs node)))))))
  11.  
  12. (defn pipel [f]
  13.   {:flow "command", :command f})
  14.  
  15. (defn pipen [flow pipes]
  16.   {:flow flow, :childs pipes})
  17.  
  18. (defn yml-check [file] ())
  19.  
  20. (defn yml-test [file] ())
  21.  
  22. (defn gerrit
  23.   "Transform gerrit stages into pipe tree"
  24.   [stages]
  25.   (pipen :par
  26.          (map
  27.           (fn [stage] (pipen :seq
  28.                             (map
  29.                              pipel
  30.                              (:commands stage))))
  31.           stages)))
  32.  
  33. (defn gerrit-stage [extension commands]
  34.   "Building stage object"
  35.   {:predicate (fn [f] (= (file-extension f) extension)),
  36.    :commands commands})
  37.  
  38. (defn -main
  39.   "I don't do a whole lot ... yet."
  40.   [& args]
  41.   (pipe
  42.    (pipen :par
  43.           [(gerrit [(gerrit-stage ".yml" [yml-check yml-test])
  44.                     (gerrit-stage ".py" [identity])])
  45.            (pipen :seq
  46.                   (pipen :par
  47.                          [(pipel (fn [] (println "Effectively parallel but sequenced with gerrit")))
  48.                           (pipel (fn [] (println "Effectively parallel but sequenced with gerrit")))]))])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement