RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
devil_tux has quit [Quit: leaving]
_whitelogger has joined #crystal-lang
relyks has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <schoening> Id like to add a big html warning block at the top of the crystal API pages when viewing an outdated version of the API, which has happened to me when getting there via a google search result. What repo do I need to fork?
akaiiro has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
akaiiro has quit [Remote host closed the connection]
<FromGitter> <dscottboggs_gitlab> The documentation is automatically generated, and old versions may not be changeable retroactively. I'm not sure how they have it set up.
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
relyks has quit [Quit: relyks]
relyks has joined #crystal-lang
<FromGitter> <schoening> That's why I was thinking doing a check via JavaScript is gonna be the simplest solution. Check the version number of the page and do an ajax request on what the current crystal version is. Then it does not matter if the pages are static. If possible we could do a one time re-build of all the pages, OR just add it to the newest ones and hope the old ones will get less and less visible by Google. Today google
<FromGitter> ... send me to version 0.24.1, for example.
<FromGitter> <schoening> Something like this you know: ⏎ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/unwatch ⏎ But instead saying "You are reading an outdated version of the API" and a link to the most current.
relyks has quit [Quit: relyks]
relyks has joined #crystal-lang
relyks has quit [Remote host closed the connection]
devil_tux has joined #crystal-lang
rohitpaulk has joined #crystal-lang
t0nyandre has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter> <swinSpo> Hi, can someone explain the "?" syntax to me? For types it means that the value can be nilable, but what about methods? I saw methods like "get?" which have this symbol
<FromGitter> <ljuti> @swinSpo methods with “?” in their name usually follow the convention that the method will return a boolean
<FromGitter> <swinSpo> oh really? I thought that they return the value or nil
<FromGitter> <swinSpo> for example get(key) would return a value or raise an exception, while get? would return the value or nil
<FromGitter> <ljuti> Oh, right
<FromGitter> <ljuti> Yes, sometimes it’s used that way, too
<FromGitter> <ljuti> But that’s just a convention AFAIK
rohitpaulk has quit [Ping timeout: 276 seconds]
<FromGitter> <swinSpo> Alright thanks
<FromGitter> <ljuti> Methods return the value of their last expression and as the conditional returns false, no expression is executed
rohitpaulk has joined #crystal-lang
<FromGitter> <swinSpo> wow what about this
<FromGitter> <swinSpo> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be93960fee6703aaf59f1a7]
<FromGitter> <swinSpo> this is super confusing
<FromGitter> <ljuti> What’s the confusing bit for you?
devil_tux has quit [Ping timeout: 244 seconds]
<FromGitter> <swinSpo> Ah i forgot a part
<FromGitter> <swinSpo> So how does that work? like this? super() + 10?
<FromGitter> <ljuti> `super` calls the method of superclass, so in this case `FighterAbility`which calls the instance variable’s method
<FromGitter> <swinSpo> Alright, I thought there was some magic there for a second
<FromGitter> <swinSpo> like that it calls the super method with 10 as the argument
<FromGitter> <swinSpo> I have seen some people use
<FromGitter> <swinSpo> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be93c0e7a36913a9a2cc2d2]
<FromGitter> <swinSpo> is there a reason for that?
<FromGitter> <ljuti> No, it calls `super` and then calls method `+` with `10` as argument on the return value of `super`
<FromGitter> <ljuti> I guess that’s just the matter of preference
<FromGitter> <swinSpo> [] of Test this could be a hash too?
<FromGitter> <ljuti> ```a = {} of String => String```
<FromGitter> <swinSpo> Definitely not a fan of tat
<FromGitter> <swinSpo> whats wrong with
<FromGitter> <swinSpo> ```b = Hash(String, String).new```
<FromGitter> <ljuti> Again, a matter of preference :) I usually use the latter definition for empty hashes
<FromGitter> <Timbus> That syntax can't initialize it with anything, either
<FromGitter> <Timbus> `thing = [1,2,3,4] of Float32`
<FromGitter> <Prutheus> I have 2 classes, one called WORK::FINDER and the other HOME::FINDER ….. however, somewhere in my code i wanna have a variable called finder which gets the class object as value depending of a flag …. so how to declare my variable finder before the switch statement (for the flag) so it can get both classes as values?
<FromGitter> <Prutheus> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be9416862866f7473874f8a]
<FromGitter> <skaragianis> True @Timbus
<FromGitter> <ljuti> (parentheses are optional)
<FromGitter> <Prutheus> thanks
<FromGitter> <Prutheus> i am such an idiot xD
ua_ has quit [Ping timeout: 276 seconds]
gangstacat has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter> <fusillicode_twitter> Sorry guys is there a way to work around this error
<FromGitter> <fusillicode_twitter> https://play.crystal-lang.org/#/r/5huv
<FromGitter> <fusillicode_twitter> Basically I'm trying to use a general module that defines how objects are initialized and use it both directly and indirectly through another module
<FromGitter> <fusillicode_twitter> Unfortunately I don't get an handle to the initialize method
<FromGitter> <j8r> initialize can't be in a module, that's particular to classes/structs. This method allocates
<FromGitter> <j8r> the only way is to use a macro, or you can have a `def initialize` and include a module with a `def self.new`
<FromGitter> <fusillicode_twitter> @j8r ok that makes sense but I don't get the alternative of `def self.new`
<FromGitter> <j8r> the fact is you need initialize in classes, it creates a `def self.new` with inside a GC.allocate or something like that. `def self.new` as is is like like all another class method - no GC allocation
<FromGitter> <j8r> but the syntax will be the same, `Object.new`. You can then have a `new` inside `def self.new`
<FromGitter> <j8r> my mistake we can't, I thought we can include `self.test` methods https://play.crystal-lang.org/#/r/5hve
<FromGitter> <j8r> @fusillicode_twitter you can still https://play.crystal-lang.org/#/r/5hvp
<FromGitter> <swinSpo> how do i iterate over an array with key and value?
<FromGitter> <fusillicode_twitter> @j8r wow
<FromGitter> <fusillicode_twitter> 😲
<FromGitter> <swinSpo> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be94faef1b8753404b33453]
<FromGitter> <swinSpo> like this for example
ashirase has quit [Ping timeout: 272 seconds]
<FromGitter> <fusillicode_twitter> this would be my first macro in Crystal 😅
<FromGitter> <fusillicode_twitter> btw I can't find any reference regarding `gen` 🤔
<FromGitter> <swinSpo> anyone?
<FromGitter> <swinSpo> I just want something like ⏎ ⏎ ``` elements.each do |key, value| ⏎ end``` ⏎ ⏎ lol [https://gitter.im/crystal-lang/crystal?at=5be951d592b7d1172177b59f]
<FromGitter> <fusillicode_twitter> nerver mind about the `gen` XD
<FromGitter> <ljuti> @swinSpo You are looking for `.each_with_index`?
<FromGitter> <swinSpo> @ljuti oh my.. i think so yes
<FromGitter> <swinSpo> I found each_index which just gave me the index
<FromGitter> <swinSpo> but i didnt see the each_with_index
<FromGitter> <j8r> @fusillicode_twitter this is a macro name, you can write `gen` or `whatever`
<FromGitter> <fusillicode_twitter> @j8r yep yep as said, nevermind my ignorance ;)
ashirase has joined #crystal-lang
<FromGitter> <fusillicode_twitter> and obviously thanks a lot for your support 🙇
<FromGitter> <fusillicode_twitter> 🙇 🙇 🙇
<FromGitter> <j8r> but you're right there are special names like `inherited`
<FromGitter> <fusillicode_twitter> yeah I recall to have read something about macro hooks but unfortunately I never had any experience about them 😅
rohitpaulk has joined #crystal-lang
<FromGitter> <proyb6> I realize Crystal home page should also advertise it's capable for writing code without rely on IDE, that should be a great point to attract newcomers as we all tends to see IDE as a powerful tools for writing complex projects
<FromGitter> <proyb6> What do Crystal team think?
<FromGitter> <proyb6> Perhaps ability to monitor memory and CPU usage on Crystal program is extreme useful
<FromGitter> <swinSpo> Does crystal work on windows?
<FromGitter> <swinSpo> Like can i crystal run app.cr and crystal build app.cr?
<FromGitter> <fusillicode_twitter> totally agree with @proyb6
<FromGitter> <fusillicode_twitter> from my humble point of view Crystal shines from the developer experience perspective
<FromGitter> <proyb6> 👍 @fusillicode_twitter I have some idea why Meteor web framework who built a complex piece of code and their developers experience is to "reduce friction" as a powerful platform to work in, Crystal will need a similar kinds of platform for devs to feel belonging and ability to interact rapidly day and night
<FromGitter> <proyb6> Perhaps need a github to discuss?
<FromGitter> <proyb6> R
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> that's not a github issue (related to code), more a google group thread to open
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter> <cserb> What's the benefit of a Set over an Array in Crystal?
<FromGitter> <j8r> A `Set`can only have an element once, an array hasn't this limit
<FromGitter> <j8r> A `Set` is useful if you don't want duplicate elements
<FromGitter> <cserb> This is clear from the docs, but is this the only reason to use a Set? It comes with limitations as well in that you can't do smth like `my_set[0]'
<FromGitter> <bew> Well it doesn't make sense to have it, what's your usecase?
<FromGitter> <proyb6> @j8r Agreed with Google Group but I don't think most of us know that channel.
moei has joined #crystal-lang
<FromGitter> <cserb> @bew I have no usecase :) (yes it doesn't make sense to have it) I'd just like to understand better what a good usecase would be for a Set
<FromGitter> <bew> Hmm if you want a list of all the unique words in a text, you can use a Set, try to add each word to it, and if the word is already in it it won't be added
<FromGitter> <j8r> I do some devops, I've a list of packages to perform an action. I don't wan't to perform the action twice, so I've used a `Set`
<FromGitter> <cserb> So the main benefit is not having to take care of duplicity like in an Array? I'd assume the Set checking for duplicity is also more efficient than in an Array?
<FromGitter> <j8r> If I've used an Array I'll need an additional check with `.includes?` to not add a package twice
<FromGitter> <j8r> yes, `includes` will re-traverse the `Array` one element after another
<FromGitter> <cserb> Thanks for answering! This was my understanding as well, but thought that maybe I'm missing out on something
<FromGitter> <ljuti> Ideas on how to make this work? https://play.crystal-lang.org/#/r/5hxi
<FromGitter> <ljuti> I can’t figure out how to bind the Contact object properly to the proc
<FromGitter> <kingsleyh> Hi - is there anyone with C skills and Crystal skills who can work with me for a couple of hours over screensharing to help me make a shard of a hashing algorithm that’s written in C - it’s similar to scrypt-n - I can pay $50/hour for 5 hours help
<FromGitter> <j8r> @ljuti Does the `Hash` are really dynamic? If not, you could pass a struct instead
<FromGitter> <j8r> @kingsleyh you could also post in https://crystaljobs.org/
Jenz has joined #crystal-lang
<FromGitter> <ljuti> @j8r The map can be a struct, just made a hash for the sake of simplicity
<Jenz> If I want to analyze a crystal built executable, to find out what different parts of the stdlib takes the most place what do I need to read up about?
<Jenz> (Hoping there's some expert hanging around)
<FromGitter> <j8r> @ljuti and you want the from_node returns a result instead of nil?
<FromGitter> <ljuti> I want a Contact object out of it
<FromGitter> <j8r> Sorry I don't understand, the `pp obj1` returns a Contact object?
<FromGitter> <ljuti> It does, but its attributes are nil
<FromGitter> <ljuti> So what I’m asking is how to put the behavior I’ve laid out in main to be encapsulated inside the object
<FromGitter> <ljuti> Node object comes from a parser/transformer that does validations. The map object defines which attributes to pull from the node and how to do it.
<FromGitter> <ljuti> Originally I thought about extending `JSON::Serializable` but it was too cryptic for me :)
Jenz has quit [Ping timeout: 252 seconds]
t0nyandre has quit [Quit: WeeChat 2.3]
<FromGitter> <ljuti> @Blacksmoke16 https://github.com/Blacksmoke16/CrSerializer looks interesting. Can one specify class level validations?
<FromGitter> <Blacksmoke16> class level validation? do you have an example of what that would be?
<FromGitter> <ljuti> Say I have a property of `foo` and it should have one of `[“bar”, “baz”]`
<FromGitter> <ljuti> If `foo` is `bar` then property `one` should be either `[“cat”, “mouse”]`
<FromGitter> <ljuti> If `foo` is `baz` then property `one` should be either `[“dog”, “bone”]`
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <ljuti> It could be a property level,t oo
<FromGitter> <Blacksmoke16> and those are strings?
<FromGitter> <Blacksmoke16> you could define a custom assertion to put on that property
<FromGitter> <Blacksmoke16> then do like
<FromGitter> <ljuti> OK, then it might work for my use case
<FromGitter> <Blacksmoke16> ```def valid? ⏎ act = @actual ⏎ act == "bar" ? ["cat","mouse"] : ["dog","bone"] ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5be995fc7a36913a9a2f0ba8]
<FromGitter> <ljuti> Yeah, that would work
<FromGitter> <Blacksmoke16> thats what the custom assertions are for :)
<FromGitter> <Blacksmoke16> unless you want to read those arrays off the annotation, you could use that example, as the `BasicAssertion` handles no fields
<FromGitter> <Blacksmoke16> but if you did want to read them off, would have to define your own initializer like in example above
<FromGitter> <ljuti> OK, one more
<FromGitter> <ljuti> If `foo`is bar, then `one` should have cat and mouse
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <ljuti> If `foo` is `baz` then `one` shouldn’t be in the input and it should have field `two` with dog or bone
<FromGitter> <ljuti> This should be doable, right?
<FromGitter> <ljuti> So in that case property `one` must be set `nil` and then property `two` must have a value from the defined array
<FromGitter> <Blacksmoke16> wow, i deff didnt think of this use case :p
<FromGitter> <Blacksmoke16> but yea it prob should be doable?
<FromGitter> <ljuti> I’ll try it out
Jenz has joined #crystal-lang
<FromGitter> <Blacksmoke16> could do the custom assertion with a field of your other property, so that way you can read in the other property to have that to use in the assertion
<FromGitter> <ljuti> Exactly
<FromGitter> <Blacksmoke16> 👍 any issues let me know
<FromGitter> <ljuti> 10-4
greengriminal has joined #crystal-lang
ua has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter> <bararchy> @bcardiff you're here?
<FromGitter> <Blacksmoke16> @ljuti am trying it out on my own side project, man am i liking it
<FromGitter> <Blacksmoke16> slap on some annotations and done
<FromGitter> <Blacksmoke16> much better than maintaining custom `.to_json` methods
<FromGitter> <ljuti> Hear, hear
<FromGitter> <Blacksmoke16> the other cool part, since it is built on top of `JSON::Serializable` you could still to `to_json` to serialize the whole obj
<FromGitter> <Blacksmoke16> since it uses diff keywords
<FromGitter> <ljuti> What did I miss? https://play.crystal-lang.org/#/r/5hyp
<FromGitter> <Blacksmoke16> whats the error?
<FromGitter> <Blacksmoke16> `@value : CrSerializer::Assertions::ALLDATATYPES` you dont need this because you're not reading a `value` key off the annotation
<FromGitter> <Blacksmoke16> since you called yours `matchers`
<FromGitter> <ljuti> Annotation in class ```@[CrSerializer::Assertions::Matches(matcher: "/\w+:(\/?\/?)[^\s]+/“)]```
<FromGitter> <Blacksmoke16> jezz, these error messages got super vauge since .27
<FromGitter> <ljuti> I’m still on 0.26.1 if that’s of any consolation
<FromGitter> <Blacksmoke16> try removing the `@value` from the initialize method
<FromGitter> <ljuti> I did, same error
<FromGitter> <Blacksmoke16> try adding in a `return true if act.nil?`
<FromGitter> <Blacksmoke16> before you do the .match
<FromGitter> <ljuti> Ditto
<FromGitter> <Blacksmoke16> also assuming the .match is https://crystal-lang.org/api/0.27.0/String.html#match%28regex%3ARegex%2Cpos%3D0%29%3ARegex%3A%3AMatchData%3F-instance-method
<FromGitter> <Prutheus> jo
<FromGitter> <Blacksmoke16> i dont think that takes a string, should just be able to set the type of `matcher` as `Regex`
<FromGitter> <ljuti> That’s what I tried first, then changed the matcher to be a string
<FromGitter> <ljuti> If I return true straight away, it runs
<FromGitter> <ljuti> So the problem is in the evaluation
<FromGitter> <Blacksmoke16> try doing like `act.match(Regex.new(matcher))`
<FromGitter> <Blacksmoke16> and since `matcher` is not nilable, can get rid of the `matcher : Actual...` and just do `@matcher` in the `Regex.new`
<FromGitter> <Blacksmoke16> this reminds me...i thought i had a regex match assertion....
* FromGitter * Blacksmoke16 adds that to the todo list
<FromGitter> <vladfaust> Hi, got a new Job at crystaljobs. Cannot send e-mails to subscribers ATM, because campaign template isn't set up yet 😅
<FromGitter> <vladfaust> Twitter postings are earsier though :)
<FromGitter> <Blacksmoke16> @ljuti check the ending quote on your `"/\w+:(\/?\/?)[^\s]+/“` i dont think thats a proper double quote...it doesnt match the first
<FromGitter> <bararchy> @vladfaust congratz\
<FromGitter> <Blacksmoke16> OHHH @ljuti i know what the issue is
<FromGitter> <vladfaust> Gonna need to optmize it for mobiles
<FromGitter> <vladfaust> Yeah, thanks, @bararchy
<FromGitter> <Blacksmoke16> but its super vague, compiler should deff have a better error message for it
<FromGitter> <vladfaust> BTW that smarttrade guy confirmed on that he'd found a Crystal developer
<FromGitter> <vladfaust> Via CrystalJobs
<FromGitter> <vladfaust> Isn't that great?
<FromGitter> <bararchy> yes it is!
<FromGitter> <bararchy> really cool
<FromGitter> <ljuti> @Blacksmoke16 I’m all ears
<FromGitter> <bararchy> https://crystaljobs.org/ is getting really cool
<FromGitter> <kingsleyh> @vladfaust yeah that's my job
<FromGitter> <kingsleyh> the new one
<FromGitter> <bararchy> lol yeha it's @kingsleyh !
<FromGitter> <bararchy> great move there
<FromGitter> <vladfaust> I *could* have figure it out
<FromGitter> <kingsleyh> heheh
<FromGitter> <bararchy> XS
<FromGitter> <Blacksmoke16> @ljuti yea so `.match` returns `Regex::MatchData?` not `Bool`
<FromGitter> <ljuti> Of course
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be9a58d6b9822140d1bf51f]
<FromGitter> <ljuti> Shouldn’t double-bang turn that into `Bool` though?
<FromGitter> <kingsleyh> @vladfaust I'm sorry but I found posting a job quite hard - I can think of many improvements - I'm flat out working on other stuff though - but maybe when I get some time I will give you my feedback
<FromGitter> <ljuti> Bingo, that does it
<FromGitter> <vladfaust> Great, feedback is appreciated indeed
<FromGitter> <vladfaust> I think that re-tweeting could drastically improve crystaljobs coverage
<FromGitter> <vladfaust> Moving out of gitter-only-crystallers
<FromGitter> <vladfaust> Dis: https://twitter.com/crystaljobsorg
<FromGitter> <ljuti> @Blacksmoke16 This is really cool. Thanks for sharing!
<FromGitter> <ljuti> Definitely useful for me
<FromGitter> <Blacksmoke16> np, im going to see if i can narrow down that issue
<FromGitter> <kingsleyh> Gitter is bridged with IRC as well - I only know of Gitter and IRC - but I guess there are other Crystal devs who don't use either of these
<FromGitter> <Blacksmoke16> that error is super not helpful for something that could have been solved by like `return type expected Bool got RegexMatch?`
<FromGitter> <Blacksmoke16> np :) glad someone other than me is enjoying it haha
<FromGitter> <Blacksmoke16> but thanks for reminding me, ill add a regex match assertion
<FromGitter> <kinxer> Is it possible to restrict a variable to be a subclass of a particular class AND to include a particular module? I know this can be done by introducing an intermediary (potentially abstract) class, but I'm wondering if there's another solution.
<FromGitter> <kinxer> Also, I don't care if it's a proper subclass; as long as an "is a" relation holds between the variable and the class, it's fine.
<FromGitter> <j8r> no
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
<FromGitter> <ljuti> @Blacksmoke16 Does CrSerializer have an assertion like `be_a`?
<FromGitter> <Blacksmoke16> no because thats handled by default due to static typing
<FromGitter> <Blacksmoke16> i.e.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58k7
<FromGitter> <Blacksmoke16> so i didnt see a reason to add one if it never would get that far anyway
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <ljuti> How do I handle validation of nested objects?
<FromGitter> <Blacksmoke16> should just be able to put the assertions on it like normal
<FromGitter> <Blacksmoke16> can do a find for those 2 classes
<FromGitter> <ljuti> I’m getting `true`for `valid?` on nested object when parent object is not valid (as expected)
<FromGitter> <Blacksmoke16> got an example?
<FromGitter> <Blacksmoke16> ohh i see
<FromGitter> <Blacksmoke16> you want the parent class to be invalid if any child class is invalid
<FromGitter> <Blacksmoke16> hmm yea good point
greengriminal has joined #crystal-lang
<FromGitter> <ljuti> Well, that too, but I expected the child classes to be invalid when given invalid data
<FromGitter> <ljuti> I’m cleaning up an example
<FromGitter> <ljuti> If I pretty print the object, does that suffice?
<FromGitter> <ljuti> It shows nothing in the errors for the child object
<FromGitter> <ljuti> And in spec if I call `.valid?` on it, it returns true
<FromGitter> <Blacksmoke16> just your structure of class/child would be fine
<FromGitter> <Blacksmoke16> with assertions
<FromGitter> <ljuti> Never mind, seemed to be a PEBKAC
<FromGitter> <ljuti> :)
<FromGitter> <Blacksmoke16> was going to say: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ print true false [https://gitter.im/crystal-lang/crystal?at=5be9b598d001b917204c85df]
<FromGitter> <Blacksmoke16> but yea, something you could put on `age` property to say `make this obj invalid if any child assertions fail` would be a good feature
<FromGitter> <ljuti> Uhhuh
<FromGitter> <ljuti> I guess that could be done with a custom assertion?
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <ljuti> Yeah, works. Default error message is just a bit cryptic but it can be customised, right?
<FromGitter> <Blacksmoke16> yea, can just do `LessThan(message: "blah blah")`
<FromGitter> <Blacksmoke16> each assertion has a `message` field that can be set
<FromGitter> <j8r> does annotations are only meant to be used with macros?
<FromGitter> <Blacksmoke16> afaik can only read them off annotations yea
<FromGitter> <Blacksmoke16> @ljuti ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be9b86b47217e07ff0f8f7e]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be9b87dbb88787474ba66ef]
<FromGitter> <Blacksmoke16> both are false
<FromGitter> <Blacksmoke16> er true, and if yrs is `15` both are false
<FromGitter> <j8r> I'm doing a work to do JSON serialization without annotation and without a namedtuple, looks good :)
<FromGitter> <j8r> Just inside an object: ⏎ ⏎ ```struct Obj ⏎ property key : String ⏎ JSON.mapping(key: "key") ⏎ end``` ⏎ ⏎ that's it :) ... [https://gitter.im/crystal-lang/crystal?at=5be9b917d001b917204c9e27]
<FromGitter> <Blacksmoke16> wouldnt the easiest solution be to just do `include JSON::Serializable`
<FromGitter> <ljuti> @Blacksmoke16 Yeah, I implemented just that :)
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> it makes the assumption that child classes are validated *before* the parent, but that seems to be the case so works for me
<FromGitter> <ljuti> Yeah, you’re correct. I have a spec which has valid data for parent object but invalid data for child object. Both parent and child are invalid and the error is the proper one.
return0e has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> so it is an issue?
<FromGitter> <ljuti> No, that’s the behaviour I want
<FromGitter> <Blacksmoke16> 👌
<FromGitter> <Blacksmoke16> writing some specs for it now
<FromGitter> <ljuti> I’m putting my custom assertions here, feel free to pick them up if you like https://gist.github.com/ljuti/67e77797d5127b90d5fea56a2220c2be
<FromGitter> <Blacksmoke16> will do
<FromGitter> <ljuti> Feature suggestion: add `fields_with_errors` or alike to `Validator` so one could get the fields that failed validation
<FromGitter> <ljuti> Or maybe I’ll write a PR when I really need this and implement it
<FromGitter> <Blacksmoke16> its doable now, just not as clean
<FromGitter> <Blacksmoke16> nvm, ill include that as well
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be9be01e0fd6b4360e16e12]
<FromGitter> <j8r> @Blacksmoke16 no because you have to add an annotation for each ivar. I don't know if you have seen the `JSON::Serialization` implementation - it's rather complex
<FromGitter> <Blacksmoke16> you dont *have* to
<FromGitter> <Blacksmoke16> by default it serializes all ivars with they key as the name of the ivar
<FromGitter> <Blacksmoke16> if you want to control they serialized key, or ignore a property then yea, would have to add some annotations
<FromGitter> <j8r> The solution I've found is really simple, just use what you know and a macro defining the mapping. ⏎ I'll open an issue on it when I'm done with the implem for JSON. I already done one for CON
<FromGitter> <j8r> it'll serialize only the keys defined in the mapping. 3 modes available, strict, lazy and full mapping
<FromGitter> <jwoertink> Our app see this error message pretty often
<FromGitter> <jwoertink> ```IO::Error/usr/share/crystal/src/io.cr:128:5 in 'write_byte':0 ⏎ Closed stream``` [https://gitter.im/crystal-lang/crystal?at=5be9bf81e0fd6b4360e17789]
<FromGitter> <jwoertink> Has anyone come across this?
<FromGitter> <Blacksmoke16> fair enough, ill be sure to take a look
<FromGitter> <jwoertink> I'm not really sure how to create it minimally, or which repo I'd report this on.
<FromGitter> <jwoertink> it seems like a connection in the pg pool goes stale, or dies, and then the app never releases it.
<FromGitter> <Blacksmoke16> @ljuti 👍 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be9c05a92b7d117217a9fb7]
<FromGitter> <Blacksmoke16> i also set `assertions` as a getter on the `Validator` class, so can return an array of all the assertions set on the class if you wanted to do something more with it
<FromGitter> <Blacksmoke16> would give you access to field, actual value etc
<Jenz> Brb
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5i08 hmm
non-aristotelian has joined #crystal-lang
<FromGitter> <mettuaditya> how to create a new library and contribute to crystal
<FromGitter> <Blacksmoke16> what do you want to create?
<FromGitter> <mettuaditya> a graph library
<FromGitter> <mettuaditya> like RGL
<FromGitter> <Blacksmoke16> `crystal init lib my_lib`
<FromGitter> <mettuaditya> can u explain the procedure in detail i am new here
<FromGitter> <Blacksmoke16> do you have crystal installed?
<FromGitter> <mettuaditya> yes
<FromGitter> <Blacksmoke16> yea, then just type `crystal init lib my_lib` into terminal
<FromGitter> <Blacksmoke16> will scaffold out a new shard for you
<FromGitter> <mettuaditya> and how to send pull request for the library ??
<FromGitter> <Blacksmoke16> well RGL graph lib wouldnt go into the standard lib of crystal itself
<FromGitter> <Blacksmoke16> you would want to make it as a shard that people can install
<FromGitter> <mettuaditya> ohh thank you for the info
<FromGitter> <Blacksmoke16> np
<Jenz> Man, it ended draw
Jenz has quit [Ping timeout: 260 seconds]
hightower4 has quit [Ping timeout: 252 seconds]
sagax has joined #crystal-lang
<FromGitter> <kinxer> I asked this a few days ago, but got no replies: does anyone know why I might be a "Permission Denied" error when trying to fetch from the Crystal dist repository from OpenSUSE?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <kinxer> I'm pretty sure I'm using the same repo as the instructions in the docs use for CentOS and RedHat. Is anyone using Crystal on those distributions with no issues updating?
<FromGitter> <Blacksmoke16> @ljuti I pushed up a new branch for the `Valid` and `RegexMatch` assertions if you want to check them out
<FromGitter> <Blacksmoke16> also includes that `invalid_properties` method
<FromGitter> <ljuti> Nice!
<FromGitter> <Blacksmoke16> going to work on `Url` next
<FromGitter> <ljuti> @Blacksmoke16 Added `ValidEmail` here https://gist.github.com/ljuti/67e77797d5127b90d5fea56a2220c2be
<FromGitter> <Blacksmoke16> nice one
<FromGitter> <ljuti> Don’t have proper specs for that, but seems to handle the obvious cases for me in my project
<FromGitter> <Blacksmoke16> rgr, ill take a look
<FromGitter> <Blacksmoke16> modeling my assertions after https://symfony.com/doc/current/reference/constraints/Url.html these
<FromGitter> <Blacksmoke16> but everything going well so far? any other suggetsions?
<FromGitter> <ljuti> Yeah, I’ll let you know if I think of something useful to change
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <jwoertink> @kinxer What's the URL you're trying to fetch?
<FromGitter> <kinxer> The full error is `Permission to access 'https://dist.crystal-lang.org/rpm/media.1/media' denied.`
<FromGitter> <kinxer> Also, the instructions I used to set up the repo in my package manager are here (https://github.com/crystal-lang/crystal-book/blob/597dd3a9b39d305ef8cc8bb0218df3f3e76144fd/installation/on_opensuse.html).
<FromGitter> <jwoertink> My guess is it's missing some signed key
<FromGitter> <jwoertink> Are you just trying to install crystal?
<FromGitter> <jwoertink> You could try it from source, and then just report that error to the repo.
<FromGitter> <kinxer> I have Crystal 0.26.1 from when I originally set up the repo, but my goal is to be able to update Crystal via my package manager.
<FromGitter> <kinxer> How would I report the error to the repo?
<FromGitter> <jwoertink> Just add a new issue on https://github.com/crystal-lang/crystal/issues for updating crystal on SUSE. Add the steps, and your version
<FromGitter> <kinxer> A'ight. Will do. Thank you.
<FromGitter> <jwoertink> 👍
woodruffw has quit [Quit: And then he took off.]
woodruffw has joined #crystal-lang
<FromGitter> <Prutheus> Are channels blocking? I mean when I do channel.send … does it wait for a receive until it continues?
<FromGitter> <Prutheus> yes it is … okay, thanks
<FromGitter> <Prutheus> I can use buffered channels
moei has quit [Quit: Leaving...]
thews has quit [Ping timeout: 250 seconds]
thews has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
t0nyandre has joined #crystal-lang
<t0nyandre> I've been wondering; are there any active Discord communities for Crystal as well as the gitter/irc? :)
<FromGitter> <vladfaust> Nope
<t0nyandre> Fair enough xD
<FromGitter> <vladfaust> I'm willing to create one as well as a discourse-based forum
<t0nyandre> I'm just seeing people using Discord more and more so that's why I asked :) Ofc. I'd join if there was any but no need to create one just for us two ;P