Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-auto_inject
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-container
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-matcher
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-monads
  • Feb 26 16:22
    karpinovsky starred dry-rb/dry-initializer
  • Feb 26 16:21
    karpinovsky starred dry-rb/dry-system
  • Feb 26 16:21
    karpinovsky starred dry-rb/dry-types
  • Feb 26 14:03
    solnic commented #143
  • Feb 26 13:19
    davydovanton commented #143
  • Feb 26 13:04
    solnic commented #143
  • Feb 25 23:58
    davydovanton review_requested #143
  • Feb 25 23:56
    davydovanton synchronize #143
  • Feb 25 23:56

    davydovanton on strategies-fail

    Fix error with mutation of froz… (compare)

  • Feb 25 22:40
    davydovanton review_requested #143
  • Feb 25 22:40
    davydovanton review_requested #143
  • Feb 25 22:40
    davydovanton assigned #143
  • Feb 25 22:40
    davydovanton opened #143
  • Feb 25 22:40
    davydovanton review_requested #143
  • Feb 25 22:40
    davydovanton labeled #143
  • Feb 25 22:34

    davydovanton on strategies-fail

    Fix error with mutation of froz… (compare)

Piotr Solnica
@solnic
this stuff is crazy flexible so we can either do this, or make it configurable, or raise an error, dunno :)
Daniel Gollahon
@dgollahon
yeah. i would expect you could inadvertently get contradictory rules with an and. but maybe that's just your fault and ohwell :P
might be less surprising to raise an error. but i don't know, there may be a reasonable alternative.
Juanma Cervera
@jmcervera
Hi, A question about testing.
I'm developing a dry-system project, where my functional classes are registered in the app container.
I instantiate the objects in specs through the container as I do in the app.
How should I instantiate the subject object when I want to mock some of the dependencies,
with mocks or lambda functions to avoid for example go to the database through a repository?
Should I instantiate the object with new and not use the DI?
Is there a way to mock only some of the dependencies and get DI work for the others?
just use .new + kwargs (it’s the default constructor type in autoinject)
Juanma Cervera
@jmcervera
@solnic Thanks :smile:
Sergey Novikov
@droptheplot
Hi there! Looks like a have a similar questions but don't know where to start. I'm using containers in my application and currently calling them like container['somenamespace.somecontainer'].call within my specs. The questions is how to use auto_inject inside specs?
Jānis Miezītis
@janjiss
Hey folks, I created a gem main purpose of which is to map data from unformated hash (In my case from CSV rows) and turn it to some usable domain objects and to add dry-types as a basis for type checks. https://github.com/janjiss/massager
Piotr Solnica
@solnic
@janjiss oh cool I’ll check it out. thanks for sharing
Jānis Miezītis
@janjiss
@solnic On which time zone are you? Are you in Krakow or in US atm?
Just curiosity - Since your work hours look more like US, but under profile there is Krakow :D
Piotr Solnica
@solnic
@janjiss US atm
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic Is it allowed to have multiple predicates( My::Predicates ) statements in the config block auf a schema?
Piotr Solnica
@solnic
@cdennl it’s config.predicates = YourPredicates since 0.9.x
or 0.8.0 O_o can’t remember exactly
oh and no, it doesn’t support more than one predicate module, at least not yet
Christopher Dennl-Ortega Arrieta
@cdennl
it is predicates(...) in 0.9+ :) and thank you I saw that only one is working at the moment
Piotr Solnica
@solnic
Ah right, I kept it eventually. Sorry, too much on my mind :)
Michał Gutowski
@CucumisSativus
Hey guys, in dry-types is there built-in way to make your own type to behave like a Maybe type?
Nikita Shilnikov
@flash-gordon
@CucumisSativus wdym by saying "behave like"?
Michał Gutowski
@CucumisSativus
@flash-gordon that it will return None if nothing is there and returns object if needed
s/needed/present
Nikita Shilnikov
@flash-gordon
yeah, but it will be wrapped with Some. dry-t has optional types ootb, so you can have your value or nil, wo wrapping it with a monadic interface
Krzysztof Wawer
@wafcio
I am reading dry-validation docs and sometimes I see require(:name).filled and sometimes I see require(:name).value(:filled) what is difference between these two syntax ?
Krzysztof Wawer
@wafcio
moreover sometimes you are using filled and filled?
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic Why do I get a exception on this?
rule( check_comment_on_reject: [ :is_accepted, :comment ] ) do |is_accepted, comment|
          is_accepted.false? > comment.filled?
        end
in `block (3 levels) in <class:CreateSubmissionReview>': undefined method `then' for false:FalseClass (NoMethodError)
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/value.rb:95:in `instance_exec'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/value.rb:95:in `rule'
Christopher Dennl-Ortega Arrieta
@cdennl
required( :is_accepted ).filled( :bool? )
optional( :comment ).maybe( :str?, size?: (5..2000) )
I also get the same eror on this one:
required( :user ).filled
required( :challenge ).filled( :is_opened?, :is_in_review_time_frame? )
required( :participation ).filled( :has_video_submission? )

rule( check_self_review: [ :user, :challenge, :participation ] ) do |user, challenge, participation|
          ( !user.is_host?( challenge ) & user.is_participant?( challenge ) ).then( user.does_no_self_review?( participation ) )
        end
Christopher Dennl-Ortega Arrieta
@cdennl
I'd be glad for feedback, but thanks to predicate logic i can workaround with this identity: a > b == !a | b :)
mh unfortunately the workaround doesnt work either
/usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/value.rb:98:in `rule': undefined method `with' for true:TrueClass (NoMethodError)
    from /var/www/gamebet/app/concepts/submission_review/operation/create.rb:49:in `block (2 levels) in <class:Create>'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/class_interface.rb:46:in `instance_exec'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema/class_interface.rb:46:in `define'
Michał Gutowski
@CucumisSativus
@flash-gordon oh crap it was much easier than i thought
Nikita Shilnikov
@flash-gordon
:grin:
Piotr Solnica
@solnic
@cdennl hmm could you report an issue with a repro script?
Piotr Solnica
@solnic
@wafcio we shouldn’t show required(:name).value(:filled?) as required(:name).filled is a shorter equivalent, where did you see it exactly?
Kimmo Lehto
@kke
great. "dry-monads-0.2.0 requires ruby version >= 2.1.0, which is incompatible with the..."
Kimmo Lehto
@kke
every week our installs break because of dry dependencies, grr!
John Backus
@backus
@kke Do you have a question or are you just venting? It shouldn't break your build if you lock it to your minor version. The gem is not 1.0 so there aren't any guarantees
Kimmo Lehto
@kke
mostly venting.
John Backus
@backus
Alrighty. I can't speak for the dry-rb organization since I'm not a core contributor but I'd recommend not venting in gitter/in a public forum with contributors. As far as I know everyone contributing to dry-rb things is doing so for free.
Kimmo Lehto
@kke
yes and the gems are quite nice.
John Backus
@backus
Glad you like them :smile:
Christopher Dennl-Ortega Arrieta
@cdennl

@solnic I am trying to make a little standalone script but when i try to execute this:

require 'dry/validation/schema'

schema = Dry::Validation.Schema do
  required( :is_accepted ).filled( :bool? )
  optional( :comment ).maybe( :str?, size?: (5..2000) )

  rule( check_comment_on_reject: [ :is_accepted, :comment ] ) do |is_accepted, comment|
    is_accepted.false? > comment.filled?
  end
end

schema.( is_accepted: false, comment: nil ).inspect

I get this error:

christopher@debian-vm:~$ ruby dry-v.rb 
/usr/local/rvm/gems/ruby-2.3.1/gems/dry-logic-0.3.0/lib/dry/logic/predicate.rb:19:in `<class:Predicate>': undefined method `Equalizer' for Dry:Module (NoMethodError)
Did you mean?  equal?
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-logic-0.3.0/lib/dry/logic/predicate.rb:11:in `<module:Logic>'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-logic-0.3.0/lib/dry/logic/predicate.rb:2:in `<module:Dry>'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-logic-0.3.0/lib/dry/logic/predicate.rb:1:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-logic-0.3.0/lib/dry/logic/predicate_set.rb:1:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-logic-0.3.0/lib/dry/logic/predicates.rb:5:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /usr/local/rvm/gems/ruby-2.3.1/gems/dry-validation-0.9.5/lib/dry/validation/schema.rb:1:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
    from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
    from dry-v.rb:1:in `<main>'
Nikita Shilnikov
@flash-gordon
@kke we had some issues with 2.0 support regarding required kw arguments and a few others. Since it's now EOL, we started to remove it from Travis configs, therefore we can't guarantee everything will work on 2.0. It's better to get a meaningful error about version incompatibility, than have a weird SyntaxError exception
also, imo, it's not a good idea to have relaxed dependencies when you're using ruby 2.0, I have Gemfile.lock in all of my commercial projects, this way I can be sure I'll have the same environment on every deploy
and, after all, upgrading to a fresher ruby version shouldn't be hard, it's pretty stable nowadays
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic solved it doesn't seem to be a dry-v error
@solnic seems to be reform ill investigate further
Christopher Dennl-Ortega Arrieta
@cdennl
@solnic investigation yielded (like so often): own dumbness, I used ! (not), ... which is wrong :D
Michał Gutowski
@CucumisSativus

Hey guys i'm pretty fresh to dry monads and i've got a question about fmap. Lets suppose i've got code like this:

      validate.fmap do |valid_attributes|
        form.save.fmap do |valid_postcard|
          mailer.send_postcard(to_email: email, postcard: valid_postcard).deliver_now
          valid_postcard
        end
      end

both validate and form.save returns Left or Right. Is there a way to chain both those functions so they return Left or Right at the end of the chain? Now, when form.save returns Left at the end of the day I have Right(Left(errors)).
Am I doing something wrong? Is there a way to make it chainable?