These are chat archives for dry-rb/chat

10th
Oct 2016
John Backus
@backus
Oct 10 2016 00:13
Is there some other way right now to run the dry-rb.org website locally? (cc @timriley or @AMHOL)
I've bundled and done npm install but I get an error if I try to do bundle exec rake watch
Tim Riley
@timriley
Oct 10 2016 00:14
What’s the error?
== The Middleman is loading
/Users/johnbackus/.gem/ruby/2.3.1/gems/middleman-blog-4.0.0/lib/middleman-blog/blog_data.rb:170: warning: key :lang is duplicated and overwritten on line 170
== Executing: `./node_modules/webpack/bin/webpack.js --watch -d`
/Users/johnbackus/Projects/dry-rb/website/config.rb:65:in `gethostbyname': getaddrinfo: nodename nor servname provided, or not known (SocketError)
    from /Users/johnbackus/Projects/dry-rb/website/config.rb:65:in `evaluate_configuration!'
I actually dropped into irb and did Socket.gethostname
Gives me backus (my last name) so maybe it is an os x thing that this is the host name that pops up?
timriley @timriley tries
John Backus
@backus
Oct 10 2016 00:17
heh
haha from the docs:
Note that it is not guaranteed to be able to convert to IP address using gethostbyname, getaddrinfo, etc.
activate :livereload, host: Socket.gethostbyname(Socket.gethostname).first
I guess I'm the edge case!
I guess I'll PR a bug fix?
Tim Riley
@timriley
Oct 10 2016 00:20
oh! Yes please!
John Backus
@backus
Oct 10 2016 00:24
@timriley I would be interested in asking Jasmin Wong about her code since I don't know enough to be confident about my fix being better
She is part of the icelab team. Would you be able to get her on gitter or just ask her?
Tim Riley
@timriley
Oct 10 2016 00:28
I could follow up with things, yeah. What would you like to know?
John Backus
@backus
Oct 10 2016 00:28
Well her comment says Make sure that livereload uses the host FQDN so we can use it across network
As far as I know that just means getting the ip address accessible on the local network (so 10.x.x instead of 127.0.0.1) but I know very very little about networking
So I basically want the original author to sanity check whatever change I make I guess
So my PR isn't just like "break other people's workflow in order to fix my own" :laughing:
Tim Riley
@timriley
Oct 10 2016 00:30
Cool, if you PR this, I’ll get someone here at least to check.
John Backus
@backus
Oct 10 2016 00:31
Thanks :)
Piotr Solnica
@solnic
Oct 10 2016 00:33
dry-constructor :skull:
Tim Riley
@timriley
Oct 10 2016 00:34
some code must die so that others can live. we salute you, dry-constructor.
John Backus
@backus
Oct 10 2016 00:38
Ok so I guess the issue is just that gethostname(3) on my machine returns backus even though the resolvable hostname would be backus.local
Not sure if that is some setting I have that is causing that
John Backus
@backus
Oct 10 2016 00:44
Hm
welp
scutil --set HostName 'backus.local' fixes the issue for me
I don't know enough to fix this and it could be misconfiguration for me so I'm not sure enough to make a change shrug
Tim Riley
@timriley
Oct 10 2016 00:48
yeah, I’m a bit ¯_(ツ)_/¯-y on matter like this too
So you can use the site now though?
John Backus
@backus
Oct 10 2016 00:49
Yup
Time to document dry-struct :)
Tim Riley
@timriley
Oct 10 2016 00:50
sweet!
John Backus
@backus
Oct 10 2016 01:21
@solnic or @timriley any chance you could make me a collaborator for dry-rb.org so I can do the PR without making a fork?
Tim Riley
@timriley
Oct 10 2016 01:21
@backus can do now
John Backus
@backus
Oct 10 2016 01:22
Thanks :)
Tim Riley
@timriley
Oct 10 2016 01:22
There you go
John Backus
@backus
Oct 10 2016 01:22
Thanks!
Nick Sutterer
@apotonick
Oct 10 2016 04:02
@timriley i'm planning an API in Operation a la Op.(params, user_repo: ...), so one positional, and the rest kw args. will that work with auto_inject/initialize?
Tim Riley
@timriley
Oct 10 2016 04:36
@apotonick Not with any of the existing injection strategies, no
We keep runtime things like “params” totally away from the initializer so far
You could probably build an injection strategy that’ll let you pass params through and look to the second arg/kwargs for the deps, though
It’d be a bit of a divergance from what we’ve done so far - all the injection strategies are around providing deps as instance variables via the initializer - so it might take a bit of experimenting
Nick Sutterer
@apotonick
Oct 10 2016 04:46
oh no, so will it be really hard to implement?
Tim Riley
@timriley
Oct 10 2016 04:47
I don’t think it’d be “really hard”, no.
It’d just need some working out, since it’s slightly off the path we’ve trod so far.
Nick Sutterer
@apotonick
Oct 10 2016 04:47
because, we don't want instances to stick around, hence the Op.() semantics everywhere (cells, trailblazer, soon reform, etc)
Tim Riley
@timriley
Oct 10 2016 04:47
However, dry-auto_inject is now built so that you can provide your injection strategies, so at least it’s modularised enough to allow you to do this.
Nick Sutterer
@apotonick
Oct 10 2016 04:53
could you help me implementing that?
the semantic is like (runtime parameters, kw: args, for: dependency, injection: true)
Tim Riley
@timriley
Oct 10 2016 05:01
It’d be like https://github.com/dry-rb/dry-auto_inject/blob/master/lib/dry/auto_inject/strategies/constructor.rb, except instead of defining .new and #initialize (which is done by subclasses here), you’d just define .call
Nick Sutterer
@apotonick
Oct 10 2016 05:01
uhm, wait, we still need an initializer
:D
Tim Riley
@timriley
Oct 10 2016 05:01
oh what?
oh, .call(foo, bar) effectively goes .new(something_here_maybe).call(foo, bar) or something?
Nick Sutterer
@apotonick
Oct 10 2016 05:04
.call(foo, bar) would do .new(foo, bar).call(foo, bar) i guess
simply passes it to both methods
Tim Riley
@timriley
Oct 10 2016 05:05
why would you want it going to both?
Nick Sutterer
@apotonick
Oct 10 2016 05:07
because in new, the polymorphic builder is called and the programmer might need arbitrary data to decide what to build
actually... not sure if we'd need bar in call, you're very right
the API has been around for 2 years now, all i want is to make it work with auto_inject/initialize so we can hook our objects into dry and vice-versa
Tim Riley
@timriley
Oct 10 2016 05:09
anyway, so this sounds like it actually just a case of constructor dependency injection after all
so you probably want some variation of the Kwargs strategy (https://github.com/dry-rb/dry-auto_inject/blob/master/lib/dry/auto_inject/strategies/kwargs.rb)
Nick Sutterer
@apotonick
Oct 10 2016 05:10
"variation"?
Tim Riley
@timriley
Oct 10 2016 05:10
except you’d look for the kwargs on the second arg
and you’d just pass through/assign the first arg, your “params”
Nick Sutterer
@apotonick
Oct 10 2016 05:11
i'll have a look, going on a trip now. thanks for your help brother
Tim Riley
@timriley
Oct 10 2016 05:11
:+1:
Alternatively, you could just give your params a “special” arg name
e.g. params: and then just go kwargs for everything
Tim Riley
@timriley
Oct 10 2016 05:18
params would be in that case a “dependency” that must always be provided manually, rather than looked up by any auto-injection system
I’m not sure if that feels good or not, though
heh
Nikita Shilnikov
@flash-gordon
Oct 10 2016 08:24
@backus sure man, no problem. I was actually about it, but then I dug a bit deeper and found there was no spec for callable defaults so considered this behavior as a bug/overlook. So if you have any strong dependencies on some behavior, be sure it's covered with specs. Anyway, I'll cc you next time in any case :)
John Backus
@backus
Oct 10 2016 08:31
Thanks
Yeah I'm not too worried and I think I specified our needed behavior pretty closely
Nick Sutterer
@apotonick
Oct 10 2016 09:00
@timriley i have the :params kw name ATM but it .. sucks. it feels too clumsy