Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Jeff Dickey
@jdickey
or is that (database config) supposed to always use the environment variables in .env?
Jeff Dickey
@jdickey
…and another difference between dry-web-roda's and Rails' app generation relevant to my adaptation of that tut is that dry-web-roda new . generates an app, but doesn't take the current directory name as the app name, so you have bugs like config.ru having a line like run .::Web.freeze.app, which of course Shotgun barfs on. I see the workaround, but it makes the Docker interaction much more fragile, especially for a sub-padawan-level student like my boss :P
Jeff Dickey
@jdickey
pinging @timriley ^^
Gustavo Caso
@GustavoCaso
Jeff I’m not at home at the moment but once I get there I will happily answer you
Jeff Dickey
@jdickey
Great, thanks, @GustavoCaso
Gustavo Caso
@GustavoCaso
@jdickey regarding the force option I agree with you it would be useful I know @timriley is currently working on a new implementation of the CLI so I would wait some time for adding new CLI options
Tim Riley
@timriley
@jdickey You’re right about all of these shortcomings. As @GustavoCaso, we’re beginning to work on a better CLI and along with that we’ll hopefully address these sorts of things you bring up.
@jdickey Unfortunately, until that’s done, you might need to make do with what we have right now, sorry. I know it’s limited, but I wanted to make the project generator just exist in the first place to help people who want to get started with apps like these.
I want to build a bunch more generators, too.
@jdickey database setup works with app config (.env files or ENV vars) like everything else, so you’re on the right track there. right now we explicitly generate a rom bootable component for setting up the DB (into system/boot/persistence.rb) but eventually that will become an “external component” (a new feature of dry-system) and be hosted within some gem, so we won’t have to generate the same boilerplate into every project. It’ll also give us the ability to tweak the DB setup over time without requiring project maintainers to make those changes themselves.
Jeff Dickey
@jdickey
@timriley sounds great. No problem making do for now; just wanted to raise awareness of (particularly) that app-name-generated-as-dot problem. Should I open an issue re that on dry-web-roda?
Tim Riley
@timriley
Sure :)
Vsevolod
@stefkin

Hi guys. I have an issue with dry-validation. I have a schema with a bunch of optional fields (23 to be exact). I need to check if at least on of the fields is filled.
I figured I could use a custom validation block. Something like:

  validate(has_some_value: DECIMAL_FIELDS) do |*fields|
    fields.any? { |field| !field.nil? }
  end

But I ended up with the following error:
ArgumentError: wrong number of arguments (23 for -1)

It pops up in dry-logic's curry rule which makes sense. Is there any way around this?

Vsevolod
@stefkin

ok guys I ended up with the following rule:

  rule(any_value_filled: DECIMAL_FIELDS) do |*fields|
    fields.reduce(fields.first.filled?) { |acc, f| acc | f.filled? }
  end

somehow it doesn't produce the error. My only concern is that rule compiler repeats error message 23 times :)

Odin Dutton
@twe4ked
I tried to post this on Discourse but I'm not sure if it failed or it's still in the moderation queue. Anyway, I'm having some trouble trying to ensure an array is filled with hashes and also checking the schema of those hashes.
require 'dry-validation'

schema = Dry::Validation.Schema do
  required(:foo).filled(:array?).each do
    schema do
      required(:bar).filled(:str?)
    end
  end
end

p schema.({}).errors
# => {:foo=>["is missing"]}

p schema.(foo: []).errors
# => {:foo=>["must be filled"]}

p schema.(foo: [1]).errors
# => {}

p schema.(foo: [{}]).errors
# => {}

p schema.(foo: [{bar: 'baz'}]).errors
# => {}
Is this supported?
Oops, I forgot to say “Hello” :wave:
Tim Riley
@timriley
@twe4ked I’m not 100% sure off the top of my head, I’m sorry! I can try play around with some things but I’m at Kiwi Ruby this week so it might need to be next week.
Unrelated, wanted to share this:
Thanks @GustavoCaso and @dNitza for their work in dry-view 0.4.0, this is a really nice convenience upgrade :)
Gustavo Caso
@GustavoCaso
Fantastic @timriley always a pleasure to help
Gustavo Caso
@GustavoCaso
New post talking about functional programming with ruby
Oskar Szrajer
@gotar
@GustavoCaso error I think here:
add = -> (x,y) { x + y }
multiply = -> (x,y) { x + y }
multiply x*y?
Gustavo Caso
@GustavoCaso
Ohh 😮 you are right
Thanks @gotar for the tip
I will update it
Rafael George
@cored
hi
how can I change the default constructor of a dry-struct custom type
I want to compose an xml with different types however there is a case in which I need to swap one particular type definition with another in which case I was planning on using DI for such thing
I'm currently using a defined factory method however I'm passing an object to the factory and then the factory knows how to retrieve the data to populate each individual attribute of the struct
I think it would be easier for me to define a constructor that knows those details extract the data and then pass it around, so I don't have to leave that logic in the initialization stage at the factory method level
does this make sense?
I'm doing that currently
maybe I should be explicit about what I want from the top level client of this types
Rafael George
@cored
also is there a way to extend a predefined type ?
so I can swap it's attributes ?
Piotr Solnica
@solnic
@cored pls ask questions about usage / support on discourse.dry-rb.org
Bartosz Bonisławski
@bbonislawski

Hi, does someone have some good patterns for documenting input/output of operations from dry-transaction?
Atm I'm doing something like this:

    # Creates adjustment for order
    #
    # @param [Hash] input input for operation
    # @option input [Order] :order !!document this
    # @option input [Adjustable] :adjustable !!document this
    # @option input [Boolean] :included !!document this
    #
    # @return [Dry::Monads::Either::Right, Dry::Monads::Either::Left, #success?, #failure?, #value]
    #

but i'm not sure if it's clear enough for users. What do you think?

Bartosz Bonisławski
@bbonislawski
Screen Shot 2017-11-13 at 11.13.30.png
looks like that in yard
Andrew Kozin
@nepalez
Btw that’s what inspired dry-initializer syntax
Rafael George
@cored
@solnic will do, thanks
Andriy Tyurnikov
@andriytyurnikov
dry-structs are not supposed to be used for sophisticated nested scenarios ?
Nikita Shilnikov
@flash-gordon
@andriytyurnikov wdym by sophisticated? :)
Andriy Tyurnikov
@andriytyurnikov
@flash-gordon :D arrays of hashes of hashes of arrays of hashes ... or even number :)
Nikita Shilnikov
@flash-gordon
well, nested structures are supported, including arrays. Can't say I have such examples in my project though, this really depends on your case (performance requirements for instance)