ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.1 | 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
<FromGitter> <watzon> This actually seems to work fairly well https://play.crystal-lang.org/#/r/7k9t
<FromGitter> <watzon> And no regex!
<FromGitter> <Blacksmoke16> nice boxes :S
<FromGitter> <watzon> Lol looks like you don't have the Hindi font
<FromGitter> <Blacksmoke16> the reader exposes like `#map` and `#each` methods btw
<FromGitter> <watzon> Yeah I'll keep messing with it
<FromGitter> <watzon> Happy that I found a non-regex method though
<FromGitter> <watzon> Omg it's so much faster
alex`` has joined #crystal-lang
hypercore has quit [Remote host closed the connection]
hypercore has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.6]
alex`` has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <asterite> instead of map + any you can use any
<FromGitter> <Blacksmoke16> had an idea to extend the assertion stuff into class method that can be used adhoc
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c47a962bfc95112e4ea7b]
<FromGitter> <Blacksmoke16> dunno how i feel about it atm tho
<companion_cube> what are these maintainers who actually review PRs and , hmm ? :p
<companion_cube> -and
<FromGitter> <Blacksmoke16> main use case would be when you cant add annotations to something, but still want to validate stuff
<FromGitter> <Blacksmoke16> thoughts?
<FromGitter> <Blacksmoke16> might go with it...implementation is like 4 lines with some macro magic :P
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c4aa0d3283306ba39e7ae]
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c4b8e5d40aa0d7d318e31]
<FromGitter> <Blacksmoke16> now correctly handle property name
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7c4c1372fe1251119f3e3d]
<FromGitter> <Blacksmoke16> pretty cool
<hypercore> whats the reasoning behind usng functions instead of templates in Lucky?
<FromGitter> <Blacksmoke16> dunno never used it
<FromGitter> <fridgerator> There is a lucky gitter channel, you might get more information there
<FromGitter> <Blacksmoke16> They don't have a relay bot I think was the problem
<hypercore> yeah i'm only on irc right now
_whitelogger has joined #crystal-lang
chemist69 has quit [Ping timeout: 245 seconds]
chemist69 has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <watzon> hypercore it's more powerful than most template languages and allows you to stay in Crystal
<FromGitter> <watzon> Takes some getting use to, but I like it
_whitelogger has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
return0e has quit [Ping timeout: 265 seconds]
absolutejam1 has joined #crystal-lang
gangstacat has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 265 seconds]
ht_ has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
erdnaxeli has joined #crystal-lang
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 276 seconds]
<FromGitter> <straight-shoota> hypercore, I haven't worked with lucky, but you can probably hook it up with a template engine. https://github.com/straight-shoota/crinja evaluates at run time, so you edit your templates without rebuilding the app. It's obviously not as performant as a pure-Crystal template, but it's incredibly useful for rapid development.
ht_ has quit [Quit: ht_]
alex`` has joined #crystal-lang
sorcus has joined #crystal-lang
return0e has joined #crystal-lang
<hypercore> watzon: i've just never seen a backend framework use templates in this way, it's actually not that bad
<hypercore> getting kind of used to it now
<hypercore> thanks straight-shoota, i'll take a look
<hypercore> is there a way way to import sub-templates for lucky?
<hypercore> e.g. if i have a sidebar.cr, how can i use this in my main_layout.cr?
<FromGitter> <asterite> I suggest you use Lucky's gitter
<FromGitter> <Blacksmoke16> they dont have a relay bot for IRC
<FromGitter> <Blacksmoke16> but yea, would prob get more help from there
<hypercore> ok thanks
<FromGitter> <Fryguy> You don't need a relay bot for irc... Just connect your irc client to irc.gitter.im
<FromGitter> <kingsleyh> I have this macro:
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7cedbdc82c2e0d7ed3a451]
<FromGitter> <kingsleyh> when I execute like this: `run_it("get_greeting", args)` it works fine
<FromGitter> <kingsleyh> but it returns Nil when I run it like this: `c : String = "get_greeting" ; run_it(c, args)`
<FromGitter> <kingsleyh> if there a way I can assign the name to a variable?
<FromGitter> <stronny> macros evaluate at compile time
<FromGitter> <stronny> if you need a runtime dispatch macros can't help you
<FromGitter> <kingsleyh> ok hmm
<FromGitter> <kingsleyh> I don't need it at runtime
<FromGitter> <kingsleyh> I can do it at compile time - since I should have all the info
<FromGitter> <kingsleyh> maybe an annotation on the method I want to run will do it for me
<FromGitter> <stronny> is there a purpose here, or just an excercise?
<FromGitter> <kingsleyh> currently I have the method I want to run in a map
<FromGitter> <kingsleyh> for my lib here: https://github.com/SushiChain/spinach
<FromGitter> <stronny> read a file and run code based on strings inside the file?
<FromGitter> <kingsleyh> yeah
<FromGitter> <stronny> that's as runtime as you can get
<FromGitter> <stronny> hash of proc is not a bad idea
<FromGitter> <kingsleyh> yeah but it doesn't work
<FromGitter> <kingsleyh> well it works for simple things
<FromGitter> <kingsleyh> but for more complicated things the compiler crashes
<FromGitter> <stronny> yeah, it's a bit finicky
<FromGitter> <stronny> also types
<FromGitter> <kingsleyh> so I was trying to get rid of the proc hash
<FromGitter> <kingsleyh> and just call the method directly
<FromGitter> <stronny> why are you dong it in crystal?
<FromGitter> <kingsleyh> I like Crystal
<FromGitter> <kingsleyh> I thought it was possible in Crystal
<FromGitter> <kingsleyh> but maybe not
<FromGitter> <stronny> even if it is, it feels hacky and not fit for purpose
<FromGitter> <kingsleyh> plus all my other code that needs testing is in Crystal - so it made sense
<FromGitter> <stronny> you need eval
<FromGitter> <stronny> what you can do with macros is generate all the possible calls, if it's a finite set
<FromGitter> <stronny> a bit like JSON.mapping works
<FromGitter> <kingsleyh> yep I see
<FromGitter> <kingsleyh> I have a think about a different approach - maybe a DSL in the code that generates the output would be a better fit
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Crystal/Macros.html#run(filename,*args):MacroId-instance-method
<FromGitter> <kingsleyh> oh you mean read and process the html file at compile time instead of runtime
<FromGitter> <kingsleyh> using that run macro
<FromGitter> <stronny> rebuild the binary on each run
<FromGitter> <Blacksmoke16> idk, i was just pointing that out
<FromGitter> <kingsleyh> ok yes I think that can work
<FromGitter> <stronny> your users will have to have crystal compiler installed
<FromGitter> <kingsleyh> binary 1 can deal with parsing the html and producing all the commands that need to be executed - and binary 2 can run binary 1 and supply it with the html file to process
<FromGitter> <kingsleyh> yeah the idea is they must have Crystal compiler anyway
<FromGitter> <Blacksmoke16> seems like a hacky solution...
<FromGitter> <kingsleyh> I don't think it's possible any other way
<FromGitter> <kingsleyh> the current way I do it with a map of method_name -> Proc - is very flaky and the compiler crashes depending on the content of the Proc
<FromGitter> <kingsleyh> if I could put whatever I want in a Proc and call it later without the compiler crashing - that would be a decent solution
<FromGitter> <stronny> can you show an example of a crash?
<FromGitter> <kingsleyh> but doing it in 2 steps using the run macro - seems like the only alternative - if I want to keep the current concept
<FromGitter> <kingsleyh> yeah
<FromGitter> <stronny> I mean you can also shell out to a bash script or something
<FromGitter> <stronny> you can use Lua
<FromGitter> <stronny> there are options
<FromGitter> <stronny> (Lua built in your crystal program)
<FromGitter> <kingsleyh> here you go
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7cf582bda39316947eac9a]
<FromGitter> <stronny> whoa, didn't see that one yet
<FromGitter> <kingsleyh> @stronny what do you mean by Lua built in the Crystal program?
<FromGitter> <asterite> does it crash with - - no-debug
<FromGitter> <asterite> and please report any crash bugs
<FromGitter> <stronny> there are C libs with interpreted language runtimes, you can link against them and eval away
<FromGitter> <kingsleyh> oh no it works with --no-debug
<FromGitter> <asterite> any DI thing and module validation failed is related to debug info
<FromGitter> <kingsleyh> @asterite oh I see - is the issue something fixable?
<FromGitter> <asterite> and these are usually easy to fix, so please report a bug. thank you!
<FromGitter> <kingsleyh> ok thanks
<FromGitter> <kingsleyh> @stronny interesting - although if I was to write it in Ruby I would just use eval
<companion_cube> sooo, people don't need overlapping regex match, ok
<FromGitter> <stronny> the idea here is 1) the bulk of your program is statically typed 2) you don't need any runtime besides what ldd tells you
<FromGitter> <stronny> you gain eval inside mruby calls, but not anywhere else
<FromGitter> <stronny> I'm surprised there isn't a shard for mruby already, it feels so natural
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7cfb15d5c523462f8020bb]
<FromGitter> <Blacksmoke16> perfect
<FromGitter> <Blacksmoke16> cant really do anything about the name, imagine it would be overwritten in most cases tho?
<FromGitter> <Blacksmoke16> i.e. like `Assert.not_blank! some_value, message: "The post title cannot be blank"`
<FromGitter> <kingsleyh> Whats the best way of making sure that amount can't be lower than 0 when doing this: `amount -= deduction`
<FromGitter> <Blacksmoke16> `amount >= 0`
<FromGitter> <kingsleyh> isn't there a built in thingy?
<FromGitter> <Blacksmoke16> not that i know of
<FromGitter> <Blacksmoke16> ```if amount.zero? ⏎ do something ⏎ else ⏎ amount -= 1 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d7d10235d40aa0d7d369975]
<FromGitter> <kingsleyh> no I mean - if the deduction happens to put amount in the negative
<FromGitter> <Blacksmoke16> right thats what that would do...
<FromGitter> <kingsleyh> like: 10 - 100 - I would want amount to be 0 not negative number
<FromGitter> <Blacksmoke16> `amount -= 1 if amount > 0`
<FromGitter> <Blacksmoke16> ah
<FromGitter> <kingsleyh> (10 - 100) should be 0, but (10 - 2) should be 8
<FromGitter> <Blacksmoke16> `Math.max(10-100, 0)`
<FromGitter> <kingsleyh> Ah yes!! that's the thingy I was thinking about
<FromGitter> <kingsleyh> thanks
<FromGitter> <kingsleyh> hmm actually that doesn't work
<hypercore> do you guys deploy your apps to heroku? and do you find it sufficient?
<hypercore> thinking about deploying a Lucky app there
ht_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
Human_G33k has quit [Ping timeout: 246 seconds]
<FromGitter> <j8r> @kingsleyh what doesn't work?
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <watzon> @hypercore Lucky's templates are actually kind of similar to the way Flutter does things
<FromGitter> <watzon> I started to enjoy it with Flutter and was super happy to see Lucky doing the same
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
<hypercore> haven't used flutter actually, heard about it a lot though
<hypercore> watzon: is it possible to deploy Lucky apps to a VPS?
<FromGitter> <watzon> Of course
<hypercore> Blacksmoke16: it only has instructions for heroku, not Linode/DO/VUltr/etc
<FromGitter> <watzon> Lucky is, I believe, already set up to work with Docker as well. So if you have your VPS set up to run Docker containers it should be easy
<FromGitter> <watzon> I recommend looking into Traefik
<FromGitter> <Blacksmoke16> right, you mentioned heroku
<FromGitter> <Blacksmoke16> :shrug:
absolutejam1 has joined #crystal-lang
<FromGitter> <kingsleyh> @Blacksmoke16 and @asterite and @stronny and @watzon - thanks for your help discussing my Spinach library - I've got things running pretty nicely now - and also running in circleci - check it out -- https://2636-116621739-gh.circle-artifacts.com/0/root/project/spec/functional/reports/transactions.report.html
<FromGitter> <watzon> Dude that is freaking awesome
<FromGitter> <watzon> I think it would take me some time to figure out how to switch gears from the way I'm currently doing testing, but having it all laid out on a webpage like that is beautiful
<FromGitter> <kingsleyh> thanks :)
<FromGitter> <kingsleyh> I'm going to generate a dashboard page with links to all the reports and some graphs and overview etc
<FromGitter> <Blacksmoke16> So you write HTML to write tests?
<FromGitter> <kingsleyh> @Blacksmoke16 yeah it's based on this: https://concordion.org/
<FromGitter> <watzon> @Blacksmoke16 link to it if you want to check it out https://github.com/SushiChain/spinach
<FromGitter> <watzon> Pretty cool project
<FromGitter> <Blacksmoke16> im not sure how i feel about that
<FromGitter> <watzon> It's definitely different
<FromGitter> <Blacksmoke16> i think i would rather write crystal tests and output junit and just have some UI to read that
<FromGitter> <kingsleyh> I think I can remove the need to write the mapping manually with some annotation magic
<FromGitter> <kingsleyh> But gotta work on SushiChain more now so I’ll come back to it
<FromGitter> <watzon> Yeah I agree that would be nice
<FromGitter> <Blacksmoke16> because crystal can output TAP and junit already
<FromGitter> <kingsleyh> Yeah that’s a developer approach
<FromGitter> <kingsleyh> My thing is the other way
<FromGitter> <Blacksmoke16> ah so someone who doesnt know code writes the html
<FromGitter> <kingsleyh> Business analyst and testers write scenarios and dev automate
<FromGitter> <Blacksmoke16> ah gotcha, that makes more sense
<FromGitter> <kingsleyh> Can also have a markdown alternative to html
<FromGitter> <Blacksmoke16> added section on the new ad hoc validation feature
ht_ has quit [Quit: ht_]
<FromGitter> <absolutejam_gitlab> > Business analyst and testers write scenarios and dev automate ⏎ ⏎ Does that work well?
<FromGitter> <absolutejam_gitlab> Sounds god-awful, but I guess it depends on the business & approach
absolutejam1 has quit [Ping timeout: 276 seconds]
<FromGitter> <kingsleyh> @absolutejam_gitlab it works well if everyone is into it - but it's pretty expensive - I've worked in quite a few places that went all in on Cucumber, BDD, Concordion etc
<FromGitter> <kingsleyh> I like it when the business provide the scenarios because they tend to be pretty awesome in term of coverage and cases I might miss etc
<FromGitter> <watzon> Well typically they know how they want the product to work
<FromGitter> <kingsleyh> especially in complex businesses
<FromGitter> <kingsleyh> most of my recent work has been on banking, fintech and trading apps - and the business is always pretty complicated
absolutejam1 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 240 seconds]
alex`` has quit [Quit: WeeChat 2.6]
alexherbo2 has joined #crystal-lang
<FromGitter> <kingsleyh> If I've got hold of the method is there any way I can see what annotations are on the method?
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7d62b1577fc14c7fc653a6]
<FromGitter> <kingsleyh> while I'm in that for loop - I'd like to know if `method` has any annotations - is that possible?
alexherbo2 is now known as alex```
<FromGitter> <kingsleyh> ah yes got it thanks
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d7d63dbba12e06448701030]
<FromGitter> <kingsleyh> in case anyone is interested :)
sorcus has quit [Ping timeout: 246 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
sagax has quit [Ping timeout: 246 seconds]
alex``` has quit [Ping timeout: 246 seconds]
sagax has joined #crystal-lang