Fork me on GitHub
#clojure
<
2019-09-19
>
seancorfield01:09:19

@kenny I think you're the person to comment on the seed not necessarily following the rules of the cache (because of what @hiredman said) but I think I'll try to update the docs to make that clearer somehow...

4
seancorfield02:09:35

Nothing specific. There are several ways of doing it.

seancorfield02:09:29

(given the caveat of :x/a and :y/a would collapse onto the same unqualified key)

seancorfield02:09:08

clojure.set/rename-keys might make it easier if you have a fixed set of keys.

seancorfield02:09:52

(zipmap ks (map (comp keyword name) ks)) would give you a map of qualified keys to unqualified keys that you could use with rename-keys

iGEL11:09:50

For an internal library, I'd like to implement a version check that alerts, if the library is outdated. How can I get the version number of the library when run inside the using app both in leiningen and uberjar? Can I write the version number somehow during publishing a version to our private repo (we use s3-wagon-private)? My best idea was to parse the class path, but that doesn't work for uberjars

jumar11:09:12

We store that info in config.edn file which gets updated whenever we do a new release

iGEL13:09:38

@U06BE1L6T Interesting. Do you read from that edn when during runtime? My goal is to know the lib version when it's executed.

jumar13:09:07

Yes, we do. It contains all the configuration keys - using cprops library

csm17:09:00

if it’s built with leiningen, you’ll also have META-INF/leiningen/<group>/<name>/project.clj for all components of an uberjar, and META-INF/maven/<group>/<name>/pom.xml for maven artifacts

👍 4
g16:09:31

anyone have any good resources on setting up logging in aws with clojure?

g16:09:07

specifically configuring different log groups and directing events as appropriate

ataggart16:09:12

I suspect that would depend more on the logging implementation than the language.

g16:09:47

i’m open to whatever, currently just printing to stdout

g16:09:00

trying to get a sense of what’s available

emccue23:09:55

Where should I keep specs?

emccue23:09:24

like, if i define a spec i need to use the namespaced keyword redonkulousness

emccue23:09:07

so if i define a spec in a namespace other than the one im using it would that whole namespace be loaded?

emccue23:09:19

if there some sort of convention?

emccue23:09:28

(and related question - how can i validate a map where the name of the item in the map isnt the same name as the spec)

hiredman23:09:19

keyword namespaces having nothing to do with code namespaces

👍 4
hiredman23:09:45

you don't need a corresponding code namespace to use a namespace with a keyword

👍 4
hiredman23:09:30

in fact I generally argue it is better to avoid using specific code namespaces and namespaces in your data, so the two are not coupled

emccue23:09:50

hmm okay but that seems to be like, the way to do it with spec

hiredman23:09:59

and don't use '::' so you can copy and paste data freely without worrying about context

emccue23:09:06

(s/def ::credit-card credit-card-predicate)

hiredman23:09:19

the docs show using '::' because they favor concision

emccue23:09:37

same question though

emccue23:09:43

if i s/def in a namespace

emccue23:09:59

then i spec a function saying its first argument is other.ns/credit-card

emccue23:09:07

does that load in that namespace?

emccue23:09:56

okay so then the other question i have

hiredman23:09:24

specs basically have a whole other system of names off to the side and don't store data or interact with code namespaces

emccue23:09:36

(s/keys :req-un [:company/name])

emccue23:09:47

or (s/keys :req [:company/name]))

emccue23:09:51

i understand how that works

emccue23:09:08

but how do i do it if i have some external data that comes in like

emccue23:09:16

{"companyName" ...}

hiredman23:09:31

a spec can be any predicate

hiredman23:09:01

can you write a predicate that returns true or false given some external data if it is the shape you want?

emccue23:09:30

yes, but the s/keys made predicates "know" how to include the key name in the error message

hiredman23:09:14

user=> (s/valid? #(contains? % "companyName") {"companyName" nil})
true
user=>

hiredman23:09:22

user=> (defn contains-company-name? [x] (contains? x "companyName"))
#'user/contains-company-name?
user=> (s/explain contains-company-name? {})
{} - failed: contains-company-name?
nil
user=>

Alex Miller (Clojure team)23:09:50

It’s probably easier to keywordize keys for stuff like this right now

hiredman23:09:11

and there are other ways to customize the behavior, and get more out of your predicates (generating, etc) but you can start there

seancorfield23:09:59

@emccue https://corfield.org/blog/2019/09/13/using-spec/ might be helpful for you -- it talks about how @hiredman and I use Spec at work.