These are chat archives for dry-rb/chat

21st
Jan 2016
Fran Worley
@fran-worley
Jan 21 2016 08:46
Oh and you might have to update the nested_removable! Method. Checkboxes probably pass in '1' not 'true'...
Luca Guidi
@jodosha
Jan 21 2016 08:46
Good morning all! I'm trying to follow the instructions in dry-data README, to understand how it works. Expect questions :D
Fran Worley
@fran-worley
Jan 21 2016 08:47
Good luck. Make sure your using the latest version (0.6.0) it was released last night.
Luca Guidi
@jodosha
Jan 21 2016 08:47
First one: there is a way to omit an attribute while initializing a Data::Struct subclass?
@fran-worley Thank you! Rubygems has still 0.5.1 https://rubygems.org/gems/dry-data
@fran-worley Is dry-validation at 0.6.0 I guess :)
Anyway, if I instantiate an entity User.new({}) I can't because of [User.new] :name is missing in Hash input (Dry::Data::StructError)
Fran Worley
@fran-worley
Jan 21 2016 08:49
@jodosha yes and I'd use the GitHub version. It contains error message improvements vital to getting grouped rules to work.
Luca Guidi
@jodosha
Jan 21 2016 08:50
@fran-worley Awesome! Thanks for letting me know! :)
Could that check be bypassed or it's a strict control by design?
(Just trying to understand how things work)
Fran Worley
@fran-worley
Jan 21 2016 08:51
What's your schema look like?
Luca Guidi
@jodosha
Jan 21 2016 08:51
@fran-worley Just one attr to try: attribute :name, Types::String
Fran Worley
@fran-worley
Jan 21 2016 08:52
in your schema? forgive me they usually look something like this:
class UserSchema < Dry::Validation::Schema
  key(:name) { |name| name.filled? }

  key(:email) { |email| email.filled? & email.format?(EMAIL_REGEX) }

  key(:age) { |age| age.none? | age.int? }

  key(:address) do |address|
   address.key(:street, &:filled?)
   address.key(:city, &:filled?)
   address.key(:zipcode, &:filled?)
  end
end
are you muddling a form object up with your schema?
Luca Guidi
@jodosha
Jan 21 2016 08:53
@fran-worley I'm following instructions from here: https://github.com/dryrb/dry-data#configuring-types-module
Fran Worley
@fran-worley
Jan 21 2016 08:54
Oh ok, your using dry-data sorry. I use dry-validation with Reform. Let me have a look.
Luca Guidi
@jodosha
Jan 21 2016 08:54
:)
Thank you
Just trying to understand if it's possible to instantiate an entity without passing data at all. Or passing only a subset of them.
I can imagine that instantiating an object for testing it, shouldn't require the entire set of correct data.
Fran Worley
@fran-worley
Jan 21 2016 08:56
@jodosha Strict Schema
thats what is happening its in the readme
Luca Guidi
@jodosha
Jan 21 2016 08:58
Yep, but even with Maybe it still complains :( with the same error
attribute :name, Types::Maybe::Coercible::String
Fran Worley
@fran-worley
Jan 21 2016 08:59
Yeah but how have you defined your class
Luca Guidi
@jodosha
Jan 21 2016 08:59
class User < Dry::Data::Struct
  attribute :name, Types::Maybe::Coercible::String
end

user = User.new({})
/Users/luca/.gem/ruby/2.3.0/bundler/gems/dry-data-860bca3ffd32/lib/dry/data/struct.rb:36:in `rescue in new': [User.new] :name is missing in Hash input (Dry::Data::StructError)
    from /Users/luca/.gem/ruby/2.3.0/bundler/gems/dry-data-860bca3ffd32/lib/dry/data/struct.rb:34:in `new'
    from test.rb:22:in `<main>'
Fran Worley
@fran-worley
Jan 21 2016 09:02
This might be one for @solnic I can't see a way to opt into strict when it's not defined as a hash and as I don't use it myself, any suggestions will probably just send you on a wild goose chase!
For now you might have to ensure that all keys are defined a refactor a bit later once you've got your answer
Luca Guidi
@jodosha
Jan 21 2016 09:04
I can easily see this problem: a dev wants to unit test User#foo which only requires to operate on #name. What I would do is:
class User < Dry::Data::Struct
  attribute :name, Types::Maybe::Coercible::String
  attribute :x,    Types::Maybe::Coercible::String
  attribute :y,    Types::Maybe::Coercible::String
  attribute :z,    Types::Maybe::Coercible::String

  def foo
    # do something only with name
  end
end

# Unit test
it "does something great" do
  user = User.new({name: 'L'}) # It raises an error
  user.foo
end
Fran Worley
@fran-worley
Jan 21 2016 09:05
dryrb/dry-data#19
Luca Guidi
@jodosha
Jan 21 2016 09:05
In other words, if I've got 10 attrs for User, it's tedious to pass all that 10 correct attrs to do a simple unit test like this above
Fran Worley
@fran-worley
Jan 21 2016 09:05
looks like someone got there first...
Luca Guidi
@jodosha
Jan 21 2016 09:06
Wonderful, I'll join that conversation.
@fran-worley Thank you very much!
Fran Worley
@fran-worley
Jan 21 2016 09:06
No worries :smile: Good luck
Piotr Solnica
@solnic
Jan 21 2016 11:16
structs and values are strict, it is the intention to have it like that, we can introduce a different type that can fill in missing attributes, it is being discussed already :)
Fran Worley
@fran-worley
Jan 21 2016 11:17
Yup I saw that, @jodosha has commented on the issue.
Luca Guidi
@jodosha
Jan 21 2016 11:17
yes :)
Piotr Solnica
@solnic
Jan 21 2016 11:17
I will be following up on that next week, this week is a dry-v week for me :D
Luca Guidi
@jodosha
Jan 21 2016 11:18
@solnic speaking of dry-v, do you think it's the case of reproduce the wiki examples in form of runnable tests? There are things that don't work as expected.
Fran Worley
@fran-worley
Jan 21 2016 11:20
@jodosha Its a public wiki :wink:
Luca Guidi
@jodosha
Jan 21 2016 11:21
@fran-worley yes, but it gets outdated very soon. Instead running tests guarantee that the behavior is the one described, because they would fail otherwise. :)
@fran-worley At least there are some high-level examples that new devs can have a look at if the wiki examples fail :)
Fran Worley
@fran-worley
Jan 21 2016 11:23
@jodosha Sorry that was cheeky of me. I see your point!
Luca Guidi
@jodosha
Jan 21 2016 11:23
@fran-worley No worries :)
Piotr Solnica
@solnic
Jan 21 2016 11:32
@jodosha sorry about the confusion with those error messages, it’s a big thing to improve and I’m gonna work on it for the next release
so far I focused mostly on the rule logic, error message compilation is a really really tricky thing
Luca Guidi
@jodosha
Jan 21 2016 11:33
@solnic gotcha :)
Piotr Solnica
@solnic
Jan 21 2016 11:33
I just had a thought that the simplest thing that will immediately fix lots of cases is to drop type-related hints whenever there are more rules
so ie value.int? & value.gt?(18) has two rules but we can drop the first one since the gt? has a higher priority in terms of error messages
but we only want to do that when the first one was not violated :)
all the information is in place, it’s just not smart yet
Luca Guidi
@jodosha
Jan 21 2016 11:35
@solnic To me it's not about the message, but about the logic rule logic that triggered that message.
Piotr Solnica
@solnic
Jan 21 2016 11:36
that logic is working correctly
we have all potential error messages generated, and call them “hints”, then we have actual error messages generated from violated rules
the trick is to merge them in a smart way
so that the feedback is minimal and valuable to the user
Luca Guidi
@jodosha
Jan 21 2016 11:39
@solnic How can a program tell if all the validations pass? schema.call({...}).empty?
Piotr Solnica
@solnic
Jan 21 2016 11:40
yes
although I plan to introduce something nicer
schema result is a huge object, it has violated rules, successful rules, error objects and can return string messages
Luca Guidi
@jodosha
Jan 21 2016 11:41
So to recap, the actual state of dry-v is: if a key fails for some reason, than the schema returns all the possible error messages / hints for that key. Right?
Piotr Solnica
@solnic
Jan 21 2016 11:42
yes
Luca Guidi
@jodosha
Jan 21 2016 11:43
I see. Do you plan to change it and return only the actual violations?
Piotr Solnica
@solnic
Jan 21 2016 11:43
no, hints are needed in many cases
we just need to be smart about choosing which ones are relevant
Luca Guidi
@jodosha
Jan 21 2016 11:43
choosing means filter?
Piotr Solnica
@solnic
Jan 21 2016 11:44
yes
reject hints that are no longer relevant
Luca Guidi
@jodosha
Jan 21 2016 11:44
cool
Piotr Solnica
@solnic
Jan 21 2016 11:44
I’m trying to come up with an example but a) I just woke up b) didn’t eat c) didn’t have coffee
:joy:
Luca Guidi
@jodosha
Jan 21 2016 11:44
So "age must be an integer" for "18" would disappear
Piotr Solnica
@solnic
Jan 21 2016 11:45
yes, definitely, it’s a nonsense to display this
Luca Guidi
@jodosha
Jan 21 2016 11:45
Sorry @solnic I didn't meant to violate some basic human rights like have a decent :coffee:
:wink2:
Piotr Solnica
@solnic
Jan 21 2016 11:45
no worries haha
lemme grab sth to eat and have that coffee though
I’ll be back in ~15 mins
Luca Guidi
@jodosha
Jan 21 2016 11:46
Take your time, leaving for lunch :spaghetti:
Piotr Solnica
@solnic
Jan 21 2016 11:46
your lunch is my breakfast, things that happen when you go to sleep at 3:40am :P
Piotr Solnica
@solnic
Jan 21 2016 12:29
btw, I should mention that I’ll introduce a neat integration between dry-validation and dry-data, it already uses form types for coercions but we can do more, ie we can use types with constraints to define validations. This will be a really cool thing to do as it will remove duplicated knowledge in some cases
Fran Worley
@fran-worley
Jan 21 2016 12:30
How would that work with optional(:attr, &:filled?) as we've already gone though, currently dry-data raises errors when attributes are missing
Piotr Solnica
@solnic
Jan 21 2016 12:31
ie we can do this:
module Types
  PostStatus = Strict::String.constrained(inclusion: %w(draft published deleted)).default(‘draft’)
end

class PostSchema < Dry::Validation::Schema::Form
  key(:status, Types::PostStatus)
end
notice that this can give you a way to encode a ton of domain knowledge within a tiny little reusable type object and use it in many places
if here we have not just constraints, but also the default value...
and since dry-data types are extendible, defining custom ones will be a very powerful weapon
ie the list of possible post statuses could be a dry-data enum, for better encapsulation
lots of possibilities here...
@fran-worley it raises in structs, structs shouldn’t be used with untrusted sources
ie I use structs for reading data from db or other source that I trust (there could be exceptions though)
Fran Worley
@fran-worley
Jan 21 2016 12:36
So in terms of coercing form params?
Piotr Solnica
@solnic
Jan 21 2016 12:36
the role of schema is to give you back clean data
and for optional keys, we can use a hash schema from dry-data that will fill in the missing pieces (not suported yet but on the todo list)
that’s exactly why I want to integrate dry-v with dry-data types
I’m 100% sure this will be a killer feature :D
Fran Worley
@fran-worley
Jan 21 2016 12:40
You should speak to apotonic. Get it into reform/ disposable.
I only use Virtus because it is integrated with Reform
Obviously as a side feature you integrating it with dry-validation. I'm just worried that the two might clash/ cause duplicate code if we aren't careful.
Piotr Solnica
@solnic
Jan 21 2016 12:43
@fran-worley we collaborate with Nick, he will replace virtus with dry-data soon
it’s our small dry-revolution
Fran Worley
@fran-worley
Jan 21 2016 12:44
@solnic Then I'm 100% on board. :smile: :sparkles:
My user form dry-v code went out to our production servers yesterday. So far so good :smirk:
Piotr Solnica
@solnic
Jan 21 2016 12:47
oh wow that went fast
@fran-worley are you using I18n?
Fran Worley
@fran-worley
Jan 21 2016 12:48
No luckily for me our entire user base are English.
Piotr Solnica
@solnic
Jan 21 2016 12:48
ah ok
I wanted to support error yamls w/o the need to pull in I18n
so I guess that turns out to be helpful
Fran Worley
@fran-worley
Jan 21 2016 12:49
@mrbongiolo uses I18n I think...
Piotr Solnica
@solnic
Jan 21 2016 12:49
ok good to know
I actually use I18n even when the site is in one language
Fran Worley
@fran-worley
Jan 21 2016 12:51
well I have scope everything under :en, but don't fully implement as the day we expand into new countries is a day when we will have a larger team that just 1 developer!! We had plans to add Welsh in due to our user base but I've just not had the time (or the language skill) to do it!
Piotr Solnica
@solnic
Jan 21 2016 13:03
@fran-worley built-in yaml-based error messages is compatible with I18n file structure to ease the transition
so you must have it scoped under a language
Fran Worley
@fran-worley
Jan 21 2016 13:04
@solnic yup thats what I've got
en:
  errors:
    lots_of_lovely_messages:
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 13:11
@solnic i18n made is easy to add custom messages in a Rails env
as I don't really need to say where my YML file is, I just put it under config/locales
Piotr Solnica
@solnic
Jan 21 2016 13:11
right
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 13:12
and I use 'pt-BR' as main language also in our app, so I had to copy the base dry-v YML file, or it just wouldn't find the keys
now I need to translate it :)
talking about translations, arew you thinking in providing basic translations (for the built-in predicates)?
Piotr Solnica
@solnic
Jan 21 2016 13:19
@mrbongiolo I don’t but I wouldn’t be against adding it to the main repo
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 13:21
That's more what I meant :joy: (when I got my translations done I'll send a PR xD
Piotr Solnica
@solnic
Jan 21 2016 13:24
otoh lots of yams will increase the size of the gem
so maybe we should discuss this first
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 13:25
no problem at all
Fran Worley
@fran-worley
Jan 21 2016 13:26
You could always include them in the wiki if you didn't want them in the repo itself.
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 13:27
a dry-v-i18n that could require 'i18n' and set a base config to use it, and have some translations. Or this would be a burden?
Fran Worley
@fran-worley
Jan 21 2016 13:28
I could add a french one if you need it.
Piotr Solnica
@solnic
Jan 21 2016 13:28
it could be useful in apps that don’t handle I18n for you
ie in rails it Just Works
but in sinatra you’re on your own
etc
setting I18n is actually uber-confusing
so a dry-v-i18n helper lib would be valuable, I think
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 13:30
I like to be able to add it to my gemfile and mostly get it working
if I need the translations, usually I always do, since per default Rails just ships with EN
Piotr Solnica
@solnic
Jan 21 2016 13:52
how about having this:
class UserSchema < Dry::Validation::Schema
  required(:email)
  maybe(:age, type: :int)
end
translates to key(:email) { |value| value.filled? } and key(:age) { |age| age.none? | age.int? }
Fran Worley
@fran-worley
Jan 21 2016 13:56
can you also do? required(:email, type: :str)
Piotr Solnica
@solnic
Jan 21 2016 13:56
yes
not needed in forms, though
Fran Worley
@fran-worley
Jan 21 2016 13:56
Yeah I know that I just wanted to check.
Piotr Solnica
@solnic
Jan 21 2016 13:56
I’m trying to come up with macros for common use cases
Fran Worley
@fran-worley
Jan 21 2016 13:57
any scope for required(:name, :email, :telephone)
Piotr Solnica
@solnic
Jan 21 2016 13:57
yeah, or even required(:name, age: :int)
we can go nuts, really
Fran Worley
@fran-worley
Jan 21 2016 13:57
nice. Also any way to specify optional keys?
maybe is obviously for optional value. But you could have case where the key might not exist
Piotr Solnica
@solnic
Jan 21 2016 13:58
yeah, I thought about that
people need to easily get the difference
how about maybe(:address, type: :hash, key: :optional) but I dunno
for “conitionals” we can also have things like on(:login).required(:email)
seriously, lots of posibilities
can’t stop thinking about this now :joy:
optional(:address).maybe(type: :hash)
Fran Worley
@fran-worley
Jan 21 2016 14:04
I like the last one. Could you also do on(login: :true).required(:email) and then further examples like on(category: :filled).required(:group_name)
Piotr Solnica
@solnic
Jan 21 2016 14:05
:category being?
Fran Worley
@fran-worley
Jan 21 2016 14:05
I dunno anything was trying to come up with a non Bool example
but essentially could you pass the key and validation into on?
Piotr Solnica
@solnic
Jan 21 2016 14:08
@fran-worley yes, that was my idea, any predicate id could be used
it would simply expand the options to rule definitions
so we can be flexible there
Fran Worley
@fran-worley
Jan 21 2016 14:09
optional(:address).maybe(type: :hash)
key(:address).maybe(type: :hash)
key(:address).required(type: :hash)
key(:name, :email).required
key(:age).required(type: :int)
Piotr Solnica
@solnic
Jan 21 2016 14:09
oh uh yeah, that is a nice idea
better than mine
thanks!
Fran Worley
@fran-worley
Jan 21 2016 14:10
might avoid the confusion of optional vs key all together
Piotr Solnica
@solnic
Jan 21 2016 14:10
exactly
:clap: :)
Fran Worley
@fran-worley
Jan 21 2016 14:11
Well good luck making that work. I'd love to play about with it!
key(:login).required(type: :bool).on(:true) { key(:email).required }
accepting a block would make this sort of thing possible:
Piotr Solnica
@solnic
Jan 21 2016 14:13
that’s lovely
I’ll mess about it
Fran Worley
@fran-worley
Jan 21 2016 14:14
key(:login).required(type: :bool).on(:true) do
 key(:email).required
 key(:password).confirmation
end
Piotr Solnica
@solnic
Jan 21 2016 14:15
this would be more complicated to implement but it’s just a dsl, so as long we can generate valid rule ast from it things will work correctly
Fran Worley
@fran-worley
Jan 21 2016 14:15
Yeah it would transform your high level rules
Piotr Solnica
@solnic
Jan 21 2016 14:15
but maybe I’m wrong, maybe it’s not gonna be that hard, we’ll see
defo worth the effort
Fran Worley
@fran-worley
Jan 21 2016 14:18
class BarcodeSchema < Dry::Validation::Schema
  key(:barcode) do |barcode|
    barcode.none? | barcode.filled?
  end

  key(:job_number) do |job_number|
    job_number.none? | job_number.int?
  end

  key(:sample_number) do |sample_number|
    sample_number.none? | sample_number.int?
  end

  rule(:barcode_only) do
    rule(:barcode).filled? & (rule(:job_number).none? & rule(:sample_number).none?)
  end
end
becomes
key(:job_number).maybe(type: :int)
key(:sample_number).maybe(type: :int)
key(:barcode).maybe.on(:filled) do
  key(:job_number, &:none?)
  key(:sample_number, &:none?)
end
Piotr Solnica
@solnic
Jan 21 2016 14:19
that would be awesome
let’s shoot for having that for 1.0.0!
Fran Worley
@fran-worley
Jan 21 2016 14:20
I think if the DSL got that clear and easy this library would become a serious contender even among less able/ patient developers.
Piotr Solnica
@solnic
Jan 21 2016 14:20
well, that is the goal
I’m just crazy focused on solving fundamental problems first, before I get to fancy DSLs
see ROM as a good example as well
Fran Worley
@fran-worley
Jan 21 2016 14:23
Yup. no point in having a fancy DSL if the backend is full of bugs and doesn't work!
Piotr Solnica
@solnic
Jan 21 2016 14:23
exactly
Luca Guidi
@jodosha
Jan 21 2016 14:26
@fran-worley That is an amazing API!
Piotr Solnica
@solnic
Jan 21 2016 14:26
:+1:
there’s just one thing where this API won’t work - complex predicate composition with disjunctions, xors, implications etc.
but then again, you can just use blocks with predicate operators in such cases
real world usage will tell us more
what’s important here is that we will always end up with a set of composed rules, so it will remain super fast, always
validation options will never be processed at runtime
Fran Worley
@fran-worley
Jan 21 2016 14:29
Exactly. and more importantly, its use is entirely optional so if people need to do advanced complex things they can just write it long hand.
Piotr Solnica
@solnic
Jan 21 2016 14:30
right, omg this is exciting :D
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 14:32
It is working already???? :D :joy:
Piotr Solnica
@solnic
Jan 21 2016 14:32
we can also do Symbol#to_proc automatically so key(:job_number, :none?)
Fran Worley
@fran-worley
Jan 21 2016 14:32
no the idea is exciting. @solnic is amazing but not god!
Piotr Solnica
@solnic
Jan 21 2016 14:33
challenge accepted, gimme a minute :joy:
Luca Guidi
@jodosha
Jan 21 2016 14:33
a minute to release?
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 14:33
go
60
59
Piotr Solnica
@solnic
Jan 21 2016 14:33
haha
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 14:33
58
Piotr Solnica
@solnic
Jan 21 2016 14:33
srsly though, I’ll experiment with that soon and report back
error compilation comes first
Fran Worley
@fran-worley
Jan 21 2016 14:34
Ok well if you need me to sling some ideas through my examples let me know. You'll be pleased to know that I've moved on from user forms and am now branching out into dates and other such exciting areas.
So my examples might get a little more interesting
Piotr Solnica
@solnic
Jan 21 2016 14:35
that’s great
dryrb/dry-validation#53 <= I opened this issue for an async discussion
Fran Worley
@fran-worley
Jan 21 2016 14:43
I've stuck the other examples in there just so they don't get lost.
Andy Holland
@AMHOL
Jan 21 2016 14:49
I like how the DSL is kind of similar to Sequel
Wonder whether the DSL could be a separate gem? That way people could create their own DSL to generate the AST and plug it in
Acronyms FTW IMO TBF
Luca Guidi
@jodosha
Jan 21 2016 14:53
@AMHOL Please stopping to create new gems :pray:
For me, the more gem we add to our systems/applications, the more work there is for bundler/rubygems.
@AMHOL But I will still :green_heart: your work and DRY ;)
Andy Holland
@AMHOL
Jan 21 2016 14:56
:joy: it's @solnic not me, I'm only responsible for configuration and container xD
And thanks :) Likewise with Lotus
Luca Guidi
@jodosha
Jan 21 2016 14:58
s/solnic/AMHOL/g :D
Andy Holland
@AMHOL
Jan 21 2016 14:58
haha
Luca Guidi
@jodosha
Jan 21 2016 14:58
ops
quite tired I swapped the args :D
Andy Holland
@AMHOL
Jan 21 2016 15:01
Seriously though, I'd rather have a gemfile with 150 small gems that use DI and encapsulate a small task well than 1 gem prefixed with active or action
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 15:02
let the guys at Bundler handle it :joy:
Andy Holland
@AMHOL
Jan 21 2016 15:03
haha
:+1:
Piotr Solnica
@solnic
Jan 21 2016 15:15
I’d prefer to focus on one DSL to be honest that ships with the main gem and make it clear it’s just a front-end for dry-logic so feel free to come up with better DSLs
Andy Holland
@AMHOL
Jan 21 2016 15:17
Fair do :)
Makes sense
Piotr Solnica
@solnic
Jan 21 2016 15:18
I’m also OK with lots of small gems but not the nodejs style :P
Andy Holland
@AMHOL
Jan 21 2016 15:25
27.000 gems created in 2014, that's a lot :trollface:
Anyone open the JS console on that page BTW?
       ∞∞∞∞              ∞∞∞∞   
     ∞∞∞∞∞∞∞∞          ∞∞∞∞∞∞∞∞          Hello, you code inspecting scoundrel, you. 
   ∞∞∞      ∞∞∞      ∞∞∞      ∞∞∞   
 ∞∞∞          ∞∞∞  ∞∞∞          ∞∞∞      Like our site? Think you can do better? 
∞∞∞            ∞∞∞∞∞∞            ∞∞∞   
∞∞∞            ∞∞∞∞∞∞            ∞∞∞     Let's talk. 
 ∞∞∞          ∞∞∞  ∞∞∞          ∞∞∞   
   ∞∞∞      ∞∞∞      ∞∞∞      ∞∞∞        https://infinum.co/careers 
     ∞∞∞∞∞∞∞∞          ∞∞∞∞∞∞∞∞   
       ∞∞∞∞              ∞∞∞∞
lol
Fran Worley
@fran-worley
Jan 21 2016 15:26
An the title changes when you change tabs
Andy Holland
@AMHOL
Jan 21 2016 15:27
haha didn't notice that
That's cool
Fran Worley
@fran-worley
Jan 21 2016 15:28
It seems to be timed as well so it reverts back.
Andy Holland
@AMHOL
Jan 21 2016 15:33
:p
Fran Worley
@fran-worley
Jan 21 2016 15:34
Very cool. I'd love to have the time to play around with things like that!
Andy Holland
@AMHOL
Jan 21 2016 15:34
Yeah, surprised they're hiring :laughing:
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:13
@solnic would dry-pipeline be "right" to do something like this for a request: authenticate > authorize > coerce > validate > operate > respond
Piotr Solnica
@solnic
Jan 21 2016 16:14
@mrbongiolo see icelab’s call_sheet
dry-pipeline is very alpha and I won’t be doing anything with it anytime soon, my idea was to extract it from rom and use in rom, which didn’t happen yet
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:17
Ah ok
but it would be experimental also, nothing to use right now
Piotr Solnica
@solnic
Jan 21 2016 16:18
Nick is trying out call_sheet for reform
so you may want to check it out yourself
ie for me call_sheet standalone is all I need
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:19
I'll look at it. Thanks!
Piotr Solnica
@solnic
Jan 21 2016 16:19
I haven’t tried it yet but it’s based on my transflow project that worked very well, and call_sheet is superior to transflow in terms of the API so yeah, there’s that
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:19
uhm, a true I saw transflow also, maybe I was thinking about it when said dry-pipeline
Piotr Solnica
@solnic
Jan 21 2016 16:19
could be it
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:20
the thing is to define the steps to be done on the request
Piotr Solnica
@solnic
Jan 21 2016 16:20
in general once you can easily compose small processing steps into a pipeline things become simple&nice
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:20
Yeah
Piotr Solnica
@solnic
Jan 21 2016 16:20
no inheritance, no configuration, no mutable state, just a processing pipeline where data is flowing through the system
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:20
Yup, that's what I was thinking
Piotr Solnica
@solnic
Jan 21 2016 16:21
it also has pub/sub baked in, which can be very powerful for complex scenarios
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:21
and at each step you can stop and go to another "road" if something is not right
Piotr Solnica
@solnic
Jan 21 2016 16:21
and explicit error handling via either monad is delicious
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:22
I need to see if I can try this out
Piotr Solnica
@solnic
Jan 21 2016 16:22
we also built a nice rubyish result-matching API
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:22
but a bit busy those days
result-matching?
Piotr Solnica
@solnic
Jan 21 2016 16:22
initially in rodakase, then Tim from icelab ported it to a standalone gem
yeah, lemme show you
it’s a really beautiful way of handling various results
I gotta adopt call_sheet in rodakase finally
eventually rodakase will become a shell with a bunch of libs under the hood
so it’ll be an omakase :P but with an actual selection of curated dishes
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:27
Oh nice, that's what I was looking for, or something like it
hauahuahuahuahuha
Piotr Solnica
@solnic
Jan 21 2016 16:27
rails is a gigantic hamburger, I want tapas
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:28
that's true, but rails is good in being a gigantic hamburguer
but it isn't for everyone
Piotr Solnica
@solnic
Jan 21 2016 16:28
try to eat good, gigantic hamburgers every day ;)
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 16:29
You can always eat in parts. But I know, right now I'm on a "diet" hahaha
atleast trying, since I still got to handle hamburgers everyday
AFK for lunch, talking bout tapas n burgers made me hungry :D
Piotr Solnica
@solnic
Jan 21 2016 16:31
lol same here
:meat_on_bone: :spaghetti: :hamburger:
Piotr Solnica
@solnic
Jan 21 2016 17:54
hey y’all, any thoughts on renaming dry-data to dry-types?
see this issue dryrb/dry-data#21
Andrew Kozin
@nepalez
Jan 21 2016 18:40
at first I've been perplexed about the name dry-data, and thought of it as types too. So I'd bet for dry-types
Piotr Solnica
@solnic
Jan 21 2016 18:43
makes sense
I would only dislike Types::Type class :(
oh I know, let’s call it Types::Base :joy:
Andrew Kozin
@nepalez
Jan 21 2016 18:45
Types::Object would be more idiomatic. Or, maybe, Types::ActiveRecord (the old dream of ruby community)
Andy Holland
@AMHOL
Jan 21 2016 18:46
I think dry-data flows better
But not fussy either way
@solnic could go one step further and just call it active-types :)
class MyType < ActiveType::Base
  has_indifferent_access!
  infer_types_from_describe_table!
  infer_coercions_from_describe_table!
end
Piotr Solnica
@solnic
Jan 21 2016 19:02
:joy:
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:21
+1 for ActiveType::Base o/
I couldn’t help myself
maybe + required are done already :)
as I suspected, on will be more complicated but…totally doable
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:25
Oh nice!!
@fran-worley keep on bringing new DSL, @solnic is a machine!!
BTW, a bit off-topic how you decide what is unit test, and what's integration?
Piotr Solnica
@solnic
Jan 21 2016 19:26
@mrbongiolo depends on my mood :joy:
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:28
hahahahaha
I'll try that one too
but probably they will all end up as unitegration tests..
Piotr Solnica
@solnic
Jan 21 2016 19:28
my definition of a unit test is essentially this: it’s any test that exercises a single object, with the assumption that its potential collaborators are part of the private API, so I don’t always mock them, in fact, I avoid mocking in general
well, honestly, over time I realized one simple thing
there are only two categories of tests:
1) tests that help
2) tests that don’t help
I use tests to help me in the api design, implementation, and maintainance process
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:30
that's a good categorization
Piotr Solnica
@solnic
Jan 21 2016 19:31
any test which turns out to be a PITA to maintain, that causes making changes in a code base difficult, or slows down development in general, is a bad test that does not help, it does the opposite
so, I pretty much do not care about unit vs integration vs whatever
I’m not gonna spend time thinking whether or not my test is A True Unit Test™ or not
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:32
I see
Piotr Solnica
@solnic
Jan 21 2016 19:32
I’m typically discovering lower level objects over time, and slowly progress from many integration tests to smaller tests (closer to unit test definition)
I see it as a very long process, in general
it takes many iterations until you clearly see the interfaces you want to have, and what kind of responsibilites individual objects have
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:33
true, usually a higher lvl integration test is easier to start with
Piotr Solnica
@solnic
Jan 21 2016 19:33
oh and I’m a top-down fan, mostly
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:34
since you don't really know how everything will work out
Piotr Solnica
@solnic
Jan 21 2016 19:34
yep pretty much
Ralf Schmitz Bongiolo
@mrbongiolo
Jan 21 2016 19:34
I send you THIS and want back THAT.
it's nice to see how my tests "improved" on the app, there are still some tests there from the first iterations
Piotr Solnica
@solnic
Jan 21 2016 19:36
app’s tests are the worst, esp in rails