Fork me on GitHub
#clojure
<
2020-01-17
>
noisesmith00:01:12

(or (str/replace main-class "-" "_")
                                    "clojure.main")
I bet this should be (if main-class (str/replace main-class "-" "_") "clojure.main") - just in terms of the behavior of and / str/replace https://github.com/seancorfield/depstar/blob/master/src/hf/depstar/uberjar.clj#L264

noisesmith00:01:58

haha you know what I'll just make that PR :D

seancorfield00:01:42

Yeah, that's my bad from a fix I added in 0.5.1 😞

seancorfield00:01:59

I need to do better testing!

noisesmith00:01:39

luckily it looks like a shallow bug

noisesmith00:01:58

@seancorfield on the plus side, I saw serious flaws with the other deps.edn jar / uberjar packagers that this lib avoids, that's why it's worth trying to make this one work

seancorfield00:01:27

Workaround, until I get 0.5.2 out: specify -m / --main 🙂

seancorfield00:01:56

This will be a good opportunity for me to switch my deploy process over to @slipset’s deps-deploy instead of mvn 🙂

seancorfield00:01:31

@noisesmith Please try seancorfield/depstar {:mvn/version "0.5.2"} to see if that works

👀 4
💯 4
noisesmith00:01:09

that's great customer service - works as expected, thanks

sheepy 8
seancorfield00:01:29

Thank you for the PR!

dominicm11:01:23

Assuming I have two lists like [1 3 4] ["a" "b" "c"] and I'd like to create something like [1 2 3 4] and ["a" nil "b" "c"] is there an idiomatic solution to that? I basically want to fill in the blanks with nils. Bit of a code golf I guess 🙂

dominicm11:01:21

My solution was to zipmap the first two structures, then map get over that against (take (range) (count x))

Daniel Stephens11:01:19

zipmap seems a good solution, not sure what you need the get for:

(let [a [1 3 4] 
      b ["a" "b" "c"]]
  (map (zipmap a b) [1 2 3 4]))

💯 4
4
dominicm11:01:16

Ah, neat. Good point.

Ramon Rios13:01:16

Hello Folks! I'm adventuring myself on java/clojure interop and i would like to ask something. I create a function to create a temporary .docx file (Huge thanks for @noisesmith for the suggestion)

(def tmp-dir (io/file (System/getProperty ".tmpdir")))

;my function
(defn create-temp-file []
  (File/createTempFile "temporary" ".docx" tmp-dir))

;the return of it
#object[.File 0x25209e59 "C:\\Users\\JDOE\\AppData\\Local\\Temp\\temporary1235918644188287069.docx"] 
I would like to get the path that is generated when i create my file to read this .docx . I tried a deconstruct but it returns me a nil, probably because i'm having a object, not a vector. Anyway, if you folks have some approach for it, i appreciate.

dpsutton13:01:14

you want to get the path of a http://java.io.File?

Ramon Rios13:01:38

Yes, looking on it, i saw that i can use (. (object) getPath)

Ramon Rios13:01:48

I don't know if it's the best approach

dpsutton13:01:34

https://docs.oracle.com/javase/8/docs/api/java/io/File.html#getCanonicalPath-- this looks like a good method on http://java.io.File. and you would call (.getCanonicalPath your-file)

Ramon Rios14:01:31

Sure, let me check that

kenny19:01:55

Does anyone know of a clojure.test extension lib that lets you do something like this?

(deftest foo-test
  (is (match= {:a [_ {:a "a"}]}
              some-data)))
I want to test equality for everything but the _.

noisesmith19:01:55

usually I just use get-in for that, I'm sure there's a test lib with a macro for it

kenny19:01:49

Yeah, I could do that. It just means I need to dissect the whole map to test it, which is fine I suppose.

noisesmith19:01:42

here's an approach using get-in and are

user=> (let [target {:a {:b :c} :d {:e [:f :g]}}]
         (clojure.test/are [path d] (= (get-in target path) d)
                           [:a] {:b :c}
                           [:e 0] :f))
FAIL in () (NO_SOURCE_FILE:1)
expected: (= (get-in target [:e 0]) :f)
  actual: (not (= nil :f))
false
user=> (let [target {:a {:b :c} :d {:e [:f :g]}}]
         (clojure.test/are [path d] (= (get-in target path) d)
                           [:a] {:b :c}
                           [:d :e 0] :f))
true

👍 4
seancorfield19:01:52

Expectations lets you use a destructuring binding which would get you close...

user=> (require '[expectations.clojure.test :refer [expect more-of]] '[clojure.test :refer [deftest]])
nil
user=> (deftest example
         (expect (more-of {[_{:keys [a]}] :a}
                          "a" a)
                 {:a [42 {:a "a"}]}))
#'user/example
user=> (example)
nil

seancorfield19:01:30

(as long as you're comfortable using nested destructuring!)

kenny19:01:32

Huh, interesting. Thanks!

ggiraldez19:01:21

I like https://github.com/metosin/testit . A combination of =in=> and any should work.

ggiraldez19:01:38

Something like:

(deftest foo-test
  (facts some-data =in=> {:a [any {:a "a"}]}))

kenny20:01:26

That's pretty neat too! I don't think mixing the midje syntax with a code base that pretty much exclusively uses clojure.test syntax is a great idea though 😬

seancorfield20:01:23

Another possibility with Expectations:

user=> (deftest example
         (expect (more-of {:keys [a]}
                          {:a "a"} (in a))
                 {:a [42 {:a "a"} :other :stuff]}))
#'user/example
user=> (example)
nil
This just expects {:a "a"} to be any one of the elements in the vector value for :a at the top level.

seancorfield20:01:04

(if you want an "exact" match of the structure with no extra keys or values, that's not going to help you tho')

caio21:01:56

http://github.com/nubank/matcher-combinators is great too and lets you do exactly that

👍 8
caio21:01:00

(require '[matcher-combinators.test :refer [match?]])
(deftest foo-test
  (is (match? {:a [any? {:a "a"}]}
              some-data)))

otwieracz19:01:35

What do you suggest for managing component's configuration?

otwieracz19:01:46

Or just loading edn as configuration? Anything special here?

lukasz19:01:59

we're using aero heavily https://github.com/juxt/aero

👍 4
noisesmith19:01:23

there are definitely helper libs (juxt/aero, outpace, environ), that allow various mixes of environment variables, jvm system properties, and config file parsing / merging

noisesmith19:01:50

you'll likely find one of them more aesthetically pleasing than the others

otwieracz19:01:51

OK, I will have look at aero - it seems very alive.

seancorfield19:01:27

We liked features from several config libs so we wrote our own(!) but it currently has some World Singles Networks' specific code so I haven't gotten around to open-sourcing it yet...

MatthewLisp23:01:00

Hello folks! Anyone here have experience with Clojure + AWS Lambda?

mruzekw23:01:45

@matthewlisp Ask in #aws or #aws-lambda