Fork me on GitHub
#clojure-uk
<
2017-09-26
>
thomas07:09:28

moin moin morning

yogidevbear09:09:58

☁️ 🕔

maleghast11:09:39

Ello All

maleghast11:09:59

How’s everyone doing?

maleghast11:09:25

@mccraigmccraig - I say! Big ‘ole rebuild?

mccraigmccraig11:09:15

not really @maleghast - mostly incremental, but quite a big increment in this current release - replacing our current direct-style messaging implementation with one which supports both newsfeed-style and direct style messaging

maleghast11:09:32

*nods* - I see 🙂

maleghast11:09:01

Well, I am glad to hear (for your sake) that you are not starting all over again, that can be a very daunting prospect 🙂

maleghast11:09:11

(sometimes necessary, but great that it’s not)

mccraigmccraig11:09:28

clojure is pretty good at incremental - i've only had a single nasty problem relating to incremental changes that i can remember

mccraigmccraig11:09:48

(which was related to moving from using the key/values of a map record as properties directly (with key-fns or destructuring) to requiring a fn to synthesize some properties from the record)

dominicm12:09:11

Sometimes I really like Java, sometimes, you discover they made something useful private: https://stackoverflow.com/a/15596145

dominicm12:09:14

the answer to parse regexes using regex also makes me 😞

iaint12:09:22

thank you 🙂

yogidevbear12:09:09

Nice news on v2 of yapster @mccraigmccraig... Is it launched or in the process of development?

mccraigmccraig12:09:57

still in dev @yogidevbear - another few weeks to go before it hits the appstores

yogidevbear12:09:31

Well I hope it's smooth sailing all the way simple_smile

chrjs14:09:51

Morning all.

chrjs14:09:34

Anyone tried mocking out auth in ring for testing before? I have the feeling I’m barking up the wrong tree.

dominicm14:09:28

@chrjs just so I'm certain, what do you mean by mocking out the auth?

dominicm14:09:43

probably useful to know if you're using a lib like buddy to help with auth

chrjs14:09:50

What I want to be able to do is something like this:

chrjs14:09:59

(defn make-app [auth]
  (-> routes ;; compojure defroutes
      blah
      (wrap-authorization auth)
      blah))
So it can be tested like this
(deftest test-app-with-mocked-auth
 (let [app (make-app some-auth-from-namespace)])
   (is (:status (app (mock/request :get "api/url/banana")))))

dominicm14:09:54

and wrap-authorization is a magic function?

chrjs14:09:01

Sorry, yes, buddy

dominicm14:09:17

> The backend parameter should be a plain function that accepts two parameters: request and errordata hashmap, or an instance that satisfies IAuthorization protocol. So, (make-app (fn [req errordata] true)) might work?

chrjs14:09:46

Hmm, will try that.

dominicm14:09:17

(constantly true) is more idiomatic

chrjs14:09:48

(@sleepyfox is my pair right now, welcome to the team, Dom :p)

sleepyfox14:09:14

And thanks @dominicm , I'm working on this with @chrjs atm

sleepyfox14:09:40

Seems to be WAD

chrjs14:09:52

Ok, seems to work. I think our problem was actually trying to do something crazy passing around namespaces before.

sleepyfox14:09:58

note to self: just pass fns

sleepyfox14:09:08

(when in fn lang)

dominicm15:09:01

You can implement the interface too, if you want OO… Go on, you know you want to.

dominicm15:09:33

Where do you guys work?

sleepyfox15:09:52

We've met btw Dom, if you remember - I used to work with Malcolm and Kris on the Sphonic project

dominicm15:09:53

Right now you're just the fox on the screen. I'm better with faces than projects themselves.

sleepyfox15:09:22

I presume that if one wants to pass a bunch of configuration, similar to constructor injection in OOP, then a simple hash of fns is the usual way of supplying dependencies for the ring handler?

dominicm15:09:19

> hash of fns Is it config, or is it a function which gets swapped out?

sleepyfox15:09:43

It's functions that get swapped for mocks

dominicm15:09:08

2 options really: * Dynamic vars * A map that you pass in I don't think either is worse than the other necessarily.

sleepyfox15:09:37

The equivalent of supertest style: request(app).get('/user').expect('Content-Type', /json/).expect(200)

dominicm15:09:38

I think that depends actually.

sleepyfox15:09:22

Where we say app = require('my_app')(auth, db)

dominicm15:09:34

https://clojuredocs.org/clojure.core/bound-fn are you saying you don't use this always @mccraigmccraig? 😆 Although, delay does the right thing & family

glenjamin15:09:06

but yeah, the equivalent of require('my_app')(auth, db) is (app/make-app auth db)

sleepyfox15:09:11

Yes, we're using ring-mock

glenjamin15:09:14

where make-app returns a ring handler

sleepyfox15:09:52

Which is exactly where we are, but with more things to inject a hash for config seems more elegant

glenjamin15:09:15

yes and no, if you have lots of params i’d say yes - but it also makes it much easier to have lots of params

glenjamin15:09:18

which maybe you shouldn’t

sleepyfox15:09:48

A production web service has quite a few 'side-causes' as Kris calls them

glenjamin15:09:02

it’s possible to make a bunch of handlers and then combine them into one, same thing you can do with Router in express

glenjamin15:09:10

so that might be a useful way of scoping deps

dominicm15:09:35

actually, it doesn't look like delay does use that... maybe it uses it via something else.

dominicm15:09:38

I could have sworn this worked

dominicm16:09:46

user=> @(binding [*x* 20] (delay (prn *x*)))
10
nil
user=> @(binding [*x* 20] (future (prn *x*)))
20
nil

dominicm16:09:21

wait, duh, of course that works

mccraigmccraig16:09:24

bound-fn sounds like a nightmare waiting for you to restart your app-context too

chrisjd17:09:22

Anyone here used tempura for app i18n? Would you recommend?