Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 18:39

    flash-gordon on master

    Update changelog.yml (compare)

  • 18:25

    flash-gordon on alias-constructors

    (compare)

  • 18:25

    flash-gordon on master

    Add aliases for .constructor T… Merge pull request #383 from dr… (compare)

  • 18:25
    flash-gordon closed #383
  • 18:15
    dry-bot commented #383
  • 18:13
    flash-gordon opened #383
  • 18:11

    flash-gordon on alias-constructors

    Add aliases for .constructor T… (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 17:04

    dry-bot on master

    [devtools] sync configs (compare)

  • 09:55

    dry-bot on master

    [devtools] sync configs (compare)

  • 09:55

    dry-bot on master

    [devtools] sync configs (compare)

  • 09:55

    dry-bot on master

    [devtools] sync configs (compare)

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?

Nikita Shilnikov
@flash-gordon
@CucumisSativus value combining will be probably added in future, but right now you can just do validate.bind instead of validate.fmap, this will give the result you want
Michał Gutowski
@CucumisSativus
@flash-gordon yeah that's exactly what i was looking for. Thanks a lot!
Nikita Shilnikov
@flash-gordon
np :)
Michał Gutowski
@CucumisSativus
@flash-gordon would you mind if I put your name (site?) in special thanks in my blogpost?
Nikita Shilnikov
@flash-gordon
@CucumisSativus I would not :) I don't have a site, you can add a gh link or twitter if you wish https://twitter.com/NikitaShilnikov
oh, well, that preview again
Michał Gutowski
@CucumisSativus
i'll let you know once I publish it :)
Jānis Miezītis
@janjiss
Hey folks, how would one deep copy Dry Container instance? :)
I want inherited object to have container with same values:
    def inherited(subclass)
      subclass.instance_variable_set(:"@container", Marshal.load(Marshal.dump(_container)))
    end
It works this way, just woundering if there is a better way to do it
Jānis Miezītis
@janjiss
Well, I think this is better:
    def inherited(subclass)
      subclass_container = Dry::Container.new
      _container.each_key do |k|
        subclass_container.register(k, _container.resolve(k).clone)
      end
      subclass.instance_variable_set(:"@container", subclass_container)
    end
Don Morrison
@elskwid
@janjiss my experience with Marshal.load and Marhsal.dump has led me to this wisdom: don’t use them. I’ve seen the formats change on Ruby point releases. Not fun. That second one is better even if just for the ability to withstand an upgrade. :smile:
Jānis Miezītis
@janjiss
@elskwid Yeah, I can se how that can become a problem
Piotr Solnica
@solnic
Yes. I wouldn't rely on marshaling
Mikhail Slyusarev
@mikhailvs
do you guys actually use dry-rb in production?
John Backus
@backus
We do
dry-validation and dry-types
works great
Mikhail Slyusarev
@mikhailvs
hmm... i've refactored a pretty big app to use dry-containers/validation/transactions but i'm feeling a bit reluctant to pull the trigger on deploying it
either way. it seems like a very cool collection of libraries
John Backus
@backus
If you have good tests I think you should be safe although I can't vouch for containers and transactions
just lock yourself to a strict version
Mikhail Slyusarev
@mikhailvs
yeah... for sure
Piotr Solnica
@solnic
@mikhailvs what’s your concern?