These are chat archives for dry-rb/chat

30th
Jun 2016
:tada: :tada: :tada:
Joe Van Dyk
@joevandyk
Jun 30 2016 04:06
should that be attrs = articles.create(result.output) or something?
Tim Riley
@timriley
Jun 30 2016 04:07
yeah, should be result :disappointed: , or result.to_h
Joe Van Dyk
@joevandyk
Jun 30 2016 04:07
not result.ouput?
ah ok
Tim Riley
@timriley
Jun 30 2016 04:07
yeah, #to_h
look at that guy on the left. staring straight at the slides and missing the error ;)
Joe Van Dyk
@joevandyk
Jun 30 2016 04:08
is to_h same as output?
lol
Tim Riley
@timriley
Jun 30 2016 04:08
yeah, #to_h is just the preferred API now
Joe Van Dyk
@joevandyk
Jun 30 2016 04:13
@timriley using result without to_h/output wouldn’t work right?
Tim Riley
@timriley
Jun 30 2016 04:15
Maybe not. I’m not sure. I know it offers access like result[:attr_name]. I’m not sure if the rom command will implicitly .to_h on its input though
you could try :)
Wilson Silva
@wilsonsilva
Jun 30 2016 06:58
@solnic, @timriley Yesss! It landed just when I needed. Thanks
Tim Riley
@timriley
Jun 30 2016 06:59
:bow:
Piotr Solnica
@solnic
Jun 30 2016 07:50
We rely on to_hash internally in rom so anything that can be dumped into hash via Kernel.Hash method will work
Piotr Solnica
@solnic
Jun 30 2016 08:05
@timriley @joevandyk ^^ as in, this was not a mistake in the slide, it works via duck typing
Tim Riley
@timriley
Jun 30 2016 08:44
Right. Thought so.
Piotr Solnica
@solnic
Jun 30 2016 09:43
oh wait, there is a mistake in the slide, should be articles.create(result) :)
@timriley ^
dear lord
@timriley @flash-gordon great work guys on matcher/monads :) congrats on the releases
Tim Riley
@timriley
Jun 30 2016 10:20
@solnic thanks! Feels so much more useful than the previous version :)
And yeah, I'll fix that misnamed variable in my slides sometime soon.
Nikita Shilnikov
@flash-gordon
Jun 30 2016 10:37
@solnic thanks :) @timriley yeah, I'm gonna give it a try asap;)
Piotr Solnica
@solnic
Jun 30 2016 10:37
@timriley are you using latest-latest master in your apps?
Tim Riley
@timriley
Jun 30 2016 10:38
@solnic of some things, yeah.
Piotr Solnica
@solnic
Jun 30 2016 10:38
ok specifically dry-v/t/l?
Tim Riley
@timriley
Jun 30 2016 10:38
Yeah, we’re tracking master of those in berg. Not sure how recently we updated them though.
Looks like a month ago
Piotr Solnica
@solnic
Jun 30 2016 10:40
could you bundle update them and see if it’s all good?
Tim Riley
@timriley
Jun 30 2016 10:41
Yeah
Just need a few moments
Chris Richards
@cmrichards
Jun 30 2016 10:50
Is there an example web-app on github showcasing all the dry-rb technologies working nicely together?
Wilson Silva
@wilsonsilva
Jun 30 2016 10:57
@cmrichards the library has been renamed to dry-matcher - http://dry-rb.org/gems/dry-matcher
Chris Richards
@cmrichards
Jun 30 2016 10:58
The link has just been fixed
Wilson Silva
@wilsonsilva
Jun 30 2016 10:59
This is an example https://github.com/icelab/berg
Tim Riley
@timriley
Jun 30 2016 11:07
@cmrichards where’d you see the broken link?
Chris Richards
@cmrichards
Jun 30 2016 11:07
it might have been an old tab
Tim Riley
@timriley
Jun 30 2016 11:07
Ah yeah. I updated that today.
Chris Richards
@cmrichards
Jun 30 2016 11:08
What do Tim and Piotr use as text editors?
Tim Riley
@timriley
Jun 30 2016 11:09
I use Sublime Text
Rolf Bjaanes
@rolfb
Jun 30 2016 11:09
Piotr uses Spacemacs with evil mode
Piotr Solnica
@solnic
Jun 30 2016 11:10
I switch between spacemacs and vim actually
I didn’t get spacemacs to work for ruby well-enough
Chris Richards
@cmrichards
Jun 30 2016 11:11
spacemacs is vim and emacs? what is this madness?
Piotr Solnica
@solnic
Jun 30 2016 11:11
it’s pretty good for clojure and scala
I gotta tweak it for ruby a bit, I just can’t live w/o well working debugging inside the editor + running tests
and right now it doesn’t work for me as well as my vim setup (for ruby)
Tim Riley
@timriley
Jun 30 2016 11:18
@solnic latest dry-{v,l,t} still works with berg’s specs
Piotr Solnica
@solnic
Jun 30 2016 11:18
good
thanks, I’ll try to wrap this up tomorrow and push releases
and I really think for 0.9 we should think about separating “params” validation from domain stuff
Tim Riley
@timriley
Jun 30 2016 11:19
I would like to see this
I think it’d encourage a healthy separation for users
Chris Richards
@cmrichards
Jun 30 2016 11:23

In view "pages.about", where is the 'people' local variable set? In routes file its just :

route "about" do |r|
r.view "pages.about"
end

Tim Riley
@timriley
Jun 30 2016 11:26
@cmrichards It’s set in Main::Views::Pages::About#locals
Tim Riley
@timriley
Jun 30 2016 11:26
the idea in general is to have only very high-level logic in those routes, so most details like that you’ll find elsewhere.
Chris Richards
@cmrichards
Jun 30 2016 11:28
ok thanks. Where is the "pages.about" resource (or whatever) defined?
Oskar Szrajer
@gotar
Jun 30 2016 11:29
there is special plugin for roda (view)
Tim Riley
@timriley
Jun 30 2016 11:29
Yeah, it’s a roda plugin. If something is called using r.view, then it fetches an object from the container matching ”<component_name>.views.<argument>”, e.g. ”main.views.pages.about”
and then you can convert that identifier to a source file path by replacing the dots with slashes :)
it's easier to understand I think on fresh code generated from dry-web-roda
app generator
less code, easier to focus and trace, then you can go and check berg
Chris Richards
@cmrichards
Jun 30 2016 11:31
So ”main.views.pages.about” isn't defined in the container but it's still in the container?
Chris Richards
@cmrichards
Jun 30 2016 11:33
Ah ok I see
Oskar Szrajer
@gotar
Jun 30 2016 11:33
you should check some more basic example, if you have already dry-web-roda gem
you can call dry-web-roda new AppName
Chris Richards
@cmrichards
Jun 30 2016 11:34
I will. Complex examples are good too though
Oskar Szrajer
@gotar
Jun 30 2016 11:34
and use skeleton to learn basic schema
Chris Richards
@cmrichards
Jun 30 2016 11:34
Will an empty dry-web-roda project tell me anything?
Oskar Szrajer
@gotar
Jun 30 2016 11:34
it's not empty
its generate whole basic app structure
basic project skeleton
Chris Richards
@cmrichards
Jun 30 2016 11:35
ok cool i'll try it now
Tim Riley
@timriley
Jun 30 2016 11:35
We lack guides/docs. I hope I can start writing some in the next few weeks.
Oskar Szrajer
@gotar
Jun 30 2016 11:35
much easier approuch - https://github.com/gotar/dry-web-skeleton simple blog API
but without all dry stack gems
just DI (IoC) and few others
Chris Richards
@cmrichards
Jun 30 2016 11:37
I'm very interested in seeing how practical dry-transaction is. It looks pretty neat, but a part of me thinks it might be overkill
Piotr Solnica
@solnic
Jun 30 2016 11:37
@cmrichards an overkill to do…what?
Oskar Szrajer
@gotar
Jun 30 2016 11:38
there are other implementation of this is you think it's not fit your needs
Piotr Solnica
@solnic
Jun 30 2016 11:38
I’m 100% sure you’re gonna appreciate error handling there
Chris Richards
@cmrichards
Jun 30 2016 11:38
ok good
It almost looks too good to be true
Piotr Solnica
@solnic
Jun 30 2016 11:39
it is true :) we’ve been using it for many months + it’s based on transflow gem that I wrote a year ago or so, also used on production
once every processing becomes a standalone thing, you can very easily handle errors
ie the original transflow gem was written because i had a really complex stuff in my past project where we had 10+ cases where things could go wrong and this approach helped me clean this up and make this really simple
Chris Richards
@cmrichards
Jun 30 2016 11:41
Where are the errors dealt with? in the routes file?
Piotr Solnica
@solnic
Jun 30 2016 11:41
yes, because that’s the place where you put together a response to the client :)
Chris Richards
@cmrichards
Jun 30 2016 11:42
But what if other business code needs to be run when a step fails?
You trigger that in the routes too?
Piotr Solnica
@solnic
Jun 30 2016 11:43
depends what it is, you can handle that inside a given step too, or the route, or even attach an event listener so that external systems can react to failures or successes (ie send a warning email to the admin etc)
Chris Richards
@cmrichards
Jun 30 2016 11:56

What are the advantages of doing :

include Admin::Import("admin.persistence.repositories.users")

over a simple require? It seems like "admin.persistence.repositories.users" is already coupled to that specific file.

Tim Riley
@timriley
Jun 30 2016 12:03
requiring it just loads the source file
you would still then need to set up the initializer for the class to accept it as an injected dependency and assign it to an ivar, etc.
and also, calling .new on that dependency wouldn’t be enough
what if it had dependencies on other objects in the container
auto_inject makes all of this work
Chris Richards
@cmrichards
Jun 30 2016 12:04
right I see. so doing the import makes it container aware
Piotr Solnica
@solnic
Jun 30 2016 12:07
yes, you require import module and that needs the container
Daniel Sandbecker
@daniels
Jun 30 2016 12:15
For what its worth, I have wrapped Dry::AutoInject in a module that sets up an empty container if it hasn't been registered when the class including it is required. This makes my classes container aware, but not container dependent - I can require them and call them with explicit dependencies without first setting up the container. I'm sure I will feel more comfortable removing the wrapper when I've settled in the "containers everywhere" mindset, but for now I like that my classes stand a little bit more on their own.
(Originally I achieved the same (possibly meaningless) sense of control by only including Dry::AutoInject after the classes were already defined, but then I didn't get the benefit of constructor and accessor generation.)
Piotr Solnica
@solnic
Jun 30 2016 12:19
@daniels it’s actually how it works with dry-component
that’s why we can load things on-demand
container can be empty and dry-component will resolve deps and require/setup/boot things that are needed for a particular part of your system
Daniel Sandbecker
@daniels
Jun 30 2016 12:20
@solnic Ah, so to feel like I'm still on the surface I have to dive deeper ... :smile:
Tim Riley
@timriley
Jun 30 2016 12:20
That’s a super cool feature.
MyClass.new -> everything gets loaded/resolved as required, just enough for that one class, nothing more
Piotr Solnica
@solnic
Jun 30 2016 12:20
it is, I gotta record a screencast and show it off
Chris Richards
@cmrichards
Jun 30 2016 12:21
Berg::Form looks curious
Tim Riley
@timriley
Jun 30 2016 12:23
That’s for https://github.com/icelab/formalist, which is still a work-in-progress, and unless you’re interested in advanced form builders, you could safely ignore that for the time being while you learn the other things
Chris Richards
@cmrichards
Jun 30 2016 12:23
yeah I found it. No readme :-(#
Tim Riley
@timriley
Jun 30 2016 12:23
It’s not ready for broader consumption
Chris Richards
@cmrichards
Jun 30 2016 12:24
It looks like a different approach to form building? It seems you are defining your field types in your class
Piotr Solnica
@solnic
Jun 30 2016 12:24
I guess we coupl prep a simpler sample app w/o formalist
Tim Riley
@timriley
Jun 30 2016 12:25
Yeah. It would be good to expand on the original rodakase-blog.
icelab/berg only serves as the example app right now because there’s nothing else out there :grimacing:
and we had other motiviations to push ourselves and finish it
timriley @timriley adds it to the list of things to consider at rails camp
Chris Richards
@cmrichards
Jun 30 2016 12:28
Will upgrading a dry-rb based web-app be more or less difficult than upgrading a rails 2 app to rails 3? ;-)
Tim Riley
@timriley
Jun 30 2016 12:29
will my orange taste like an apple? ;)
It’d be more difficult, I bet. It’s not just an upgrade of libraries you’re already using (however large the version gap), it’s a different paradigm.
Chris Richards
@cmrichards
Jun 30 2016 12:30
I've rephrased it. I meant to add the word 'upgrading' to the start of the sentence
Tim Riley
@timriley
Jun 30 2016 12:33
There’ll definitely be some churn across the short-/medium-term as we figure things out. But it’s manageable. We handle it already for multiple apps.
And as for upgrading, we don’t have “marketing” versions like Rails 2/Rails 3
dry-/rom- gems follow semver, so as long as you lock to the version you want, things should be stable
you’re not forced to upgrade things until you want something new
and when you do, it’s more likely you’ll be able to update individual components rather than the enture stack at once
Chris Richards
@cmrichards
Jun 30 2016 12:37
Why is ""core.authentication.encrypt_password" imported here when it's not used here? https://github.com/icelab/berg/blob/master/apps/admin/lib/admin/users/operations/update.rb
Tim Riley
@timriley
Jun 30 2016 12:37
because it used to be used and we forgot to remove the import :)
Chris Richards
@cmrichards
Jun 30 2016 12:37
:-) good
timriley @timriley fixes
Chris Richards
@cmrichards
Jun 30 2016 12:39
"include Dry::ResultMatcher.for(:call)" looks a bit strange here
Tim Riley
@timriley
Jun 30 2016 12:39
how so?
Chris Richards
@cmrichards
Jun 30 2016 12:41
Maybe because it's not immediately obvious to me what it does. Is it basically saying that call will return and accept a monad?
Tim Riley
@timriley
Jun 30 2016 12:42
It means that the dry-result_matcher match block API will be offered for the #call method
my_thing.call do |m|
  m.success do |v|
  end

  m.failure do |v|
  end
end
^ that thing
without that include all #call does is return a value. the include enhances it with this API for when you pass a block.
Chris Richards
@cmrichards
Jun 30 2016 12:43
ahhh... off course
Tim Riley
@timriley
Jun 30 2016 12:46
(n.b. dry-result_matcher is dry-matcher as of today and the API is slightly different)
Luca Guidi
@jodosha
Jun 30 2016 12:51
Hi folks, I've noticed that the hanami-validations build has slowed down recently: from 4 to 16 seconds. I just kept updating the dry-* deps. Maybe it's a symptom to find some bottleneck. Dunno, just wanted to communicate this :)
Piotr Solnica
@solnic
Jun 30 2016 12:51
really? that's weird coz we made perf improvements and our suite got faster O_o
I'll look into that
Luca Guidi
@jodosha
Jun 30 2016 12:54
I wanted to ask if the new syntax with the types has perf advantages.
I haven't updated yet hanami fixtures to this new syntax.
Piotr Solnica
@solnic
Jun 30 2016 12:54
yeah it's gazillion times faster for defining schemas
but no diff at runtime
Luca Guidi
@jodosha
Jun 30 2016 12:55
But there are a lot of schemas defined in Minitest before blocks.
So they aren't preloaded when the test suite starts.
It's safe to port fixtures to the new typed API?
Piotr Solnica
@solnic
Jun 30 2016 13:00
I'd say this feature will be marked as experimental for now
I mean, it works fine, but I'm not yet entirely sure about the api
Luca Guidi
@jodosha
Jun 30 2016 13:00
Okay, I changed several times that fixtures, I hold for now :D
thank you @solnic :)
Chris Richards
@cmrichards
Jun 30 2016 13:05

In the user Update operation, why don't you also inject the validation form? https://github.com/icelab/berg/blob/master/apps/admin/lib/admin/users/operations/update.rb

The validation form does depend on an item in the container.

Piotr Solnica
@solnic
Jun 30 2016 13:07
@jodosha sure :) I’ll be trying to wrap up releases tomorrow btw
Luca Guidi
@jodosha
Jun 30 2016 13:07
@solnic dry-* releases?
Piotr Solnica
@solnic
Jun 30 2016 13:08
si
Luca Guidi
@jodosha
Jun 30 2016 13:08
:D
Chris Richards
@cmrichards
Jun 30 2016 13:13
Is it ok to leave a company if because the main project you work on, a 300+ table rails 2 app, is a grind to work on and you're not given any time to do major refactoring or upgrades to it? even if you built that sucky app yourself?
Ralf Schmitz Bongiolo
@mrbongiolo
Jun 30 2016 13:41
omfg, vanilla rails 2?
Jeff Dickey
@jdickey
Jun 30 2016 14:55
such apps exist. @cmrichards, your ethics may not allow this, but what I'd at least think about doing in your shoes is walk out, in thed process demonstrating that I'm not carrying anything but what's in my head; figure out a MVP that would cover the two or three biggest management-visible pain points with what you left behind, and offer to SAAS them a lightly-customised set of anything that's worth making a service useful to others as well. If it's Rails 2, they had to have heard your screams for at least 5 years; put the shoe on the other foot. IANAL, but I've been in disturbingly-similar shoes.
but the exercise only really works if you can sell the SAAS to other customers as well as them. they had control and messed themselves over, and karma's a pain
Piotr Solnica
@solnic
Jun 30 2016 16:36
$1M question - should "10." be considered as a valid representation of a decimal value??
Fran Worley
@fran-worley
Jun 30 2016 16:37
According to BigDecimal yes.
Piotr Solnica
@solnic
Jun 30 2016 16:37
right, so that we know :)
Fran Worley
@fran-worley
Jun 30 2016 16:37
according to Float, No
Piotr Solnica
@solnic
Jun 30 2016 16:38
irb(main):012:0> BigDecimal("10.").to_s
=> “0.1E2"
Chris Richards
@cmrichards
Jun 30 2016 16:39
It tells someone how precise the number is
Piotr Solnica
@solnic
Jun 30 2016 16:39
so yeah, I think we should not parse it in Form
Fran Worley
@fran-worley
Jun 30 2016 16:39
in ruby 2.2.4 I get "10.0" back from BigDecimal("10.").to_s
but yeah in form I wouldn't pass it as a valid decimal
Piotr Solnica
@solnic
Jun 30 2016 16:40
I love this kind of nuances :)
yeah we should not, definitely
gonna close the issue
Chris Richards
@cmrichards
Jun 30 2016 16:41
At the laboratory I work for, "10." is a valid result
Piotr Solnica
@solnic
Jun 30 2016 16:41
this is the context: dry-rb/dry-types#104
Chris Richards
@cmrichards
Jun 30 2016 16:41
we've had many discussions about this kind of thing
Fran Worley
@fran-worley
Jun 30 2016 16:42
In theory AM::V wouldn't pass it as valid either
Piotr Solnica
@solnic
Jun 30 2016 16:43
although…you might have a case where somebody really wants to send a form with 10. precision
so there’d be a difference between Form::Decimal and Form::Float
lol
it works fine in master
irb(main):002:0> Types::Form::Float['10.1']
=> 10.1
irb(main):003:0> Types::Form::Decimal['10.1']
=> #<BigDecimal:7fcfda0b0e80,’0.101E2’,18(18)>
oops, sorry bad values ;)
yeah, broken on master
Fran Worley
@fran-worley
Jun 30 2016 16:45
was going to say, if that didn't work we really have problems!
Piotr Solnica
@solnic
Jun 30 2016 16:45
lololol yeah
k, let’s fix it :)
btw we’re missing predicates for precisions :)
oh and precision is not supported by coercions too
Chris Richards
@cmrichards
Jun 30 2016 16:51
Correction: "10." isn't a valid analytical result from our laboratory. But it can happen if the system isn't setup correctly. All tests in our system have a SF (significant figure)and DP (decimal places) number which indicate how the number should be displayed on reports. If the SF is 4 and the DP is 0, then a result of 52.12 will show as "52."
Luca Guidi
@jodosha
Jun 30 2016 17:23
Sorry for spamming, but it would be cool to have somebody to talk about dry-rb http://www.rubyday.it/call-for-papers/
Piotr Solnica
@solnic
Jun 30 2016 17:27
@jodosha I’ll probably send a proposal
Luca Guidi
@jodosha
Jun 30 2016 18:10
@solnic <3
It would be great if somebody will talk about ROM too.
Piotr Solnica
@solnic
Jun 30 2016 18:12
@jodosha I suppose I can’t do 2 talks right? :laughing:
Andy Holland
@AMHOL
Jun 30 2016 18:12
:joy:
Nikita Shilnikov
@flash-gordon
Jun 30 2016 18:34
@solnic dry-rb/dry-validation@102fcba oops :)
I tried to update dry-v (finally) in one of my projects and it failed with undefined method warn' for [:val, [:predicate, [:key?, [:licenses]]]]:Dry::Validation::Schema::Rule (NoMethodError) :)
Luca Guidi
@jodosha
Jun 30 2016 18:35
@solnic I hope so :D
Theo Cushion
@theozaurus
Jun 30 2016 19:28
Hi All. Does anyone know how I might be able to merge Schemas in dry-validation? I have an invitation form that I want to say is a user form plus a token. I could do it using nesting, but I’d like to avoid that.
Piotr Solnica
@solnic
Jun 30 2016 19:35
@theozaurus merge as in inherit rules from another schema?
Nikita Shilnikov
@flash-gordon
Jun 30 2016 20:02
@solnic OK, now rom doesn't play nice with default types dry-rb/dry-types#105
Piotr Solnica
@solnic
Jun 30 2016 20:04
@flash-gordon ooooh great fix thanks!
Nikita Shilnikov
@flash-gordon
Jun 30 2016 20:24
stay tuned :) It seems rom-rb/rom-sql#67 will be the next because I have different table and relation names in this project, soooo...
Piotr Solnica
@solnic
Jun 30 2016 20:36
Hah right :)
John Backus
@backus
Jun 30 2016 21:22
btw @solnic I'm not sure if you ever saw my comment here before about this but what do you think about extracting dry-types structs to dry-structs?
@solnic I think they would become much more stable and would probably end up with better documentation if it was a separate gem (and I think it would be fine if dry-types just default pulled it in as a dependency)
Piotr Solnica
@solnic
Jun 30 2016 21:23
@backus I replied that I think it's a good idea :)
John Backus
@backus
Jun 30 2016 21:23
Would happy to be a maintainer for dry-structs
Oh cool well sorry about that then
Piotr Solnica
@solnic
Jun 30 2016 21:24
no worries :)
John Backus
@backus
Jun 30 2016 21:26
Is there anything I should do to make that happen? I don't know what the procedure is for being a member of the dry-rb org (or what the exact expectation is) but if you want dry-structs to happen I could just setup the repo and do the extraction soon
Piotr Solnica
@solnic
Jun 30 2016 21:36
@backus it should probably be called dry-struct (singular)
John Backus
@backus
Jun 30 2016 21:36
Feel free to PM me about that @solnic (after poland v. portugal game is over :smile:) if logistics would be noisy in main chat
backus @backus nods
John Backus
@backus
Jun 30 2016 21:40
:)
Alrighty I'll set a reminder for later today to begin extracting
:balloon: