jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
willl has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 244 seconds]
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vTNKJ
<crystal-gh> crystal/master b0906e5 Ary Borenszweig: Make Tuple#map return a tuple. Fixes #683. Use tuple type restrictions in Char#in_set? and String#squeeze.
<crystal-gh> crystal/master 856a1f1 Ary Borenszweig: Allow math operations in macros
<travis-ci> manastech/crystal#2372 (master - 856a1f1 : Ary Borenszweig): The build passed.
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
waterlink1 has joined #crystal-lang
waterlink has quit [Ping timeout: 265 seconds]
havenwood has joined #crystal-lang
strcmp1 has quit [Remote host closed the connection]
strcmp1 has joined #crystal-lang
waterlink1 has quit [Ping timeout: 272 seconds]
JBat has joined #crystal-lang
BlaXpirit has joined #crystal-lang
strcmp2 has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
strcmp1 has quit [Ping timeout: 245 seconds]
sandelius has joined #crystal-lang
sandelius has quit [Client Quit]
sandelius has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
zz_Cidan is now known as Cidan
strcmp2 has quit [Ping timeout: 264 seconds]
unshadow has quit [Quit: leaving]
JBat has joined #crystal-lang
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
unshadow has joined #crystal-lang
ponga has joined #crystal-lang
<unshadow> So, I got a small programing hardle that I need to pass, I have a file with text, I want to parse the file and build a box around it, for that I check which line is the longest, and use that as the spacer for all the other lines, but it still looks wierd (not sure why)
Cidan is now known as zz_Cidan
ponga has quit [Quit: Leaving...]
DerisiveLogic has quit [Ping timeout: 240 seconds]
sandelius has joined #crystal-lang
strcmp1 has joined #crystal-lang
<jhass> >> "foo".rjust(5)
<DeBot> jhass: # => " foo" - http://carc.in/#/r/fy
<jhass> >> "foo".ljust(5)
<DeBot> jhass: # => "foo " - http://carc.in/#/r/fz
<jhass> >> "| #{"foo".ljust(5)} |"
<DeBot> jhass: # => "| foo |" - http://carc.in/#/r/g0
<jhass> #{} is efficient, it's rewritten to String.build
<unshadow> What does the (5) means ? how much spaces from the aligned side ?
<jhass> >> "foo".rjust(5).size
<DeBot> jhass: # => 5 - http://carc.in/#/r/g1
<jhass> >> "foobar".rjust(5).size
<DeBot> jhass: # => 6 - http://carc.in/#/r/g2
<jhass> >> "foobar".rjust(10).size
<DeBot> jhass: # => 10 - http://carc.in/#/r/g3
BlaXpirit has joined #crystal-lang
<crystal-gh> [crystal] jhass opened pull request #695: Add values_at (master...values_at) http://git.io/vTxmx
<unshadow> I think crystal deps should also check if the repos under .deps has been changed and update them, or, to have a "deps --update" options to do that
<jhass> there's crystal deps update, isn't there?
<unshadow> Oh, is there is... sorry it wasn't in the --help nor deps --help menu
<unshadow> jhass, Damn.. I can't get the box thingy to align :| I even exported it to an external lib for easier testing https://github.com/bararchy/text-parser
<unshadow> Got any ideas ?
<unshadow> I tried ljust and rjust... I can't figure out why this isn't keeping the proportions as it should
<jhass> ljust wants the total width
<jhass> pass just max_size (+1)
<jhass> Also not sure why you do the to_s?
<jhass> also why .bytesize over .size?
<jhass> not that it should make a diff for all ascii
<unshadow> to_s or else its a colorize class, bytesize so if UTF8 I can still compute it
<jhass> I'd do it in parse_line_signs then
<unshadow> to return line.to_S
<unshadow> you mean ?
<unshadow> thats a good idea too :)
<jhass> missing require "colorize"
<unshadow> fixed :)
<jhass> oh, I see you're french :P
<unshadow> woot french ?
<jhass> you plenk
<unshadow> Some one already told me I plenk ... what does that means ?? something about spaces after "!" or something right ?
<jhass> anyway, so the issue is that it counts the color codes you insert
<unshadow> Oh........ this is a problem
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<unshadow> can I have colorize.red.size ? for just the encoding length ? or should I create a before and after size ?
<unshadow> maybe .colorize.uncolorize.size
sandelius has joined #crystal-lang
<jhass> unshadow: http://paste.mrzyx.de/ppidna6gc some ideas
<unshadow> It's beautiful ^^ I have a long way to go ha ? anyway, this looks awsome, would you mind PR ?
<jhass> yeah, can't be bothered :P
<jhass> the center doesn't work well yet
<unshadow> maybe we should try printf adjusments, like "printf "%-15s %-15s %-19s %-14s %s\n" % ["", "Version", "Cipher", " Bits", "Vulnerability"]"
<unshadow> for example
<unshadow> from another project where I needed to print text in a specific format
<jhass> I think that just uses r/ljust in crystal in fact
<unshadow> Oh.
<jhass> oh, I'm dumb, it's + not -
<jhass> .ljust(line_size / 2 + text.size / 2)
<jhass> eh, rjust
<jhass> options = $1.split(",")
<jhass> line = center("(#{options[0]}) (#{options[1]})", max_size + 1).colorize.yellow
<unshadow> nice idea, center()
<jhass> max_size = (data.strip.lines.map {|line| line.gsub(/##\w+$/, "") }.max_of &.size) - 1
<jhass> I like the unicode box drawing chars btw
<jhass> why do use \r\n btw?
<unshadow> \r\n so it will parse ok on Windows cmd (if you only use \n all hell breaks loose)
<unshadow> what do you mean by unicode box chars ?
<unshadow> also, "in ./libs/text-parser/text-parser.cr:67: undefined method 'center'"
<unshadow> line = center("(#{options[0]}) (#{options[1]})", max_size + 1).colorize.yellow
<jhass> that's what I'd do I think
<jhass> oh, missing padded on 42
<jhass> box_width = lines.max_of &.gsub(/##\w+$/, "").size
<unshadow> I'm using your lib, it seems to not print at all, http://screencloud.net/v/2Cg8
<unshadow> Oh, STDOUT
<unshadow> sorry !!!
<unshadow> This looks cool, Thanks so much jhass !
<unshadow> Is there a way to tell io to default to STDOUT unless specificly told not to ? like io=StringIO.new=STDOUT or something ?
<jhass> foo=bar defines a default argument
<jhass> io=StringIO.new -> parse(data, StringIO.new)
chrisseaton has left #crystal-lang [#crystal-lang]
strcmp1 has quit [Ping timeout: 240 seconds]
<unshadow> I mean, if parse(data) assume STDOUT as StringIO
<unshadow> also, I hope you dont mind that I added you as a contributer to the README :)
<jhass> >> def foo(a=1); p a; end; foo
<DeBot> jhass: 1 - more at http://carc.in/#/r/g8
<jhass> >> def foo(a=1); p a; end; foo(2)
<DeBot> jhass: 2 - more at http://carc.in/#/r/g9
<jhass> >> def foo(a=StringIO.new); p a; end; foo
<DeBot> jhass: #<StringIO:0x9FA8F90 @buffer=Pointer(UInt8)@0x9FACF78, @bytesize=0, @capacity=64, @pos=0> - more at http://carc.in/#/r/ga
<jhass> >> def foo(a=StringIO.new); p a; end; foo(STDOUT)
<DeBot> jhass: CFileIO(@file=Pointer(Void)@0xB75E3E80) - more at http://carc.in/#/r/gb
<unshadow> >> STDOUT.is_a?(StringIO)
<DeBot> unshadow: # => false - http://carc.in/#/r/gc
<unshadow> >> STDOUT.class
<DeBot> unshadow: # => CFileIO - http://carc.in/#/r/gd
<unshadow> >> StringIO.class
<DeBot> unshadow: # => Class - http://carc.in/#/r/ge
<unshadow> >> StringIO.new == STDOUT
<DeBot> unshadow: # => false - http://carc.in/#/r/gf
<unshadow> >> STODOUT.print "hello"
<DeBot> unshadow: Error in line 4: undefined constant STODOUT (did you mean 'STDOUT'?) - http://carc.in/#/r/gg
<unshadow> >> STDOUT.print "hello"
<DeBot> unshadow: hello - http://carc.in/#/r/gh
<unshadow> Oh...
<unshadow> >> StringIO.new.print "bla"
<DeBot> unshadow: # => #<StringIO:0x910DF90 @buffer=Pointer(UInt8)@0x9111F78, @bytesize=3, @capacity=64, @pos=0> - http://carc.in/#/r/gi
<unshadow> Ok...
<unshadow> So, techniclly I can just chage parse(data, io=StringIO.new) to parse(data, io=STDOUT) to let it be the default right ?
<jhass> sure
<jhass> I don't think that's a good default since it's called parser and not printer, but your choice
<unshadow> Hm... thats true
<unshadow> Ok, I'm with you on that
<unshadow> Btw, what's "spec" for ?
<jhass> specs
<jhass> (tests)
Ven has joined #crystal-lang
<unshadow> What would be good tests to run against this kind of lib ? should I even bother making them ? (Sorry if i'm asking too much but I never really created a lib from scratch and I really want to know what I'm doing)
<jhass> a bunch of known output tests, check the edge cases
<jhass> "foo", "(enter)", "options(a,b)", "foo options(a, b)", "options(a,b,c) bar", "##redblue", "This ## is some text"
<jhass> etc. etc.
BlaXpirit has quit [Quit: Quit Konversation]
havenwood has quit [Ping timeout: 245 seconds]
<unshadow> Cool! it's ready including specs
<unshadow> I really like the crystal init function
waterlink has joined #crystal-lang
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
strcmp1 has joined #crystal-lang
<unshadow> jhass, how would one compile to Windows ?
<jhass> uh, checkout the branch, read the readme there, do stuff and complain that it doesn't work?
<jhass> something in that direction
<unshadow> jhass: ok, so there is a Windows branch, thanks I guess
<jhass> unshadow: https://github.com/xwanderer/crystal/tree/win32 has a bit more recent work I think
<unshadow> jhass: Thanks, it does lool better, I'll to use that
<unshadow> it's kind of annoying that you cannot open an issue in a forked repo
<jhass> you can, they're just disabled by default
<unshadow> hmm didn't know that , btw is carc.in is on git ? or latest stable ?
<jhass> it's on the version it denotes
<jhass> so 0.7.1 by default currently
<unshadow> Would you think about adding Crystal-git to the list ? to test new features as they are added ?
<jhass> my main issue would be that I'd forget rebuilding it regularly
<jhass> probably should just write a timer unit for it, but meh
<unshadow> It could even be great way to check a new commit and see that it wont break your code :)
<unshadow> you could just crontab a git pull
<unshadow> hourly, or daily
<jhass> nah, the version it runs with and that it runs is completely decoupled
<unshadow> and build
<unshadow> you could write a small crystal script to git pull and sleep 24 hours ;)
<jhass> if anything I'd use a systemd timer unit
<unshadow> the container is Ubuntu or Arch ?
<jhass> arch
<jhass> another issue is that it'll loose reproducability or pile up hundreds of containers
<unshadow> In what scenerio ? if someone will try to run something while the git version is being built ?
<jhass> no, I mean that I couldn't rerun the runs using git HEAD against the version they ran originally against
<jhass> the failed run during container replace I'd accept, rebuilding the container takes < 5 secs
BlaXpirit has joined #crystal-lang
<unshadow> Oh.. well whenever the pull is made, the histroy will be cleared and you cannot re-run against same version, thats the point of running against latest commit no ?
<crystal-gh> [crystal] asterite closed pull request #695: Add values_at (master...values_at) http://git.io/vTxmx
<jhass> no
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<unshadow> ok, c u later, at last it's home time :)
<jhass> anyway, the services focus is to provide a playground for exploring the language when you're new to it and for support things like the eval bot here, so I don't see the effort worth it
<unshadow> that's cool
unshadow has quit [Quit: leaving]
<travis-ci> manastech/crystal#2374 (master - 722fe08 : Ary Borenszweig): The build passed.
bcardiff has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
havenwood has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
Ven has joined #crystal-lang
Ven has quit [Client Quit]
havenwood has joined #crystal-lang
shama has joined #crystal-lang
sandelius has joined #crystal-lang
JBat has quit [Ping timeout: 246 seconds]
kulelu88 has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
DerisiveLogic has joined #crystal-lang
Ven has joined #crystal-lang
c355E3B has joined #crystal-lang
<crystal-gh> [crystal] waj pushed 1 new commit to master: http://git.io/vTj0p
<crystal-gh> crystal/master 93aa54e Juan Wajnerman: Update Vagrant config
<travis-ci> manastech/crystal#2376 (master - 93aa54e : Juan Wajnerman): The build passed.
bcardiff has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zz_Cidan is now known as Cidan
Cidan is now known as zz_Cidan
havenwood has quit [Ping timeout: 246 seconds]
havenwood has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vkek9
<crystal-gh> crystal/master d0f5c32 Ary Borenszweig: Added type restriction to Array#push(*values)
<crystal-gh> crystal/master 010c872 Ary Borenszweig: Make `Tuple#class` return a proper Class, not a tuple. This will allow doing things like `Tuple(Int32, String).from_json`
<crystal-gh> crystal/master 7d9028f Ary Borenszweig: Added IO.copy (thanks @datanoise)
bcardiff has quit [Quit: Leaving.]
<travis-ci> manastech/crystal#2377 (master - 7d9028f : Ary Borenszweig): The build passed.
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vkeqC
<crystal-gh> crystal/master 10c4163 Ary Borenszweig: Added TypeNode#length in macros: similar to the magic @length variable in macros, which later will be removed.
<crystal-gh> crystal/master 4e4e2f3 Ary Borenszweig: Fixed cast (as) to metaclass