ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.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
<postmodern> oprypin, ugh yeah, it seems awkward to have to define a constant so your data doesn't get duplicated on each call, but more weird to have to also define a class_getter
<postmodern> although it appears that crystal's class variables are slightly better than ruby's. in crystal the class-variable is bound to the meta-class to the base class
<postmodern> question, what is an app wrt `crystal init app ...`?
<postmodern> is it supposed to be a CLI util or a server?
<oprypin> postmodern, the distinction is "lib" (made to be a source dependency for other project) and "app" (made to be compiled to an executable)
dwdv has quit [Ping timeout: 265 seconds]
<postmodern> oprypin, hmm weird that apps don't have a bin/<name>.cr file or bin/ dir
<oprypin> postmodern, they do after `shards build`
<postmodern> ah ha
<postmodern> oprypin, is it possible for a crystal project to be both? seems like the init command needs options for --lib and --app
<oprypin> postmodern, i have no known cases
<oprypin> i think any boilerplate is a failing so i start from scratch anyway
<postmodern> i'd rather not waste time writing a README or editing an existing one.
<postmodern> it's been a huge productivity benefit to me to just hit the ground running
<oprypin> glad to hear :>
<postmodern> problem is you need to draw out the use-cases for a generator. if you're not generating a CLI app, then you don't need a Usage/Synopsis
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<postmodern> so basically you can't use generic types in constants or class methods in an abstract class, because the type isn't known yet
MasterdonX has quit [Read error: Connection reset by peer]
MasterdonX has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
darkstardevx has joined #crystal-lang
hsh has joined #crystal-lang
<hsh> I haven't used Crystal for a year or so and I assume many things changed :). IIUC `JSON.mapping` is to be replaced with `JSON::Serializable`. Does this mean `JSON.mapping` is deprecated?
dwdv has joined #crystal-lang
_ht has joined #crystal-lang
darkstardevx has quit [Ping timeout: 240 seconds]
darkstardev13 has quit [Ping timeout: 240 seconds]
darkstarx has joined #crystal-lang
ravenx has joined #crystal-lang
<Andriamanitra> do you guys use something similar to nodemon when doing web stuff with crystal? a quick google search found a crystal tool called guardian but that didn't seem to work
<repo> Andriamanitra: yeah guardian, sentry, paladin, you name it
<Andriamanitra> repo: what's paladin (google is unsurprisingly unhelpful)? guardian i couldn't get to work at all on my system, and sentry doesn't seem to be quite what i'm looking for
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 260 seconds]
DTZUZU2 has joined #crystal-lang
DTZUZU has quit [Ping timeout: 272 seconds]
sorcus has quit [Quit: WeeChat 2.7.1]
<yxhuvud> oprypin: was it you or RX14 that was doing the gitter bridge? It seems down..
<Stephie> it was oprypin iirc
gangstacat has quit [Quit: Ĝis!]
juanfra_ has quit [Ping timeout: 240 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
sz0 has joined #crystal-lang
juanfra_ has joined #crystal-lang
gangstacat has joined #crystal-lang
sorcus has joined #crystal-lang
FromGitter has joined #crystal-lang
<oprypin> did crystal change to forcibly buffer stdout even if it's not in a tty -_-
<oprypin> or stderr
<FromGitter> <Blacksmoke16> could prob do like `STDERR.sync = false`
<oprypin> yea but why
<oprypin> wait, what i said makes no sense
<oprypin> what i'm getting at is, previously the logs that i was seeing in systemd were not buffered, and now they are
<oprypin> and buffered means i get the log lines in batches with wrong timestamps
<oprypin> and yes, the IRC<->Gitter bridge has been down. sorry about that :(
<FromGitter> <dscottboggs_gitlab> HM
<FromGitter> <dscottboggs_gitlab> interesting
<FromGitter> <dscottboggs_gitlab> crystal-lang.org/api/IO/Buffered.html#sync=(sync)-instance-method
<oprypin> `$ crystal eval 'pp! STDOUT.sync?' | cat`
<oprypin> `STDOUT.sync? # => false`
<oprypin> maybe the change is correct. i get that behavior in Python as well
<FromGitter> <dscottboggs_gitlab> wait, what version of crystal are you on?
<oprypin> `crystal eval 'loop do; STDERR.puts rand(100000); sleep 0.01; end' 2>&1 | cat` is batched
<oprypin> `python -c $'import random, time\nwhile True:\n print(random.randrange(100000))\n time.sleep(0.01)' 2>&1 | cat` is batched just as well
<oprypin> dscottboggs_gitlab, my command is different, with `| cat`. version is probably one vehind
<FromGitter> <dscottboggs_gitlab> ah, interesting, you're right!
<FromGitter> <dscottboggs_gitlab> so it looks like @Blacksmoke16 is right (well, backwards, but he had the right idea lol). You need `STDOUT.sync = true`
<oprypin> i wish `flush_on_newline` was still a thing
<oprypin> i think `flush_on_newline` would be much more performant than `sync`
<FromGitter> <dscottboggs_gitlab> that change happened in 0.28.0 FYI
<FromGitter> <dscottboggs_gitlab> hm. I'm sure it wouldn't be too hard to reimplement `flush_on_newline`, why was it removed?
<FromGitter> <dscottboggs_gitlab> https://github.com/crystal-lang/crystal/pull/7470 it's not super clear to me why it was removed
<oprypin> agh what's worse, the flushnig happens in a wrong order
_ht has quit [Ping timeout: 248 seconds]
<oprypin> if an exception happens, that one is printed first, and after that stdout from before is flushed
<FromGitter> <dscottboggs_gitlab> oof
_ht has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<oprypin> thanks, i added `STDOUT.sync = true; STDERR.sync = true` and it's good now
<oprypin> i wonder if that should be the solution for every daemon application
<FromGitter> <dscottboggs_gitlab> woo
<FromGitter> <dscottboggs_gitlab> idk i think it depends
<FromGitter> <dscottboggs_gitlab> i just wrote a logger for an app i'm working on that flushes manually after each event, that's fine for me
sorcus has quit [Quit: WeeChat 2.7.1]
sorcus has joined #crystal-lang
<FromGitter> <dburnsii> Is there a way to define dependencies specifically for running tests in the shard.yml?
<FromGitter> <dburnsii> Similar to defining `group :test` in a Gemfile?
<FromGitter> <Blacksmoke16> put them under dev deps and only require them in `spec_helper.cr`?
<FromGitter> <dburnsii> Makes sense, that's what I was thinking. Thanks.
_whitelogger has joined #crystal-lang
_ht has quit [Remote host closed the connection]
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#865e1a7 (ci/fix32bits - Use flag?(:i386) instead of i686): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/656454481
<FromGitter> <asterite> ugh, stodut sync change strikes again
DTZUZU2 has quit [Ping timeout: 260 seconds]
DTZUZU2 has joined #crystal-lang
DTZUZU2 has quit [Ping timeout: 240 seconds]
DTZUZU2 has joined #crystal-lang
<FromGitter> <smalls12> I'm building an app, which uses a shard which has an object sitting under the src folder but I can't seem to include it for some reason
<FromGitter> <smalls12> app/src/app.cr uses shard/src/object.cr
<FromGitter> <smalls12> inside app.cr ⏎ ⏎ ```object = Object.new``` [https://gitter.im/crystal-lang/crystal?at=5e599d9a3ca0375cb38f4591]
<FromGitter> <smalls12> keeps complaining it cant find it
<FromGitter> <dscottboggs_gitlab> did you `require "shard/src/object"` or `"./shard/src/object"` depending?
<FromGitter> <Blacksmoke16> it would just be `shard/object` assuming the shard is called `shard` and there is an `object.cr` file under `src/`
<FromGitter> <Blacksmoke16> is probably not a good idea to have an `Object` type, that would deff conflict with the stdlib type...
<FromGitter> <dscottboggs_gitlab> yeah, you're right. and if it's actually called `Object` that's not gonna work
<FromGitter> <dscottboggs_gitlab> and your code will all break
<FromGitter> <smalls12> @Blacksmoke16 it was adding shard/object
<FromGitter> <Blacksmoke16> it *could* work but would have to be namedspaced
<FromGitter> <smalls12> thanks for that
<FromGitter> <dscottboggs_gitlab> unless it's actually like `Shard::Object`, vs `::Object` but that's still sketch
<FromGitter> <Blacksmoke16> yea
<FromGitter> <smalls12> its not named Object, poor example
<FromGitter> <Blacksmoke16> ah ok
<FromGitter> <watzon> You can also tecnically include directly from `/lib`, but that's not the best idea
<FromGitter> <jwoertink> Anyone know if there's a method on TypeDeclaration that would tell me if `type` is a Metaclass?
<FromGitter> <jwoertink> I guess just `dec.type.is_a?(Metaclass)`?
<FromGitter> <Blacksmoke16> Metaclass?
<FromGitter> <jwoertink> like if you have a macro `run klass : Thing.class`
<FromGitter> <jwoertink> I thought I had saw a method like `.metaclass` or `.metaclass?` but I think just using `is_a?` works fine instead
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <Blacksmoke16> id make sure that doesnt also return true for other stuff
<FromGitter> <jwoertink> good call
<FromGitter> <stronny> is it possible to fill StaticArray from a slice?
<oprypin> stronny, yea if it's the same number of bytes known at compile time, why not
<FromGitter> <stronny> say I have a string from a user and I want 8 first bytes in a SA
<FromGitter> <stronny> nevermind, I'll just do C-like `buf.size.times {|i| buf[i] = str.char_at i}` or smth