summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2021-07-06 09:54:46 -0400
committerKjetil Orbekk <kj@orbekk.com>2021-07-06 09:54:46 -0400
commit4226f9d0716dbe0274a76c46705c831da8a10d9a (patch)
tree069477575f6f49ec1d3fc8cfdf5cf995caf911a2
parent42e16dc95f05bc8da403ff7329bc815b4baf005b (diff)
example clojure project
-rw-r--r--clojure/.gitignore13
-rw-r--r--clojure/README.md44
-rw-r--r--clojure/doc/intro.md3
-rw-r--r--clojure/flake.lock26
-rw-r--r--clojure/flake.nix12
-rw-r--r--clojure/in-file.csv2
-rw-r--r--clojure/project.clj13
-rw-r--r--clojure/src/csvtool/core.clj21
-rw-r--r--clojure/test/csvtool/core_test.clj7
9 files changed, 141 insertions, 0 deletions
diff --git a/clojure/.gitignore b/clojure/.gitignore
new file mode 100644
index 0000000..d956ab0
--- /dev/null
+++ b/clojure/.gitignore
@@ -0,0 +1,13 @@
+/target
+/classes
+/checkouts
+profiles.clj
+pom.xml
+pom.xml.asc
+*.jar
+*.class
+/.lein-*
+/.nrepl-port
+/.prepl-port
+.hgignore
+.hg/
diff --git a/clojure/README.md b/clojure/README.md
new file mode 100644
index 0000000..54e5a4d
--- /dev/null
+++ b/clojure/README.md
@@ -0,0 +1,44 @@
+# csvtool
+
+FIXME: description
+
+## Installation
+
+Download from http://example.com/FIXME.
+
+## Usage
+
+FIXME: explanation
+
+ $ java -jar csvtool-0.1.0-standalone.jar [args]
+
+## Options
+
+FIXME: listing of options this app accepts.
+
+## Examples
+
+...
+
+### Bugs
+
+...
+
+### Any Other Sections
+### That You Think
+### Might be Useful
+
+## License
+
+Copyright © 2021 FIXME
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0.
+
+This Source Code may also be made available under the following Secondary
+Licenses when the conditions for such availability set forth in the Eclipse
+Public License, v. 2.0 are satisfied: GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or (at your
+option) any later version, with the GNU Classpath Exception which is available
+at https://www.gnu.org/software/classpath/license.html.
diff --git a/clojure/doc/intro.md b/clojure/doc/intro.md
new file mode 100644
index 0000000..13dcca3
--- /dev/null
+++ b/clojure/doc/intro.md
@@ -0,0 +1,3 @@
+# Introduction to csvtool
+
+TODO: write [great documentation](http://jacobian.org/writing/what-to-write/)
diff --git a/clojure/flake.lock b/clojure/flake.lock
new file mode 100644
index 0000000..c01dc11
--- /dev/null
+++ b/clojure/flake.lock
@@ -0,0 +1,26 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1625573330,
+ "narHash": "sha256-fPZ0QF5d4IJwWN5lxRbh6Q0pLAvRLSRhyn8SD414WlA=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "4116dd8256ac8a3c0f58fdebe01538e09e344aa6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/clojure/flake.nix b/clojure/flake.nix
new file mode 100644
index 0000000..b970fe0
--- /dev/null
+++ b/clojure/flake.nix
@@ -0,0 +1,12 @@
+{
+ description = "A very basic flake";
+ inputs = { nixpkgs.url = "github:nixos/nixpkgs"; };
+
+ outputs = { self, nixpkgs }:
+ let
+ system = "x86_64-linux";
+ pkgs = nixpkgs.legacyPackages.${system};
+ in {
+ devShell.${system} = pkgs.mkShell { buildInputs = [ pkgs.leiningen ]; };
+ };
+}
diff --git a/clojure/in-file.csv b/clojure/in-file.csv
new file mode 100644
index 0000000..7e2b25d
--- /dev/null
+++ b/clojure/in-file.csv
@@ -0,0 +1,2 @@
+test,hello,hello
+1,2,3
diff --git a/clojure/project.clj b/clojure/project.clj
new file mode 100644
index 0000000..6e26b8f
--- /dev/null
+++ b/clojure/project.clj
@@ -0,0 +1,13 @@
+(defproject csvtool "0.1.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :url "http://example.com/FIXME"
+ :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
+ :url "https://www.eclipse.org/legal/epl-2.0/"}
+ :dependencies [
+ [org.clojure/clojure "1.10.1"]
+ [org.clojure/data.csv "1.0.0"]
+ ]
+ :main ^:skip-aot csvtool.core
+ :target-path "target/%s"
+ :profiles {:uberjar {:aot :all
+ :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
diff --git a/clojure/src/csvtool/core.clj b/clojure/src/csvtool/core.clj
new file mode 100644
index 0000000..11e6bc7
--- /dev/null
+++ b/clojure/src/csvtool/core.clj
@@ -0,0 +1,21 @@
+(ns csvtool.core
+ (:gen-class))
+
+(require '[clojure.data.csv :as csv]
+ '[clojure.java.io :as io])
+
+(defn -main
+ "I don't do a whole lot ... yet."
+ [& args]
+ (println "Hello, World!"))
+
+(defn my-read []
+ (with-open [reader (io/reader "in-file.csv")]
+ (doall
+ (csv/read-csv reader))))
+
+(defn my-write []
+ (with-open [writer (io/writer "out-file.csv")]
+ (csv/write-csv writer
+ [["abc" "def"]
+ ["ghi" "jkl"]])))
diff --git a/clojure/test/csvtool/core_test.clj b/clojure/test/csvtool/core_test.clj
new file mode 100644
index 0000000..be5a441
--- /dev/null
+++ b/clojure/test/csvtool/core_test.clj
@@ -0,0 +1,7 @@
+(ns csvtool.core-test
+ (:require [clojure.test :refer :all]
+ [csvtool.core :refer :all]))
+
+(deftest a-test
+ (testing "FIXME, I fail."
+ (is (= 0 1))))