├── tests.edn ├── .dir-locals.el ├── .gitignore ├── .github └── workflows │ └── build.yml ├── deps.edn ├── README.md ├── Makefile ├── test └── rusty │ └── yard_test.cljc └── src └── rusty └── yard.cljc /tests.edn: -------------------------------------------------------------------------------- 1 | #kaocha/v1 2 | {:tests [{:id :clj 3 | :type :kaocha.type/clojure.test} 4 | {:id :cljs 5 | :type :kaocha.type/cljs}]} 6 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((clojure-mode . ((cider-clojure-cli-aliases . ":test")))) 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .cpcache 3 | .nrepl-port 4 | **/.clj-kondo/.cache 5 | **/.lsp 6 | **/.DS_Store 7 | .cljs_node_repl 8 | node_modules 9 | out 10 | package-lock.json 11 | package.json 12 | yarn.lock -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [push] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: checkout 9 | uses: actions/checkout@v3 10 | - name: prepare java 11 | uses: actions/setup-java@v3 12 | with: 13 | java-version: '11' 14 | distribution: 'zulu' 15 | architecture: 'x64' 16 | - name: install clojure 17 | uses: DelaGuardo/setup-clojure@10.0 18 | with: 19 | cli: 1.11.1.1347 20 | - name: clj tests 21 | run: make test 22 | -------------------------------------------------------------------------------- /deps.edn: -------------------------------------------------------------------------------- 1 | {:deps 2 | {org.clojure/clojure {:mvn/version "1.11.1"}} 3 | :paths ["src"] 4 | 5 | :aliases 6 | {:test 7 | {:extra-deps {lambdaisland/kaocha {:mvn/version "1.85.1342"} 8 | com.lambdaisland/kaocha-cljs {:mvn/version "1.4.130"}} 9 | :extra-paths ["test"] 10 | :exec-fn kaocha.runner/exec-fn} 11 | 12 | :outdated 13 | {:deps {com.github.liquidz/antq {:mvn/version "RELEASE"} 14 | org.slf4j/slf4j-simple {:mvn/version "2.0.7"}} 15 | :main-opts ["-m" "antq.core"]} 16 | 17 | :cljfmt 18 | {:deps {dev.weavejester/cljfmt {:mvn/version "0.11.2"}} 19 | :ns-default cljfmt.tool} 20 | 21 | :check 22 | {:extra-deps {org.spootnik/deps-check {:mvn/version "0.5.2"}} 23 | :ns-default spootnik.deps-check} 24 | 25 | :quickdoc 26 | {:deps {org.babashka/cli {:mvn/version "0.7.52"} 27 | io.github.borkdude/quickdoc 28 | {:deps/root "jvm" 29 | :git/sha "e4f08eb5b1882cf0bffcbb7370699c0a63c9fd72"}} 30 | :exec-args {:github/repo "https://github.com/pyr/rusty-yard" 31 | :git/branch "main"} 32 | :main-opts ["-m" "babashka.cli.exec" "quickdoc.api" "quickdoc"]}}} 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rusty yard: when you feel uninspired 2 | ==================================== 3 | 4 | Somewhat randomly generates names that you can remember easily. 5 | 6 | ## Usage 7 | 8 | ### `codename` 9 | ``` clojure 10 | 11 | (codename 12 | & 13 | {:keys [corpus suffixes separator join?], 14 | :or {corpus default-corpus, suffixes default-suffixes, separator default-separator, join? true}}) 15 | ``` 16 | 17 | Generate a name composed of two or three parts. This can be used 18 | to generate release names for the uninspired. The 0-arity uses an 19 | internal corpus and a space as separator for the elements. The 20 | following arguments can be provided as keyword arguments or using 21 | a map as the first argument: 22 | 23 | - `corpus`: The list of names. Either one or two elements from this 24 | corpus will be picked for every generated name. Prefer 25 | adjectives or qualifying words here. 26 | - `suffixes`: A list of suffixes, a single one picked for every generated 27 | name. Prefer nouns here. 28 | - `separator`: A string to use to join elements together, defaults to a 29 | space. 30 | - `join?`: Whether to join using the separator, defaults to true. 31 | Otherwise yields a vector. 32 | 33 | 34 |

Source

35 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: * 2 | .DEFAULT_GOAL:=help 3 | 4 | # Internal 5 | CLJ=clojure -J-Dclojure.main.report=stderr 6 | CLEANFILES=target .cpcache node_modules package.json out yarn.lock 7 | SOURCE_PATHS='["src"]' 8 | RM=rm -f 9 | 10 | ##@ Testing 11 | 12 | test: ## Runs Clojure unit tests (lein test) 13 | $(CLJ) -M:test -m kaocha.runner clj 14 | 15 | test-cljs: ## Runs Clojurescript unit tests 16 | [ -d node_modules ] || npm instal ws 17 | $(CLJ) -M:test -m kaocha.runner cljs 18 | 19 | test-all: ## Runs both test suites 20 | $(CLJ) -M:test -m kaocha.runner 21 | 22 | repl: ## Launch test repl (lein repl) 23 | $(CLJ) -A:test 24 | 25 | ##@ Dependencies 26 | 27 | deps: ## Show deps tree (lein deps :tree) 28 | $(CLJ) -Stree 29 | 30 | check: ## Compile all namespaces to check for issues (lein compile :all) 31 | $(CLJ) -X:check check :paths $(SOURCE_PATHS) 32 | 33 | setup: ## Ensure everything is working 34 | @$(CLJ) -M:test -e '(println "everything is ready")' 35 | 36 | 37 | ##@ Misc. 38 | 39 | lint: ## runs linting on all modules (clj-kondo) 40 | clj-kondo --lint src test 41 | 42 | format: ## Format according to linter rules (lein cljfmt check) 43 | $(CLJ) -T:cljfmt check :paths $(SOURCE_PATHS) 44 | 45 | format-fix: ## Fix formatting errors found (lein cljfmt fix) 46 | $(CLJ) -T:cljfmt fix :paths $(SOURCE_PATHS) 47 | 48 | outdated: ## run antq (aka 'ancient') task on all modules (lein ancient) 49 | $(CLJ) -M:test:outdated 50 | 51 | doc: ## generate documentation from code 52 | $(CLJ) -M:quickdoc 53 | 54 | clean: ## Clean module target dirs (lein clean) 55 | $(RM) -r $(CLEANFILES) 56 | 57 | ##@ Helpers 58 | 59 | help: ## Display this help 60 | @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) 61 | -------------------------------------------------------------------------------- /test/rusty/yard_test.cljc: -------------------------------------------------------------------------------- 1 | (ns rusty.yard-test 2 | (:require [clojure.test :refer [deftest testing is]] 3 | [rusty.yard :refer [codename]])) 4 | 5 | (def fake-corpus 6 | [:red :rusty :yard]) 7 | 8 | (def fake-suffixes 9 | [:balloon :animal]) 10 | 11 | (def possibilities 12 | #{ ;; Triple variant 13 | [:red :rusty :balloon] 14 | [:red :rusty :animal] 15 | [:red :yard :balloon] 16 | [:red :yard :animal] 17 | [:rusty :red :balloon] 18 | [:rusty :red :animal] 19 | [:rusty :yard :balloon] 20 | [:rusty :yard :animal] 21 | [:yard :red :balloon] 22 | [:yard :red :animal] 23 | [:yard :rusty :balloon] 24 | [:yard :rusty :animal] 25 | [:red :red :balloon] 26 | [:red :red :animal] 27 | [:rusty :rusty :balloon] 28 | [:rusty :rusty :animal] 29 | [:yard :yard :balloon] 30 | [:yard :yard :animal] 31 | 32 | ;; Suffix first variant 33 | [:balloon :red] 34 | [:balloon :rusty] 35 | [:balloon :yard] 36 | [:animal :red] 37 | [:animal :rusty] 38 | [:animal :yard] 39 | ;; Suffix last variant 40 | [:red :balloon] 41 | [:red :animal] 42 | [:rusty :balloon] 43 | [:rusty :animal] 44 | [:yard :balloon] 45 | [:yard :animal]}) 46 | 47 | (deftest basic-behavior 48 | (testing "Returns a string by default" 49 | (is (string? (codename))) 50 | (is (string? (codename :separator "-"))) 51 | (is (string? (codename {:separator "-"})))) 52 | 53 | (testing "Returns a vector when instructed to" 54 | (is (vector? (codename :join? false))) 55 | (is (vector? (codename {:join? false}))) 56 | ;; join? takes precedence over separator 57 | (is (vector? (codename :join? false :separator "-"))) 58 | (is (vector? (codename {:join? false :separator "-"})))) 59 | 60 | (testing "Generation can be determined" 61 | (is (every? #(contains? possibilities %) 62 | (take 100 63 | (repeatedly #(codename {:join? false 64 | :corpus fake-corpus 65 | :suffixes fake-suffixes}))))))) 66 | -------------------------------------------------------------------------------- /src/rusty/yard.cljc: -------------------------------------------------------------------------------- 1 | (ns rusty.yard 2 | "A codename generator, see `codename`" 3 | (:require [clojure.string :as str])) 4 | 5 | (def ^:private ^:no-doc colors 6 | "A few color for the triple part version of generated names" 7 | ["white","black","yellow","red","blue","brown","green", 8 | "purple","orange","silver","scarlet","rainbow","indigo", 9 | "ivory","navy","olive","teal","pink","magenta","maroon", 10 | "sienna","gold","golden"]) 11 | 12 | (def ^:private ^:no-doc adjectives 13 | "Adjectives make most of the corpus" 14 | ["abandoned","aberrant","accidentally","aggressive","aimless", 15 | "alien","angry","appropriate","barbaric","beacon","big","bitter", 16 | "bleeding","brave","brutal","cheerful","dancing","dangerous", 17 | "dead","deserted","digital","dirty","disappointed","discarded", 18 | "dreaded","eastern","eastern","elastic","empty","endless", 19 | "essential","eternal","everyday","fierce","flaming","flying", 20 | "forgotten","forsaken","freaky","frozen","full","furious","ghastly", 21 | "global","gloomy","grim","gruesome","gutsy","helpless","hidden", 22 | "hideous","homeless","hungry","insane","intense","intensive", 23 | "itchy","liquid","lone","lost","meaningful","modern", 24 | "monday's","morbid","moving","needless","nervous","new","next", 25 | "ninth","nocturnal","northernmost","official","old","permanent", 26 | "persistent","pointless","pure","quality","random","rare","raw", 27 | "reborn","remote","restless","rich","risky","rocky","rough", 28 | "running","rusty","sad","saturday's","screaming","serious", 29 | "severe","silly","skilled","sleepy","sliding","small","solid", 30 | "steamy", "stony","stormy","straw","strawberry","streaming", 31 | "strong","subtle", 32 | "supersonic","surreal","tainted","temporary","third","tidy", 33 | "timely", 34 | "unique","vital","western","wild","wooden","worthy","bitter", 35 | "boiling", 36 | "brave","cloudy","cold","confidential","dreadful","dusty","eager", 37 | "early","grotesque ","harsh","heavy","hollow","hot","husky","icy", 38 | "late","lonesome","long","lucky","massive","maximum","minimum", 39 | "mysterious","outstanding","rapid","rebel","scattered","shiny", 40 | "solid","square","steady","steep","sticky","stormy","strong", 41 | "sunday's","swift","tasty"]) 42 | 43 | (def ^:private ^:no-doc default-suffixes 44 | "By default suffixes are nouns" 45 | ["alarm","albatross","anaconda","antique","artificial","autopsy", 46 | "autumn","avenue","backpack","balcony","barbershop","boomerang", 47 | "bulldozer","butter","canal","cloud","clown","coffin","comic", 48 | "compass","cosmic","crayon","creek","crossbow","dagger","dinosaur", 49 | "dog","donut","door","doorstop","electrical","electron","eyelid", 50 | "firecracker","fish","flag","flannel","flea","frostbite","gravel", 51 | "haystack","helium","kangaroo","lantern","leather","limousine", 52 | "lobster","locomotive","logbook","longitude","metaphor", 53 | "microphone", 54 | "monkey","moose","morning","mountain","mustard","neutron", 55 | "nitrogen", 56 | "notorious","obscure","ostrich","oyster","parachute","peasant", 57 | "pineapple","plastic","postal","pottery","proton","puppet", 58 | "railroad", 59 | "rhinestone","roadrunner","rubber","scarecrow","scoreboard", 60 | "scorpion", 61 | "shower","skunk","sound","street","subdivision","summer","sunshine", 62 | "tea","temple","test","tire","tombstone","toothbrush","torpedo", 63 | "toupee", 64 | "trendy","trombone","tuba","tuna","tungsten","vegetable","venom", 65 | "vulture","waffle","warehouse","waterbird","weather","weeknight", 66 | "windshield","winter","wrench","xylophone","alpha","arm","beam", 67 | "beta", 68 | "bird","breeze","burst","cat","cobra","crystal","drill","eagle", 69 | "emerald","epsilon","finger","fist","foot","fox","galaxy","gamma", 70 | "hammer","heart","hook","hurricane","iron","jazz","jupiter","knife", 71 | "lama","laser","lion","mars","mercury","moon","moose","neptune", 72 | "omega","panther","planet","pluto","plutonium","poseidon","python", 73 | "ray","sapphire","scissors","screwdriver","serpent","sledgehammer", 74 | "smoke","snake","space","spider","star","steel","storm","sun", 75 | "swallow", 76 | "tiger","uranium","venus","viper","wrench","yard","zeus"]) 77 | 78 | (def ^:private ^:no-doc default-corpus 79 | "The default corpus has both colors and adjectives" 80 | (vec (concat colors adjectives))) 81 | 82 | (def ^:private ^:no-doc default-separator 83 | "The default separator for code names" 84 | " ") 85 | 86 | (defn codename 87 | "Generate a name composed of two or three parts. This can be used 88 | to generate release names for the uninspired. The 0-arity uses an 89 | internal corpus and a space as separator for the elements. The 90 | following arguments can be provided as keyword arguments or using 91 | a map as the first argument: 92 | 93 | - `corpus`: The list of names. Either one or two elements from this 94 | corpus will be picked for every generated name. Prefer 95 | adjectives or qualifying words here. 96 | - `suffixes`: A list of suffixes, a single one picked for every generated 97 | name. Prefer nouns here. 98 | - `separator`: A string to use to join elements together, defaults to a 99 | space. 100 | - `join?`: Whether to join using the separator, defaults to true. 101 | Otherwise yields a vector. 102 | 103 | " 104 | ([& {:keys [corpus suffixes separator join?] 105 | :or {corpus default-corpus 106 | suffixes default-suffixes 107 | separator default-separator 108 | join? true}}] 109 | (let [name1 (rand-nth corpus) 110 | name2 (rand-nth corpus) 111 | suffix (rand-nth suffixes) 112 | i (rand-int 100)] 113 | (cond->> (cond 114 | (<= i 15) [name1 name2 suffix] 115 | (< 15 i 31) [suffix name1] 116 | :else [name1 suffix]) 117 | join? 118 | (str/join separator))))) 119 | 120 | (comment 121 | 122 | ;; Quick examples 123 | (codename) 124 | (codename :separator "-") 125 | (codename {:join? false})) 126 | --------------------------------------------------------------------------------