From a5dc3634296c559a9b6c5c0e4b524dd02d328113 Mon Sep 17 00:00:00 2001 From: Florian Sellmayr Date: Sun, 7 Feb 2016 14:54:00 +0100 Subject: [PATCH] make step-id namespace public (#84) --- CHANGELOG.md | 4 ++- src/clj/lambdacd/internal/execution.clj | 2 +- src/clj/lambdacd/internal/step_id.clj | 33 ++++++----------- .../lambdacd/presentation/pipeline_state.clj | 2 +- src/clj/lambdacd/step_id.clj | 35 +++++++++++++++++++ src/clj/lambdacd/steps/control_flow.clj | 2 +- .../lambdacd/{internal => }/step_id_test.clj | 4 +-- 7 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 src/clj/lambdacd/step_id.clj rename test/clj/lambdacd/{internal => }/step_id_test.clj (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2683d718..e416a748 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/clj/lambdacd/internal/execution.clj b/src/clj/lambdacd/internal/execution.clj index f6d0cce6..7c4a53e2 100644 --- a/src/clj/lambdacd/internal/execution.clj +++ b/src/clj/lambdacd/internal/execution.clj @@ -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]) diff --git a/src/clj/lambdacd/internal/step_id.clj b/src/clj/lambdacd/internal/step_id.clj index 1755ca70..034b87a0 100644 --- a/src/clj/lambdacd/internal/step_id.clj +++ b/src/clj/lambdacd/internal/step_id.clj @@ -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)) \ No newline at end of file + (step-id/root-step-id-of step-id)) \ No newline at end of file diff --git a/src/clj/lambdacd/presentation/pipeline_state.clj b/src/clj/lambdacd/presentation/pipeline_state.clj index dfbee1e4..7d88a6cd 100644 --- a/src/clj/lambdacd/presentation/pipeline_state.clj +++ b/src/clj/lambdacd/presentation/pipeline_state.clj @@ -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)) diff --git a/src/clj/lambdacd/step_id.clj b/src/clj/lambdacd/step_id.clj new file mode 100644 index 00000000..70dd501f --- /dev/null +++ b/src/clj/lambdacd/step_id.clj @@ -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)) \ No newline at end of file diff --git a/src/clj/lambdacd/steps/control_flow.clj b/src/clj/lambdacd/steps/control_flow.clj index 78cde7f6..7b52c84e 100644 --- a/src/clj/lambdacd/steps/control_flow.clj +++ b/src/clj/lambdacd/steps/control_flow.clj @@ -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]) diff --git a/test/clj/lambdacd/internal/step_id_test.clj b/test/clj/lambdacd/step_id_test.clj similarity index 95% rename from test/clj/lambdacd/internal/step_id_test.clj rename to test/clj/lambdacd/step_id_test.clj index 0bc7a2b5..d9000ce6 100644 --- a/test/clj/lambdacd/internal/step_id_test.clj +++ b/test/clj/lambdacd/step_id_test.clj @@ -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]"