Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
make step-id namespace public (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
flosell committed Feb 7, 2016
1 parent 6aa436e commit a5dc363
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 29 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ The official release will have a defined and more stable API. If you are already
* `lambdacd.presentation.pipeline-state/overall-build-status`
* `lambdacd.presentation.pipeline-state/latest-most-recent-update`
* `lambdacd.presentation.pipeline-state/earliest-first-update`
* `lambdacd.presentation.pipeline-state/build-duration`
* `lambdacd.presentation.pipeline-state/build-duration`
* Renames namespace `lambdacd.internal.step-id` to `lambdacd.step-id` to officially make it public.
In case someone was using the internal namespace, it is still there but is considered DEPRECATED and will be removed in subsequent releases.
* UI: Link LambdaCD header to "/" to link back to overview in cases with multiple pipelines (#82)
* Bugs:
* `with-workspace` now creates temporary directories in the home-dir (#79)
Expand Down
2 changes: 1 addition & 1 deletion src/clj/lambdacd/internal/execution.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(:require [clojure.core.async :as async]
[lambdacd.internal.pipeline-state :as pipeline-state]
[clojure.tools.logging :as log]
[lambdacd.internal.step-id :as step-id]
[lambdacd.step-id :as step-id]
[lambdacd.steps.status :as status]
[clojure.repl :as repl]
[lambdacd.event-bus :as event-bus])
Expand Down
33 changes: 10 additions & 23 deletions src/clj/lambdacd/internal/step_id.clj
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
(ns lambdacd.internal.step-id
(:require [lambdacd.util :as util]))
(:require [lambdacd.util :as util]
[lambdacd.step-id :as step-id]))

; TODO: make this namespace public
; THIS NAMESPACE IS DEPRECATED and will be removed in subsequent releases.
; Use lambdacd.step-id instead.

(defn parent-of? [a b]
(let [cut-off-b (take-last (count a) b)]
(and
(not= a b)
(= a cut-off-b))))
(step-id/parent-of? a b))

(defn later-than? [a b]
(let [length (max (count a) (count b))
a-parents-first (reverse a)
b-parents-first (reverse b)
equal-length-a (util/fill a-parents-first length -1)
equal-length-b (util/fill b-parents-first length -1)
a-and-b (map vector equal-length-a equal-length-b)
first-not-equal (first (drop-while (fn [[x y]] (= x y)) a-and-b))
[x y] first-not-equal]
(if (nil? first-not-equal)
(> (count a) (count b))
(> x y))))
(step-id/later-than? a b))

(defn before? [a b]
(and
(not= a b)
(not (later-than? a b))))
(step-id/later-than? a b))

(defn child-id [parent-step-id child-number]
(cons child-number parent-step-id))
(step-id/child-id parent-step-id child-number))

(defn root-step-id? [step-id]
(= 1 (count step-id)))
(step-id/root-step-id? step-id))

(defn root-step-id-of [step-id]
(last step-id))
(step-id/root-step-id-of step-id))
2 changes: 1 addition & 1 deletion src/clj/lambdacd/presentation/pipeline_state.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[clj-time.core :as t]
[clojure.tools.logging :as log]
[clj-timeframes.core :as tf]
[lambdacd.internal.step-id :as step-id]))
[lambdacd.step-id :as step-id]))

(defn- desc [a b]
(compare b a))
Expand Down
35 changes: 35 additions & 0 deletions src/clj/lambdacd/step_id.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(ns lambdacd.step-id
(:require [lambdacd.util :as util]))

(defn parent-of? [a b]
(let [cut-off-b (take-last (count a) b)]
(and
(not= a b)
(= a cut-off-b))))

(defn later-than? [a b]
(let [length (max (count a) (count b))
a-parents-first (reverse a)
b-parents-first (reverse b)
equal-length-a (util/fill a-parents-first length -1)
equal-length-b (util/fill b-parents-first length -1)
a-and-b (map vector equal-length-a equal-length-b)
first-not-equal (first (drop-while (fn [[x y]] (= x y)) a-and-b))
[x y] first-not-equal]
(if (nil? first-not-equal)
(> (count a) (count b))
(> x y))))

(defn before? [a b]
(and
(not= a b)
(not (later-than? a b))))

(defn child-id [parent-step-id child-number]
(cons child-number parent-step-id))

(defn root-step-id? [step-id]
(= 1 (count step-id)))

(defn root-step-id-of [step-id]
(last step-id))
2 changes: 1 addition & 1 deletion src/clj/lambdacd/steps/control_flow.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(:require [lambdacd.core :as core]
[clojure.core.async :as async]
[lambdacd.steps.support :as support]
[lambdacd.internal.step-id :as step-id]
[lambdacd.step-id :as step-id]
[lambdacd.steps.status :as status]
[lambdacd.util :as utils])
(:refer-clojure :exclude [alias])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns lambdacd.internal.step-id-test
(ns lambdacd.step-id-test
(:use [lambdacd.testsupport.test-util])
(:require [clojure.test :refer :all]
[lambdacd.internal.step-id :refer :all]))
[lambdacd.step-id :refer :all]))

(deftest later-or-before-test
(testing "that [2] is after [1]"
Expand Down

0 comments on commit a5dc363

Please sign in to comment.