aboutsummaryrefslogtreecommitdiff
path: root/challenge-146
diff options
context:
space:
mode:
authorTyler Wardhaugh <tyler.wardhaugh@gmail.com>2022-01-08 12:45:20 -0800
committerTyler Wardhaugh <tyler.wardhaugh@gmail.com>2022-01-08 16:00:46 -0800
commitfb0789c3ddec9b910e380206faf65c4510e2c39d (patch)
treefa854136ed66e4d5429c470b75c687bd09b08025 /challenge-146
parent14d1e11913396216dade604c1dee3945dd4eb4e8 (diff)
downloadperlweeklychallenge-club-fb0789c3ddec9b910e380206faf65c4510e2c39d.tar.gz
perlweeklychallenge-club-fb0789c3ddec9b910e380206faf65c4510e2c39d.tar.bz2
perlweeklychallenge-club-fb0789c3ddec9b910e380206faf65c4510e2c39d.zip
prep for challenge
New year, new template!
Diffstat (limited to 'challenge-146')
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/.gitignore22
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/LICENSE2
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/README.md39
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/bb.edn39
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/build.clj19
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/deps.edn21
-rw-r--r--challenge-146/tyler-wardhaugh/clojure/pom.xml44
7 files changed, 71 insertions, 115 deletions
diff --git a/challenge-146/tyler-wardhaugh/clojure/.gitignore b/challenge-146/tyler-wardhaugh/clojure/.gitignore
index 894239c8e8..ac8c2a1062 100644
--- a/challenge-146/tyler-wardhaugh/clojure/.gitignore
+++ b/challenge-146/tyler-wardhaugh/clojure/.gitignore
@@ -1,16 +1,28 @@
*.class
*.jar
+*.swp
+*~
.*_history
-.clj-kondo/
-.hg/
-.hgignore
-.lsp/
-.projections.json
+.sw*
+.vscode
+/.calva/output-window/
+/.classpath
+/.clj-kondo/
/.cpcache/
+/.eastwood/
+/.factorypath
+/.hg/
+/.hgignore
+/.java-version
/.lein-*
/.lsp/
/.nrepl-history
/.nrepl-port
+/.project
+/.projections.json
+/.rebel_readline_history
+/.settings
+/.socket-repl-port
/checkouts/
/classes/
/target/
diff --git a/challenge-146/tyler-wardhaugh/clojure/LICENSE b/challenge-146/tyler-wardhaugh/clojure/LICENSE
index 7689f30efd..d921d3dffe 100644
--- a/challenge-146/tyler-wardhaugh/clojure/LICENSE
+++ b/challenge-146/tyler-wardhaugh/clojure/LICENSE
@@ -126,7 +126,7 @@ a commercial product offering. The obligations in this section do not apply
to any claims or Losses relating to any actual or alleged intellectual
property infringement. In order to qualify, an Indemnified Contributor must:
a) promptly notify the Commercial Contributor in writing of such claim, and
-b) allow the Commercial Contributor tocontrol, and cooperate with the
+b) allow the Commercial Contributor to control, and cooperate with the
Commercial Contributor in, the defense and any related settlement
negotiations. The Indemnified Contributor may participate in any such claim
at its own expense.
diff --git a/challenge-146/tyler-wardhaugh/clojure/README.md b/challenge-146/tyler-wardhaugh/clojure/README.md
index 213f1884bc..4738867627 100644
--- a/challenge-146/tyler-wardhaugh/clojure/README.md
+++ b/challenge-146/tyler-wardhaugh/clojure/README.md
@@ -1,48 +1,35 @@
-# tw.weekly.c140
+# c146
-
-The Weekly Challenge - #140 - Tyler Wardhaugh
+The Weekly Challenge — #146 — Tyler Wardhaugh
## Usage
Clojure ([installation instructions](https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools)) required for `clojure` commands; Babashka ([installation instructions](https://github.com/babashka/babashka#quickstart)) required for the `bb` commands.
-Run the project directly (shows default output from both tasks):
+Run Task #1:
- $ clojure -M -m tw.weekly.c140.core
+ $ clojure -M:t1
# ... or ...
- $ bb run both
-
-Run the project's tests (which are samples from the task descriptions):
+ $ bb run task-1
- $ clojure -X:test
- # ... or ...
- $ bb run test
-
-Run Task #1 with input
+Run Task #2 with input:
- $ clojure -M -m tw.weekly.c140.t1 A B
+ $ clojure -M:t2 M
# ... or ...
- $ bb run task-1 A B
+ $ bb run task-2 M
-Run Task #2 with input:
+Run the project's tests (which are samples from the task descriptions):
- $ clojure -M -m tw.weekly.c140.t2 I J K
+ $ clojure -T:build test
# ... or ...
- $ bb run task-2 I J K
+ $ bb run test
View available tasks Babashka can run:
$ bb tasks
-## Project Template
-
-I used Sean Corfield's clj-new to generate the project template
-
-See [seancorfield/clj-new: Generate new projects based on clj, Boot, or Leiningen Templates!](https://github.com/seancorfield/clj-new) for more information.
-
## License
-Copyright © 2021 Tyler Wardhaugh
+Copyright © 2022 Tyler Wardhaugh
-Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
+Distributed under the Eclipse Public License version 1.0.
diff --git a/challenge-146/tyler-wardhaugh/clojure/bb.edn b/challenge-146/tyler-wardhaugh/clojure/bb.edn
index e053ec5de1..e21cd63a1e 100644
--- a/challenge-146/tyler-wardhaugh/clojure/bb.edn
+++ b/challenge-146/tyler-wardhaugh/clojure/bb.edn
@@ -16,15 +16,13 @@
(defn get-task-ns
[task]
- (let [glob-target (format "src/tw/weekly/*/%s.clj" (name task))
+ (let [glob-target (format "src/*/%s.clj" (name task))
file (->> glob-target (fs/glob ".") first)]
(-> file get-first-form second str)))
- (defn run-task
- ([task args] (run-task task args (get-task-ns task)))
- ([task args task-ns]
- (let [clj-options (format "-M -m %s " task-ns)]
- (apply clojure clj-options args))))
+ (defn run-task-clj
+ [task args]
+ (apply clojure (str "-M:" task) args))
(defn run-task-bb
([task args] (run-task-bb task args (get-task-ns task)))
@@ -43,11 +41,9 @@
(System/exit 1)))
clean {:doc "Clean out temporary files"
- :task (run! fs/delete-tree
- [".nrepl-port" ".cpcache" ".lsp" ".clj-kondo"])}
-
- generate-pom {:doc "Generate POM file"
- :task (clojure "-X:deps mvn-pom")}
+ :task (do (clojure "-T:build" "clean")
+ (run! fs/delete-tree
+ [".nrepl-port" ".cpcache" ".lsp" ".clj-kondo"]))}
generate-jar {:doc "Generate JAR file"
:depends [generate-pom]
@@ -68,35 +64,20 @@
p/check))}
test {:doc "Run tests"
- :task (clojure "-X:test")}
+ :task (clojure "-T:build test")}
c**** {:doc "CHALLENGE TASKS"}
task-1 {:doc "Run Task 1 (via clojure)"
- :task (run-task :t1 *command-line-args*)}
+ :task (run-task-clj :t1 *command-line-args*)}
task-1-bb {:doc "Run Task 1 (via Babashka)"
:task (run-task-bb :t1 *command-line-args*)}
task-2 {:doc "Run Task 2 (via clojure)"
- :task (run-task :t2 *command-line-args*)}
+ :task (run-task-clj :t2 *command-line-args*)}
task-2-bb {:doc "Run Task 2 (via Babashka)"
:task (run-task-bb :t2 *command-line-args*)}
-
- both {:doc "Run both tasks (via clojure)"
- :task (do
- (println "Task 1:")
- (run 'task-1)
- (println "\nTask 2:")
- (run 'task-2))}
-
- both-bb {:doc "Run both tasks (via Babashka)"
- :task (do
- (println "Task 1:")
- (run 'task-1-bb)
- (println "\nTask 2:")
- (run 'task-2-bb))}
-
}
}
diff --git a/challenge-146/tyler-wardhaugh/clojure/build.clj b/challenge-146/tyler-wardhaugh/clojure/build.clj
new file mode 100644
index 0000000000..8a78fbc09a
--- /dev/null
+++ b/challenge-146/tyler-wardhaugh/clojure/build.clj
@@ -0,0 +1,19 @@
+(ns build
+ (:refer-clojure :exclude [test])
+ (:require [org.corfield.build :as bb]))
+
+(def lib 'net.clojars.c146/c146)
+(def version "0.1.0-SNAPSHOT")
+(def main 'c146.c146)
+
+(defn test "Run the tests." [opts]
+ (bb/run-tests opts))
+
+(def clean bb/clean)
+
+(defn ci "Run the CI pipeline of tests (and build the uberjar)." [opts]
+ (-> opts
+ (assoc :lib lib :version version :main main)
+ (bb/run-tests)
+ (bb/clean)
+ (bb/uber)))
diff --git a/challenge-146/tyler-wardhaugh/clojure/deps.edn b/challenge-146/tyler-wardhaugh/clojure/deps.edn
index 5b1400b27e..16a95bc2f6 100644
--- a/challenge-146/tyler-wardhaugh/clojure/deps.edn
+++ b/challenge-146/tyler-wardhaugh/clojure/deps.edn
@@ -1,14 +1,15 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}}
:aliases
- {:test {:extra-paths ["test"]
- :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
+ {:t1 {:main-opts ["-m" "c146.t1"]}
+ :t2 {:main-opts ["-m" "c146.t2"]}
+ :build {:deps {io.github.seancorfield/build-clj
+ {:git/tag "v0.6.3" :git/sha "9b8e09b"
+ ;; since we're building an app uberjar, we do not
+ ;; need deps-deploy for clojars.org deployment:
+ :deps/root "slim"}}
+ :ns-default build}
+ :test {:extra-paths ["test"]
+ :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
io.github.cognitect-labs/test-runner
- {:git/url "https://github.com/cognitect-labs/test-runner"
- :sha "62ef1de18e076903374306060ac0e8a752e57c86"}}
- :exec-fn cognitect.test-runner.api/test}
- :jar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.278"}}
- :exec-fn hf.depstar/uberjar
- :exec-args {:aot true
- :jar "tw-weekly.jar"
- :sync-pom true}}}}
+ {:git/tag "v0.5.0" :git/sha "48c3c67"}}}}}
diff --git a/challenge-146/tyler-wardhaugh/clojure/pom.xml b/challenge-146/tyler-wardhaugh/clojure/pom.xml
deleted file mode 100644
index e51de32ab2..0000000000
--- a/challenge-146/tyler-wardhaugh/clojure/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>tw.weekly</groupId>
- <artifactId>tw.weekly.c140</artifactId>
- <version>0.1.0-SNAPSHOT</version>
- <name>tw.weekly.c140</name>
- <description>Challenge #140</description>
- <url>https://github.com/tw.weekly/tw.weekly.c140</url>
- <licenses>
- <license>
- <name>Eclipse Public License</name>
- <url>http://www.eclipse.org/legal/epl-v10.html</url>
- </license>
- </licenses>
- <developers>
- <developer>
- <name>Tyler Wardhaugh</name>
- </developer>
- </developers>
- <dependencies>
- <dependency>
- <groupId>org.clojure</groupId>
- <artifactId>clojure</artifactId>
- <version>1.10.3</version>
- </dependency>
- </dependencies>
- <build>
- <sourceDirectory>src</sourceDirectory>
- </build>
- <repositories>
- <repository>
- <id>clojars</id>
- <url>https://repo.clojars.org/</url>
- </repository>
- </repositories>
- <distributionManagement>
- <repository>
- <id>clojars</id>
- <name>Clojars repository</name>
- <url>https://clojars.org/repo</url>
- </repository>
- </distributionManagement>
-</project>