ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
mattt has quit [Quit: WeeChat 1.4]
Guest12 has joined #crystal-lang
Guest12 has quit [Client Quit]
maria_elis has joined #crystal-lang
postmodern has quit [Quit: Leaving]
<FromGitter> <naqvis> true, case will end on the very first match, so for such scenario its better to move the parent or more general type to the end
<FromGitter> <naqvis> https://carc.in/#/r/bc7m
billyruffian has joined #crystal-lang
billyruffian has quit [Remote host closed the connection]
<FromGitter> <bovepm> hi there! former rubyist and crystal newbee here. I am currently writing some crystal code and wanted to use the mixin Enumerable on class level rather than on instance level (see code below). any hints? ⏎ https://carc.in/#/r/bc7v
<FromGitter> <erdnaxeli:cervoi.se> just extend it: https://carc.in/#/r/bc7z
<FromGitter> <bovepm> super, thanks for the quick reply
fifr has quit [Changing host]
fifr has joined #crystal-lang
dostoyevsky2 has quit [Quit: leaving]
dostoyevsky2 has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
ua_ has joined #crystal-lang
<FromGitter> <foxxx0> Hi, any suggestions on how I would best implement a predefined set of format strings / placeholders that can be user-specified (e.g. via config file)? I don't want allow users to directly influence the `#sprintf` formatstring for security reasons, I was thinking more in the direction of having something like `"some prefix: ###foo.attr1### with ###foo.attr2###"` where I want to replace `"###foo.attr1###"` with
<FromGitter> ... the value of `foo.attr1` and so on. How could achieve that somewhat elegantly?
<FromGitter> <naqvis> @foxxx0 Crystal doesn't support RTTI, that means there is no way to achieve dynamic execution of props/methods. Crystal expects methods/fields calls to be known at compile time. What I understand from your context is you are looking for some template language which you can invoke at run-time
<FromGitter> <foxxx0> correct
<FromGitter> <naqvis> AFAIK crinja (https://github.com/straight-shoota/crinja) does this trick of run-time execution, so that might be something you can refer to
<FromGitter> <foxxx0> mh, looks like crinja strictly expects values and not custom classes
<FromGitter> <foxxx0> maybe i'll need to parse the user-supplied argument then and provide crinja with the correct value? but then there is no point to pulling in crinja
<FromGitter> <naqvis> hmm, how come such conclusion?
<FromGitter> <naqvis> Template engine doesn't force you to any specific set of usage
<FromGitter> <naqvis> you can access any object as long as template engine has access to that object
<FromGitter> <naqvis> For example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60c89ae3a5d5740d61276eb4]
deavmi has quit [Quit: No Ping reply in 180 seconds.]
deavmi has joined #crystal-lang
fifr is now known as fifr_
fifr_ is now known as fifr
mattt has joined #crystal-lang
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
<FromGitter> <speg> speaking of templates, how do i make this work: ⏎ `ECR.def_to_s "#{ECR_ROOT}/greeter.ecr"` ⏎ Can't do that when calling a macro?
<FromGitter> <Blacksmoke16> does that not already work?
<FromGitter> <speg> Kinda. I think it's constant above that is broken: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60c8d022c705e53c1c92ed3a]
<FromGitter> <Blacksmoke16> try and use `__DIR__` instead of `.`
<FromGitter> <Blacksmoke16> pretty sure `.` is the dir you're executing the file from while `__DIR__` is the location of the file or something like that
wmoxam_ is now known as wmoxam
<FromGitter> <Blacksmoke16> oh but try doing ` ECR.def_to_s "#{ECR_ROOT.id}/greeter.ecr"`
<FromGitter> <speg> same thing, I had also tried using `Dir.current` with no luck
<FromGitter> <speg> ooh, `.id`?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <speg> Success! 🙌🏼 Thank you sir. I haven't used macros yet, what's going on here?
<FromGitter> <Blacksmoke16> seems like its interoplating the string literal into the other string. Notice the path in the error has like `\"`, instead of just like `ecr/greeter.ecr`
<FromGitter> <Blacksmoke16> `.id` returns the raw value of the constant, e.g. `./src/template/components/ecr`
<FromGitter> <Blacksmoke16> *maybe* thats a bug as it's deff not what you'd expect :shrug:
<FromGitter> <speg> hehe, neat. I was reading up on macros just last night but obvs need to learn some more. Thanks again!
postmodern has joined #crystal-lang
Guest54 has joined #crystal-lang
Guest54 has quit [Client Quit]
fifr has quit [Quit: ZNC 1.8.2 - https://znc.in]
fifr has joined #crystal-lang
<FromGitter> <wyhaines> @foxxx0 Is something like this what you are looking for? ⏎ ⏎ https://gist.github.com/wyhaines/9b939ce08ea6f85de08c2802edb774c5
<FromGitter> <foxxx0> @wyhaines oh yes, that looks neat, thank you for that! I will tinker with a bit :)
<FromGitter> <foxxx0> @wyhaines would you mind sharing the `./src/send` also or is that not needed?
<FromGitter> <wyhaines> Send absolutely is the secret sauce there. :)
<FromGitter> <wyhaines> Fortunately, it'
<FromGitter> <wyhaines> It's not secret.
<FromGitter> <wyhaines> https://github.com/wyhaines/send.cr
<FromGitter> <wyhaines> It has some limitations that I haven't bothered to address yet (and some that can not be fixed), and caveat emptor re undiscovered bugs, but basically it lets one do dynamic dispatch to objects in Crystal.
<FromGitter> <wyhaines> Feel free to ping me here or on Github or on the discord if you have any questions about what you can or can not do with it, or if it does something that you think is broken.
<FromGitter> <foxxx0> will do, thank you!
<FromGitter> <didactic-drunk> Why does `crystal doc` skip all my classes (https://didactic-drunk.github.io/crypto-secret.cr/main/) except for a monkey patched `Slice` in my project (https://github.com/didactic-drunk/crypto-secret.cr)
<FromGitter> <Blacksmoke16> I'd guess`Crypto` already exists and is nodoc
dom96_ is now known as dom96
<FromGitter> <didactic-drunk> I don't see defined `Crypto`anywhere. It's implicitly defined as `Crypto::{Subtle,Bcrypt,Blowfish}`
<FromGitter> <oprypin:matrix.org> @didactic-drunk: because `Crypto` (https://crystal-lang.org/api/1.0.0/Crypto.html) is marked as originating from stdlib by its first occurrence in the whole code blob, and the whole stdlib is excluded from doc building
<FromGitter> <didactic-drunk> @oprypin:matrix.org Now I have a workaround. Thank you
<FromGitter> <oprypin:matrix.org> @didactic-drunk: im scared. what is it?