ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.4 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
Raimondi has quit [Write error: Broken pipe]
matp has quit [Excess Flood]
Raimondi has joined #crystal-lang
bjz has quit [Max SendQ exceeded]
bjz has joined #crystal-lang
Philpax has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
Philpax has quit [Ping timeout: 268 seconds]
bjz has quit [Ping timeout: 256 seconds]
bjz has joined #crystal-lang
ome has joined #crystal-lang
kulelu88 has quit [Quit: Leaving]
onethirtyfive has quit [Remote host closed the connection]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
onethirtyfive has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
vikaton has quit [Quit: Connection closed for inactivity]
mark_66 has joined #crystal-lang
ome has quit [Quit: Connection closed for inactivity]
lacour has quit [Quit: Leaving]
hako has quit [Ping timeout: 250 seconds]
gloscombe has joined #crystal-lang
matp has joined #crystal-lang
Philpax has joined #crystal-lang
mhib has joined #crystal-lang
humlereader has joined #crystal-lang
_whitelogger has joined #crystal-lang
p0p0pr37 has joined #crystal-lang
<FromGitter> <International> is there any way of mocking a call to `abort` ?
<FromGitter> <sdogruyol> that's a tough one
<FromGitter> <sdogruyol> anyone here who can help me with parsing this xml? https://gist.github.com/sdogruyol/50ec88258a6c008af31cb097441f6436
<FromGitter> <sdogruyol> i wanna retrieve a:ReturnCode but getting a sigfault lol
<FromGitter> <sdogruyol> invalid mem access
<RX14> that probably shouldnt be happening
<FromGitter> <sdogruyol> think so
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
gloscombe has quit [Read error: Connection reset by peer]
<FromGitter> <luislavena> @sdogruyol do you know if Ruby's nokogiri or ox can parse it properly?
<FromGitter> <International> found this thread about debugging: https://groups.google.com/forum/m/#!topic/crystal-lang/gRf-yDNdZ-Y , after hitting a breakpoint, is there a easy way to inspect variables?
pawnbox has quit [Read error: Connection reset by peer]
gloscombe has joined #crystal-lang
pawnbox has joined #crystal-lang
<FromGitter> <International> i'm checking out webmock.cr , and i'm not sure whether i ran into a bug in the library, or if i'm doing something wrong, and adding puts statements everywhere is tiresome :D
pawnbox_ has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
<FromGitter> <sdogruyol> @luislavena kinda
<FromGitter> <sdogruyol> Nokogiri also fails with namespaces
<FromGitter> <luislavena> @International recently debugging was improved (you will need to build crystal locally), find more details (with debugging examples) here: https://github.com/crystal-lang/crystal/pull/3473 and here: https://github.com/crystal-lang/crystal/pull/3469
<FromGitter> <International> thank you @luislavena , i'll give it a try!
<FromGitter> <johnjansen> @sdogruyol if you have an xml doc with namespaces, try `doc.xpath_nodes("//*[local-name()='Status']”)` and see if that works
<FromGitter> <International> @luislavena , I tried the examples, and with ints the values are displayed, when doing a `info locals`, but with other objects, it seems only the address is displayed, like : `$1 = (struct String *) 0x1003dde70` . Do you know how I could inspect strings, or other objects?
<FromGitter> <International> it seems that doing something like `p *my_string` is a good starting point
<FromGitter> <sdogruyol> @johnjansen thanks for the tip
Raimondi has quit [Ping timeout: 260 seconds]
mhib_ has joined #crystal-lang
mhib_ has quit [Client Quit]
balotelli266 has joined #crystal-lang
balotelli266 has quit [Remote host closed the connection]
<FromGitter> <luislavena> @International not sure you can inspect complex objects *yet*, I haven't tried it (I'm more a *puts debugger* than anything :smile:)
mhib has quit [Quit: Leaving]
pawnbox_ has quit [Ping timeout: 252 seconds]
pawnbox has joined #crystal-lang
gloscombe has quit [Ping timeout: 250 seconds]
gloscombe has joined #crystal-lang
Raimondi has joined #crystal-lang
<FromGitter> <johnjansen> anyone know if/how you can get the class of a caller
<crystal-gh> [crystal] kostya opened pull request #3493: allow rand with zero value (master...rand_zero) https://git.io/vXOR0
<BlaXpirit> johnjansen, uhhhh it would have to be a macro
<BlaXpirit> what comes to mind is a macro that outputs `\{{@type}}`
<FromGitter> <johnjansen> thats what i was thinking, which would be ok … im just considering a better log formatter, one that is A) structured and B) includes the caller so the messages are more consumable from log analyzers …
Raimondi has quit [Ping timeout: 244 seconds]
Raimondi has joined #crystal-lang
<FromGitter> <citizen428> @luislavena thanks for explaining... my problem is that i want to test that calling my macro defines a new module, so defining it beforehand somewhat defeats the purpose
mark_66 has quit [Remote host closed the connection]
Raimondi has quit [Ping timeout: 244 seconds]
am_ has joined #crystal-lang
<FromGitter> <johnjansen> @citizen428 consider this, if your module doesnt get defined (by calling your macro) one of 2 things will likely happen, A) your code wont compile, since macro’s run at compile time and must generate valid code OR B) your module will be defined, and will therefore be testable. this seems sensible to me, someone else may disagree?
am_ has quit [Ping timeout: 250 seconds]
<FromGitter> <jwoertink> Is there a way to run a filter on specs like `:focus`?
<FromGitter> <johnjansen> do you mean run a subset of specs?
<FromGitter> <luislavena> @citizen428 invoke your macro at the top of your spec file, in the class/module you're expected it to work, write a spec that check that sample gets the module in it
<FromGitter> <luislavena> sometimes just a `typeof(MyModule::ModuleFromMacro)` in a spec will be enough to check that the macro worked.
Philpax has quit [Ping timeout: 268 seconds]
<FromGitter> <jwoertink> @johnjansen Yeah. Like with RSpec, you can set filters to say only run specific specs.
<FromGitter> <johnjansen> i dont see anything in the source, but you could certainly use an ENV var and a condition to get very similar behaviour
<FromGitter> <johnjansen> @jwoertink i “think” you could patch describe to take filters https://github.com/crystal-lang/crystal/blob/7f82f79bd1e3a7a1a73607e35c0662906736f1f8/src/spec/context.cr#L148
<FromGitter> <jwoertink> That's what I'll probably do then. Thanks
<FromGitter> <johnjansen> good luck, let me know how you get on … id have a hack at it but i should do some real work ;-)
vikaton has joined #crystal-lang
lacour has joined #crystal-lang
gloscombe has quit [Remote host closed the connection]
matp_ has joined #crystal-lang
matp has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
Renich has joined #crystal-lang
bazaar has quit [Ping timeout: 265 seconds]
bazaar has joined #crystal-lang
pawnbox has joined #crystal-lang
<FromGitter> <redcodefinal> Hi guys! New to Crystal, was recently looking at crystal again after letting it mature for a while, and I wanted to get some opinions on somethings I was looking to try. For starters, I have a pretty heavy Ruby background, I really enjoy the MetaProgramming aspects of Ruby. I am mainly looking at Crystal to port and speed up a project I wrote called [isometric-world-generator]
<FromGitter> ... (https://github.com/redcodefinal/isometric-world-generator). If you would like to view pictures of the project, you can view them [here](http://broken-kami.tumblr.com/). Essentially the project is a DSL for building Minecraft style world generation. Letting you do things like layer generation,etc. The DSL portion of it is the most important part becau ... [https://gitter.im/crystal-lang/crystal?at=5818f171c3569a036e4625ed]
pawnbox has quit [Ping timeout: 244 seconds]
<FromGitter> <redcodefinal> Also ⏎ 5. Is there a way to search shards? ⏎ 6. Any good image manipulation in Crystal (like ruby's rmagick library)
<BlaXpirit> some of your questions involved "... like Ruby" which I cannot answer without additional information
<FromGitter> <redcodefinal> @BlaXpirit Ruby has an ImageMagick implementation called rmagick. Really I only use it to combine a bunch of single textures into a large sheet to improve speed. Is there a similar shard for Crystal?
<BlaXpirit> probably not. just basic pixel manipulation and image format implementations
<BlaXpirit> or you can manipulate textures with opengl and opengl-like APIs
<FromGitter> <redcodefinal> Shoot, not a deal breaker, I can still load each texture in it's own single instance
<FromGitter> <redcodefinal> Here is an example of the kind of combining I'm doing, basically baking a spritesheet https://github.com/redcodefinal/isometric-world-generator/blob/master/content/forest/blocks.png
<BlaXpirit> redcodefinal, hm yeah, CrSFML could do that but it's an annoying dependency
<BlaXpirit> nothing wrong with the pixel-manipulation-only library https://github.com/l3kn/stumpy_png . just copy those things pixel by pixel
<FromGitter> <redcodefinal> @BlaXpirit I figured CrSMFL was going to be my goto library
<FromGitter> <redcodefinal> @BlaXpirit Yeah I'm more than comfortable using stumpy_png to do a pixel by pixel copy.
<FromGitter> <redcodefinal> @BlaXpirit What about instance_exec?
Renich has quit [Quit: leaving]
<BlaXpirit> like i said, i don't know what that is because presumably it's just something that exists in Ruby
<FromGitter> <redcodefinal> Oh, it essentially lets you run a block as if it is inside an instance.
<BlaXpirit> redcodefinal, you can make an object that has a method that allows running things as if it is inside the instance. https://crystal-lang.org/docs/syntax_and_semantics/capturing_blocks.html#with-yield
<FromGitter> <redcodefinal> ```code paste, see link``` ⏎ ⏎ In this example @x is private. [https://gitter.im/crystal-lang/crystal?at=5818f79dc3569a036e464802]
<BlaXpirit> `class A; def instance_exec; with self yield; end; end; A.new.instance_exec { call_method_in_a }`
<BlaXpirit> but i'm not sure about private in particular
<FromGitter> <redcodefinal> @BlaXpirit oo interesting
<FromGitter> <redcodefinal> How does `with` work?
shawn42 has joined #crystal-lang
<BlaXpirit> i dunno, `with` is probably not a thing by itself, just this construct `with ... yield` (linked above)
<BlaXpirit> > The default receiver within a captured block can't be changed by using with ... yield
<BlaXpirit> hm it's an even weirder piece of documentation
<FromGitter> <redcodefinal> hmm
<BlaXpirit> but yeah, this is `yield` which changes the default receiver
<FromGitter> <redcodefinal> I guess I'll just have to rewrite how my layer logic works but so far everything seems doable'
<FromGitter> <redcodefinal> Thanks for the support @BlaXpirit and writing CRSMFL so I can do this
<FromGitter> <redcodefinal> Looks like I am going to have to make a Perlin Noise library
<BlaXpirit> great project to familiarize yourself
<shawn42> hey guys, quick question: if I have some JSON that is an array of arrays of ints.. why doesn't JSON.parse(json) as Array(Array(Int32)) work?
<FromGitter> <redcodefinal> @BlaXpirit Yeah I am trying to decide whether or not to do the C bindings directly from [Spooners](https://github.com/Spooner/ruby-perlin/blob/master/ext/perlin) implementation or to port his C code into Crystal and do it that way.
<shawn42> <-- total crystal newb
<BlaXpirit> redcodefinal, i'd go for porting code. i'm not aware of the more complex implementations. the example on wikipedia seems very simple
<BlaXpirit> shawn42, because JSON.parse returns a magical JSON::Any object
<BlaXpirit> which is certainly not an array
<BlaXpirit> shawn42, well this got out of hand quickly... https://play.crystal-lang.org/#/r/1d4z
mhib has joined #crystal-lang
<shawn42> BlaXpirit: I'm seeing other examples that seem to cast directly to say an Array or Hash
<BlaXpirit> possibly avoid making this array if an array is not what you're looking for. might just access this magical Any instead
<BlaXpirit> shawn42, what examples?
<shawn42> thanks for the snippet
<shawn42> SO posts
<FromGitter> <johnjansen> haha @BlaXpirit thats hysterical
<shawn42> I'll read up on the Any docs
mhib has quit [Client Quit]
mhib has joined #crystal-lang
<FromGitter> <redcodefinal> @BlaXpirit hey is play.crystal.com working for you? When I run any code it sends me right back to the editor without showing me output
<FromGitter> <johnjansen> seems fine to me @redcodefinal
<FromGitter> <cjgajard> @redcodefinal something I have to open them in an incognito window
<BlaXpirit> redcodefinal, :( yeah this bug has been getting real annoying lately
<BlaXpirit> clear cookies
mhib has quit [Quit: Leaving]
<FromGitter> <redcodefinal> @BlaXpirit thanks fixed it
<FromGitter> <redcodefinal> @BlaXpirit tested the instance_exec, looks like that will work for what I need, thanks for the help :smile:
<FromGitter> <iDev0urer> Is there any way to create an `XML::Node` without parsing a XML string? Every overload for `XML::Node.new` takes a pointer to something from `LibXML`
<FromGitter> <iDev0urer> Tried this, but I get `exit status 11` ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5819063783a2008d22fc6d78]
<BlaXpirit> yeah, trying random stuff in combination of an unsafe method `pointerof` will do that
<FromGitter> <iDev0urer> Haha, I figured. Any idea how to create a `XML::Node`?
<FromGitter> <iDev0urer> I would really rather not have to do it by stitching strings together
<BlaXpirit> i don't think it can be done with the current bindings
<FromGitter> <iDev0urer> Well that bites
<FromGitter> <johnjansen> how about parsing a string and then setting the attributes on the node
<BlaXpirit> heh yeah good idea
<BlaXpirit> problem is i don't think you can set attributes
<FromGitter> <iDev0urer> so something like this? `node = XML.parse("<hello />").children[0]`
<FromGitter> <iDev0urer> That works in theory, but feels extremely hacky
<FromGitter> <iDev0urer> And like @BlaXpirit said, I don't think you can set attributes
<FromGitter> <iDev0urer> I think the `XML` module just needs some TLC
<FromGitter> <johnjansen> </> is enough
<FromGitter> <johnjansen> I'm in the car so I can't look at the node source, but I'd be surprised if you can't set attributes
<FromGitter> <iDev0urer> The problem is that attributes are also nodes and have the same inherent problem. `Node` also doesn't have an `#attributes=(attributes)` method
bjz has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
bjz has joined #crystal-lang
Fichtenstein has quit [Quit: Fichtenstein]
kulelu88 has joined #crystal-lang
<FromGitter> <redcodefinal> Does anyone know where the docs are for the getter setter property methods are?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <redcodefinal> @johnjansen thanks man I was having trouble finding where it was in the docs
<BlaXpirit> redcodefinal, https://crystal-lang.org/api/0.19.4/Object.html#setter%28%2Anames%29-macro
<FromGitter> <johnjansen> or you could read the docs ;-) thanks @BlaXpirit
justinmcp has quit [Remote host closed the connection]
justinmcp has joined #crystal-lang
justinmcp has quit [Read error: Connection reset by peer]
justinmcp has joined #crystal-lang
onethirtyfive has quit [Remote host closed the connection]
shawn42 has quit [Quit: Connection closed for inactivity]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 252 seconds]
Raimondi has joined #crystal-lang