RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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> <Blacksmoke16> https://github.com/Blacksmoke16/athena/blob/master/docs/routing.md#exception-handling quite happy how this turned out
lucasb has quit [Quit: Connection closed for inactivity]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
ashirase has quit [Ping timeout: 272 seconds]
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 272 seconds]
gangstacat has quit [Quit: Ĝis!]
rohitpaulk has joined #crystal-lang
chemist69 has quit [Ping timeout: 240 seconds]
chemist69 has joined #crystal-lang
gangstacat has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
sagax has quit [Quit: Konversation terminated!]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
gtramontina has joined #crystal-lang
gtramontina has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
simerax has joined #crystal-lang
<simerax> Hello together, im fairly new to using crystal. Right now im writing an application which uses the HTTP::WebSocket inside a Connection Class. I want to write tests for this class but I dont really know how. Im thinking about mocking the HTTP::WebSocket class however i dont quite know how to mock the constructor of HTTP::WebSocket since the connection is already established inside the constructor.
<simerax> what i want is that the Constructor of HTTP::WebSocket does not fail bcs it cannot connect but still get a valid WebSocket Object
<simerax> I looked up mocking in crystal and found https://github.com/waterlink/mocks.cr
<FromGitter> <vladfaust> Why don’t you actually launch a server and do websocket requests to it?
<simerax> did not really think about that...thanks for the example! i will look into it
rohitpaulk has quit [Ping timeout: 250 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
laaron has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <straight-shoota> simeray, it depends on what you want to test. You don't need to test the websocket implementation itself, that's already covered in stdlib specs. But you might still want to have some kind of integration test which includes going through the network stack to ensure that everyting's really working as expected. But it's probably not necessary to run all specs this way. But you should be able to mock a
<FromGitter> ... websocket connection by creating a `HTTP::Websocket` instance with an IO. This constructor is not documented, though and I can't tell if everything works as expected.
<FromGitter> <bajro17> is anyone plan to record course for udemy or some other learning site for crystal
<FromGitter> <bajro17> or please tell me if you know some
<FromGitter> <r00ster91> Did you try the official docs yet? https://crystal-lang.org/reference/overview/
<FromGitter> <bajro17> Yes I try but I would like to watch and to get better explain
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
lucasb has joined #crystal-lang
simerax has quit [Remote host closed the connection]
trashhalo[m] has quit [Remote host closed the connection]
olbat[m] has quit [Remote host closed the connection]
bobmolson[m] has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> straw poll time: Opinions on which is your preferred syntax
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c8d19e08aa66959b61e3a40]
<FromGitter> <Blacksmoke16> benefit of 1 is its more explicit and dont have to worry about another file. benefit of 2 is you wouldnt need a code change to change middleware, and could have env specific configs
<FromGitter> <r00ster91> I vote for number 1. I think this can be easily in one file.
<FromGitter> <Blacksmoke16> well assume the config file would be used for other similar things
<FromGitter> <Blacksmoke16> but yea, this specific example its a bit overkill. Was thinking this + CORS + db stuff maybe + etc :shrug:
trashhalo[m] has joined #crystal-lang
<FromGitter> <Simerax> is there a way to get the *LINE* and *FILE* inside a function from the caller perspective? Im Tinkering with the Logger::Formatter, i would like to see in my Logger messages the line and file on which the log was written. for example inside my File "foo.cr" i call log.error("something happend") on line 40 then i would like to get something like "something happend in file foo at line 40". I did try using *LINE*
<FromGitter> ... and *FILE* inside the Logger::Formatter.new but this of course gives me the line on which i created the formatterstring
<FromGitter> <Simerax> well line and file should have __ around them
<FromGitter> <Simerax> i just thought about it its probably not as simple as getting the caller...the caller is probably somewhere inside the Logger Module so this would not be enough
<FromGitter> <Simerax> Is there a simple way of doing this or do i have to write a wrapper around Logger?
DTZUZO has quit [Ping timeout: 245 seconds]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> :shrug:
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
DTZUZO has joined #crystal-lang
f1refly has joined #crystal-lang
f1refly has quit [Quit: WeeChat 1.6]
f1refly has joined #crystal-lang
rohitpaulk has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <bararchy> Is there any other Diff shard then this one: https://github.com/MakeNowJust/crystal-diff ?
<FromGitter> <sergiotapia> Is there a website I can follow to see if Crystal support windows?
<FromGitter> <sergiotapia> Similar to Rust's arewewebyet, but maybe arewewindowsyet?
<FromGitter> <bararchy> Isn't RUST working on Windows?
<FromGitter> <sergiotapia> Yes it is
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/5430 would be your best bet
<FromGitter> <sergiotapia> Thanks @Blacksmoke16 - Woah it's like 60% done?!
<FromGitter> <Blacksmoke16> getting there albeit very slowly :p PRs are welcome ;)
<FromGitter> <sergiotapia> I wish I could help, I know zero about language programming
<FromGitter> <bararchy> the good things about Crystal is that it's written in Crystal :) so it's just like writing another shard TBH
<FromGitter> <Blacksmoke16> just a pretty complex one hehe
<FromGitter> <bararchy> ^ true hahah
<FromGitter> <Blacksmoke16> saw your comment btw
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c8d7eb32f6ded0abbf4ee19]
<FromGitter> <Blacksmoke16> is what im thinking the defaults are going to be
<FromGitter> <bararchy> where `mydomain` is the actual domain of the site running right?
<FromGitter> <Blacksmoke16> well i wouldnt really know the domain they would be using
<FromGitter> <Blacksmoke16> they would have to go in an update it to whatever their domain is or `*` if they so choose
<FromGitter> <bararchy> Maybe you can "raise" and issue if the CORS module is enabled and the allow_origin is not defined?
<FromGitter> <Blacksmoke16> would be visible that way yea
<FromGitter> <Blacksmoke16> default to empty string and raise if blank
<FromGitter> <Blacksmoke16> i could go with that
<FromGitter> <bararchy> sounds secure and also not too much of a pain, as in, if you use CORS there is no reason to not set this up
<FromGitter> <Blacksmoke16> yea for sure
<FromGitter> <Blacksmoke16> nice, never saw this error before
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c8d80ef2fb6800d803011e3]
<FromGitter> <bararchy> Oh wow lol
fullforce has left #crystal-lang [#crystal-lang]
<FromGitter> <sergiotapia> I'm a firm believer of fate and synchronicity. Many examples of it in my life. Since yesterday I've been weighing Rust, Nim and Crystal - flipflopping between them. This morning I got an email for Cirque Do Soleil Crystal lol. And just now, my wife turned on the TV to Cake Wars and the guest baker is named...Crystal. ⏎ ⏎ I think my choice is made. Time to buy the Crystal book.
<FromGitter> <Blacksmoke16> sounds like a plan
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/ reading this would also be a good idea
<FromGitter> <Blacksmoke16> well i kinda realized ill have to do my route checking *after* the cors check, otherwise would 404 on OPTIONS
<FromGitter> <ryanstout> question if anyone has a sec. Is there a way to get the AST directly in a crystal macro and do transforms, then return a new AST?
<FromGitter> <Blacksmoke16> transforms as in?
<FromGitter> <ryanstout> For example building a DSL as a marco.
<FromGitter> <ryanstout> ^ I mean passing code written in a DSL to a macro
<FromGitter> <ryanstout> I might be able to accomplish the same thing another way, was just curious if you could get the AST directly
<FromGitter> <Blacksmoke16> well when in macro land you have access to the AST nodes, https://crystal-lang.org/api/0.27.2/Crystal/Macros/ASTNode.html which are specials types
<FromGitter> <Blacksmoke16> i.e. `StringLiteral` vs `String`
<FromGitter> <Blacksmoke16> do you have an example of what you're trying to do
<FromGitter> <ryanstout> yea, sorry I don't have a more specific example. Just trying to understand whats possible. I read that args were passed in as ASTNodes. Is it possible to call a macro with what looks like a block and get the AST for the block in the macro definition?
<FromGitter> <ryanstout> @Blacksmoke16 thanks for the help btw
<FromGitter> <Blacksmoke16> can do stuff like https://play.crystal-lang.org/#/r/6ify
<FromGitter> <Blacksmoke16> or like https://play.crystal-lang.org/#/r/6ig1
<FromGitter> <Blacksmoke16> etc
<FromGitter> <ryanstout> ok, cool. Yea, I read all the docs on macro's. It's not possible to pass a block to a macro though? (forgive my noobness) Thinking something like this (fictitious example that adds benchmarking timings in): ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c8d8c04f3dbbd230c6a436f]
<FromGitter> <Blacksmoke16> no but could just use a method called `benchmark` and use your macro logic in that method?
<FromGitter> <ryanstout> ok, so ```benchmark``` would be a normal method? Would llvm inline that extra call? (not that it matters, just curious)
<FromGitter> <Blacksmoke16> that i don't know
<FromGitter> <Blacksmoke16> `When using blocks with yield, the blocks are always inlined: no closures, calls or function pointers are involved. `