baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com || Ruby 2.5.0, 2.4.3, 2.3.6: https://www.ruby-lang.org || Paste >3 lines of text to: https://gist.github.com || Rails questions? Ask in: #RubyOnRails || Logs: https://irclog.whitequark.org/ruby || Books: https://goo.gl/wpGhoQ
ta_ has quit [Ping timeout: 268 seconds]
alfiemax has joined #ruby
ineb has quit [Ping timeout: 256 seconds]
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nowhere_man has joined #ruby
ta_ has joined #ruby
skweek has quit [Ping timeout: 256 seconds]
alfiemax has quit [Ping timeout: 256 seconds]
nowhereman_ has quit [Ping timeout: 240 seconds]
eckhardt has joined #ruby
John__ has joined #ruby
John__ has quit [Remote host closed the connection]
John__ has joined #ruby
drewmcmillan has joined #ruby
minimalism has quit [Quit: minimalism]
John_Ivan has quit [Ping timeout: 248 seconds]
John__ has quit [Client Quit]
John_Ivan has joined #ruby
John_Ivan has joined #ruby
John_Ivan has quit [Changing host]
randyn has joined #ruby
jnyw has joined #ruby
arescorpio has joined #ruby
<randyn> hi there, is there anyone here familiar with TarWRiter and TarReader? My question can be seen here: https://stackoverflow.com/questions/48856240/appending-files-to-a-stringio-tar-archive-one-at-a-time
alfiemax has joined #ruby
ineb has joined #ruby
war_pigs has quit [Quit: later... computer is sleeping]
alfiemax has quit [Ping timeout: 268 seconds]
vondruch has quit [Ping timeout: 255 seconds]
alfiemax has joined #ruby
s3nd1v0g1us has quit [Ping timeout: 252 seconds]
alfiemax has quit [Ping timeout: 276 seconds]
ta_ has quit [Ping timeout: 248 seconds]
ta_ has joined #ruby
cagomez has joined #ruby
n0m4d1c has quit [Remote host closed the connection]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
s3nd1v0g1us has joined #ruby
s3nd1v0g1us has quit [Max SendQ exceeded]
alfiemax has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
alfiemax has quit [Ping timeout: 255 seconds]
clemens3 has quit [Ping timeout: 260 seconds]
eckhardt has joined #ruby
quobo has quit [Quit: Connection closed for inactivity]
n008f4g_ has quit [Ping timeout: 256 seconds]
nadir has quit [Quit: Connection closed for inactivity]
war_pigs has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jordanm has joined #ruby
ptx0 has quit [Ping timeout: 268 seconds]
skweek has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ptx0 has joined #ruby
cagomez has quit [Remote host closed the connection]
alfiemax has joined #ruby
ta_ has quit [Ping timeout: 260 seconds]
Guest5967 has quit [Ping timeout: 268 seconds]
alfiemax has quit [Ping timeout: 248 seconds]
marr has quit [Ping timeout: 255 seconds]
lavamind has joined #ruby
ta_ has joined #ruby
<lavamind> hello, I'd like to know, in a Gemfile, how to require a gem condtionally based on the (latest) version of another gem
torin_ has joined #ruby
<lavamind> go if gem A version > 2.0, then gem B should have :require => false
<lavamind> I already use groups in my Gemfile but I'm wondering if there's a way to solve this without using groups
gary has joined #ruby
gary is now known as Guest6343
alfiemax has joined #ruby
nadir has joined #ruby
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
konsolebox has quit [Ping timeout: 260 seconds]
alfiemax has quit [Ping timeout: 252 seconds]
leitz has quit [Quit: Nappy time]
konsolebox has joined #ruby
Guest6343 has quit [Ping timeout: 268 seconds]
alfiemax has joined #ruby
drewmcmillan has joined #ruby
vutral|kali has quit [Ping timeout: 248 seconds]
alfiemax has quit [Ping timeout: 256 seconds]
vutral|kali has joined #ruby
vutral|kali has joined #ruby
vutral|kali has quit [Changing host]
ta_ has quit [Ping timeout: 252 seconds]
shinnya has quit [Ping timeout: 268 seconds]
erlend has quit [Ping timeout: 240 seconds]
hfp_work has quit [Quit: bye]
ta_ has joined #ruby
gary has joined #ruby
alfiemax has joined #ruby
gary is now known as Guest71942
erlend has joined #ruby
Guest71942 has quit [Ping timeout: 264 seconds]
alfiemax has quit [Ping timeout: 256 seconds]
schneide_ has joined #ruby
hndk has joined #ruby
eroux has quit [Remote host closed the connection]
torin_ has quit []
hfp_work has joined #ruby
schneide_ has quit [Ping timeout: 268 seconds]
gary_ has joined #ruby
gary_ is now known as Guest9346
gizmore has joined #ruby
aguestuser has quit [Remote host closed the connection]
hfp_work has quit [Client Quit]
aguestuser has joined #ruby
Guest9346 has quit [Ping timeout: 240 seconds]
alfiemax has joined #ruby
gizmore|2 has quit [Ping timeout: 260 seconds]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
aintno_sunshine has joined #ruby
war_pigs has quit [Quit: later... computer is sleeping]
alfiemax has quit [Ping timeout: 268 seconds]
braderhart has joined #ruby
gary__ has joined #ruby
schneide_ has joined #ruby
war_pigs has joined #ruby
John_Ivan has quit [Read error: Connection reset by peer]
gary__ has quit [Ping timeout: 248 seconds]
schneide_ has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
al2o3-cr has quit [Read error: Connection reset by peer]
gary__ has joined #ruby
ta_ has quit [Ping timeout: 240 seconds]
alfiemax has quit [Ping timeout: 256 seconds]
cdg has joined #ruby
Yxhuvud has quit [Read error: Connection reset by peer]
hfp_work has joined #ruby
Yxhuvud has joined #ruby
eblip has joined #ruby
cdg has quit [Remote host closed the connection]
def_jam has joined #ruby
eb0t has quit [Ping timeout: 256 seconds]
eb0t- has quit [Ping timeout: 268 seconds]
ta_ has joined #ruby
sagax has quit [Quit: Konversation terminated!]
orbyt_ has joined #ruby
hndk has quit [Quit: Leaving]
xMopx is now known as xMopx1
xMopx1 is now known as xMopx
alfiemax has joined #ruby
memo1 has joined #ruby
millz has quit [Ping timeout: 240 seconds]
<memo1> hi. I need to use a regex this way /test/ but my test have quotes "test". How i remove the quotes to use the regex?
<Vashy> try this /\"test\"/
alfiemax has quit [Ping timeout: 265 seconds]
elcontrastador has quit [Ping timeout: 276 seconds]
<memo1> Vashy: thank you. Is not working
<Vashy> can you show the code?
lunarkitty7 has quit [Ping timeout: 265 seconds]
<Vashy> what is argv[0]
<memo1> Vashy: is a simple code to find word in a webpage. i run the code ruby webscrapping.rb word, and it must find the word in the webpage
<memo1> Vashy: im trying to capture the varible on console
govg has joined #ruby
<memo1> Vashy: the regex /test/ dont works with " "
arescorpio has quit [Quit: Leaving.]
<Vashy> memo1, what's the exact thing you pass in? "word" ??
skweek has quit [Ping timeout: 260 seconds]
def_jam is now known as eb0t
<memo1> Vashy: ruby test.rb test. But when i get a = ARGV[0] i get a String "test". When i use /"test"/ is not the same as /test/. The last one works
war_pigs has quit [Quit: laters.. I'm out.]
<memo1> Vashy: i need to convert "test" to test
<Vashy> hm, I don't think that's what you want
cdg has joined #ruby
<Vashy> I don't think the word "test" is in the html document
AJA4350 has quit [Quit: AJA4350]
<memo1> Vashy: oh, sure, you can use the word tras
<memo1> Vashy: a spanish word
<memo1> Vashy: i just try to explain with an example. But if you remove the AARV[0] form the regext and use tras, it works
<memo1> Vashy: but, if you use "tras" it fails
cdg has quit [Ping timeout: 276 seconds]
<Vashy> ah ok I see what you're saying now
<Vashy> hm one sec let me check
<Vashy> I think you have to use a regex object if I remember correctly
<memo1> Vashy: thank you
<memo1> Vashy: Im searching on google, but regex is really confusing to me.
<Vashy> no worries, this is a pretty common task, we can solve it
<memo1> Vashy: i just try to remove the "
ta_ has quit [Ping timeout: 264 seconds]
<Vashy> ok memo1 figured it out
<Vashy> you want to do: Regexp.new(ARGV[0]) instead of /ARGV[0]/
lunarkitty7 has joined #ruby
<Vashy> let me know if that doesn't work
ta_ has joined #ruby
<memo1> Vashy: Wow, it works!. Thank you. Regexp is a class?
<Vashy> yeah it's part of standard Ruby
aguestuser has quit [Remote host closed the connection]
<memo1> Vashy: im pretty new to Ruby. if a want to learn about Regexp, how i use ri or the local docs to learn?,
aguestuser has joined #ruby
gary__ has quit [Ping timeout: 265 seconds]
<memo1> Vashy: ri Regexp, "nothing known about Regexp
<Vashy> oh neat I didn't know about "ri" that's cool! =)
<Vashy> so most languages have support for Regex so I think you'll be okay with just googling mostly
<Vashy> but learning regex in general might help you
<Vashy> https://www.regexone.com/ here's an interactive tutorial
gary has joined #ruby
alfiemax has joined #ruby
gary is now known as Guest71708
<Vashy> you can use the "Lesson Notes" section on the right side to choose the topic you're interested in
<memo1> Vashy: Thank you friend!.
<Vashy> no problem, happy to help
alfiemax has quit [Ping timeout: 256 seconds]
flak has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
Guest71708 has quit [Ping timeout: 256 seconds]
howdoi has joined #ruby
aintno_sunshine has quit [Remote host closed the connection]
Guest48858 has quit [Ping timeout: 268 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ta_ has quit [Ping timeout: 256 seconds]
trautwein has quit [Quit: ZNC 1.6.5 - http://znc.in]
trautwein has joined #ruby
ta_ has joined #ruby
gary has joined #ruby
gary is now known as Guest17680
<havenwood> require 'matrix'; [*4.times.map { |n| n.succ ** 4 % 19 + 96 }, *20.times.map { |n| 100 + (Matrix[[0, 1], [1, 1]] ** n)[1, 1] % 10 + 10 }.last(3)].pack('C*')
Guest17680 has quit [Ping timeout: 256 seconds]
gary_ has joined #ruby
gary_ is now known as Guest68828
Guest68828 has quit [Ping timeout: 252 seconds]
moeSizlak has left #ruby ["Leaving"]
brandedcandy has joined #ruby
brandedcandy has quit [Quit: Ex-Chat]
gix has joined #ruby
ta_ has quit [Ping timeout: 268 seconds]
gix- has quit [Ping timeout: 240 seconds]
ta_ has joined #ruby
ephemera__ has joined #ruby
gary__ has joined #ruby
ephemera_ has quit [Ping timeout: 248 seconds]
alfiemax has joined #ruby
gary__ has quit [Ping timeout: 240 seconds]
alfiemax has quit [Ping timeout: 276 seconds]
Matthew1 has joined #ruby
zkv has joined #ruby
zkv has quit [Quit: HydraIRC -> http://www.hydrairc.com <- Nine out of ten l33t h4x0rz prefer it]
zkv has joined #ruby
darkhanb has joined #ruby
troys has quit [Quit: Bye]
jnollette has quit [Ping timeout: 255 seconds]
jnollette_ has joined #ruby
vondruch has joined #ruby
jeffreylevesque has quit [Ping timeout: 256 seconds]
b100s has left #ruby ["Leaving"]
pabs has quit [Ping timeout: 264 seconds]
jeffreylevesque has joined #ruby
braderhart has quit [Quit: Connection closed for inactivity]
eckhardt has joined #ruby
gary has joined #ruby
gary is now known as Guest61519
pabs has joined #ruby
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ta_ has quit [Ping timeout: 260 seconds]
Guest61519 has quit [Ping timeout: 276 seconds]
sanscoeur has joined #ruby
darkhanb has joined #ruby
darkhanb has quit [Client Quit]
jeffreylevesque has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ta_ has joined #ruby
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cdg has joined #ruby
cdg has quit [Ping timeout: 265 seconds]
dionysus69 has joined #ruby
anisha has joined #ruby
darkhanb has joined #ruby
dviola has quit [Quit: WeeChat 2.0.1]
gary_ has joined #ruby
gary_ is now known as Guest99625
darkhanb has quit [Client Quit]
alfiemax has joined #ruby
Guest99625 has quit [Ping timeout: 248 seconds]
alfiemax has quit [Ping timeout: 240 seconds]
gizmore has quit [Ping timeout: 260 seconds]
sanscoeur has quit [Remote host closed the connection]
ta_ has quit [Ping timeout: 268 seconds]
alfiemax has joined #ruby
<dminuoso> havenwood: Use lambdas.
* dminuoso spanks havenwood with a stabby lambda
memo1 has quit [Quit: WeeChat 1.6]
alfiemax has quit [Ping timeout: 264 seconds]
alfiemax has joined #ruby
ta_ has joined #ruby
cliq has joined #ruby
gary has joined #ruby
gary is now known as Guest97869
cliq has quit [Ping timeout: 268 seconds]
Guest97869 has quit [Ping timeout: 240 seconds]
ta_ has quit [Ping timeout: 256 seconds]
roshanavand has joined #ruby
apeiros has quit [Remote host closed the connection]
kliq has joined #ruby
kliq has quit [Remote host closed the connection]
agent_white has quit [Quit: bai]
KeyJoo has joined #ruby
darkhanb has joined #ruby
alfiemax_ has joined #ruby
guardianx has joined #ruby
gary_ has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
gary_ is now known as Guest18557
nahra has quit [Remote host closed the connection]
Sifrael has quit [Ping timeout: 256 seconds]
guardianx has quit [Remote host closed the connection]
guardianx has joined #ruby
Guest18557 has quit [Ping timeout: 255 seconds]
conta has joined #ruby
minimalism has joined #ruby
sundhell_away is now known as sundhell
maum has joined #ruby
rabajaj has joined #ruby
mtkd has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
n008f4g_ has joined #ruby
Dimik has joined #ruby
gary has joined #ruby
gary is now known as Guest19208
vondruch has quit [Ping timeout: 240 seconds]
RougeR has quit [Ping timeout: 268 seconds]
andikr has joined #ruby
despai has joined #ruby
gr33n7007h has joined #ruby
gr33n7007h is now known as al2o3-cr
schneide_ has joined #ruby
despai has quit [Client Quit]
Guest19208 has quit [Ping timeout: 240 seconds]
schneide_ has quit [Remote host closed the connection]
guardianxx has joined #ruby
guardianx has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
tvw has joined #ruby
x0f has quit [Ping timeout: 240 seconds]
mtkd has quit []
schneide_ has joined #ruby
alfiemax_ has quit [Ping timeout: 260 seconds]
b0nn has joined #ruby
x0f has joined #ruby
b0nn has left #ruby [#ruby]
alfiemax has quit [Remote host closed the connection]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
LocaMocha has joined #ruby
n008f4g_ has quit [Ping timeout: 248 seconds]
alfiemax has joined #ruby
Sauvin has quit [Ping timeout: 276 seconds]
ta_ has joined #ruby
gary_ has joined #ruby
x0f has quit [Ping timeout: 240 seconds]
gary_ is now known as Guest56947
x0f has joined #ruby
LocaMocha has quit [Max SendQ exceeded]
LocaMocha has joined #ruby
guardianxx has quit []
LocaMocha has quit [Excess Flood]
aufi has joined #ruby
vondruch has joined #ruby
LocaMocha has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
Dimik has quit [Ping timeout: 264 seconds]
mtkd has joined #ruby
apeiros has joined #ruby
<vutral|kali> can someone fix my regex ? /:(\w|\.|\!|\@+) PRIVMSG (\w|\#+) :(.*)/.match(line)
iceskins[m] has joined #ruby
<dminuoso> vutral|kali: How about zou tell us whats wrong with it.
<dminuoso> Make a testcase.
<dminuoso> Surely you can reduce the regex to the single portion you cant make sense of.
<vutral|kali> it shoudl match :user!ident@host PRIVMSG #channel :bla
<dminuoso> vutral|kali: So reduce the regex to the portion that doesn't work?
<vutral|kali> matching multiple cases doesnt work
<dminuoso> I dont like "Here's a big regex - something doesn't match" because it implies you have not tried to split it into small testable pieces.
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso> vutral|kali: There's multiple mistakes in your regex, so just reduce it to
<dminuoso> "#channel" being matched by /(\w|\#+)/
<dminuoso> for now.
<dminuoso> / /(\w|\#+)/ means "a single word character _OR_ (1 or more '#')"
<dminuoso> This probably is not what you intended.
aupadhye has joined #ruby
<vutral|kali> rubular.com says my expression should work
<vutral|kali> :/
<apeiros> vutral|kali: it's unlikely that you'll come up with a correct regex for irc messages.
<vutral|kali> :([\w|\.|\!|\@]+) PRIVMSG ([\w|\#]+) :(.*)
<apeiros> one reason being that the correctness depends on server settings communicated during connecting to the server
<vutral|kali> apeiros, ?
<vutral|kali> what do you mean
<apeiros> [\w|\#] <-- in a character class, the | is a literal pipe, not an "or"
<apeiros> [ab] already is "a" or "b"
<dminuoso> vutral|kali: So you allow for a##aaa# as a channel name
<apeiros> and [a|b] is "a", "b" or "|"
<vutral|kali> i know its not perfect
<dminuoso> vutral|kali: No its not just "not perfect" its just "wrong"
<apeiros> vutral|kali: I mean that irc messages only seem simple. they are not.
<vutral|kali> apeiros, i still can match channels for correctness later
<dminuoso> vutral|kali: Wrong regular expressions mean you accept wrong input. Accepting wrong input means your program has a good basis for misbehaving.
<dminuoso> vutral|kali: Either you intend to pattern match, then do it right, or dont do it at all and just split on whitespace.
<apeiros> vutral|kali: channelnames are actually one thing where you can't use a generic expression, as max channel name length is one of the things communicated when you first connect
<apeiros> also iirc valid channelname prefixes
<apeiros> let me see whether I find my set of expressions…
<dminuoso> apeiros: In all fairness it's not inherently wrong to separate tokenization and semantic checking
claudiuinberlin has joined #ruby
<apeiros> dminuoso: yeah, sure, but then not even # would be a part
<vutral|kali> thats correct
<vutral|kali> its a nick sometimes not a channel
<apeiros> as in, your "allow for a##aaa#" would be part of semantic checking too
<apeiros> fun fact: freenode sometimes has users with invalid nicknames (in case of collisions, their ircd sometimes uses invalid replacement nicks)
<dminuoso> vutral|kali: So just do something along the lines of /(?<source>\w+) PRIVMSG (?<target>\w+) (?<message>\w+)/
<dminuoso> GOOD LORD
<dminuoso> What is that.
RougeR has joined #ruby
<apeiros> the thing powering ruby[bot]
<apeiros> it's irc v3.2 capable (not that freenode would support that already :< )
clemens3 has joined #ruby
<dminuoso> apeiros: I wonder, are there any monadic parser combinators?
<apeiros> no idea
<apeiros> note the "HURRAY" statements
marr has joined #ruby
<dminuoso> kind of.
<dminuoso> apeiros: Heh
<apeiros> that seems to be doable with plain regex in ruby? as they're perfectly composable.
<dminuoso> apeiros: not exactly
<apeiros> an example of what doesn't work?
<dminuoso> apeiros: You could do something like..
<dminuoso> apeiros: `token p = p <* spaces`
<apeiros> yeah, in words, not in cryptic
<apeiros> I can't know what '<*' means in that context.
<dminuoso> apeiros: sec
<apeiros> but yeah, recursive is difficult / requires creativity :D
<dminuoso> apeiros: So lets say you have a regex that knows how to extract an "identifier", and you have a regex that knows how to extract spaces - how do you combine them into a regex that extracts an identifier _and_ spaces, but disregards the spaces?
<apeiros> /#{spaces}(#{identifier})#{spaces}/
<apeiros> if by extract you mean "advances the cursor"
<dminuoso> apeiros: Except that just matches - but doesn't build.
<dminuoso> apeiros: It doesnt produce results
<apeiros> um, yes? of course?
<apeiros> a regex never will produce results on its own. so kinda stating the obvious?
<dminuoso> apeiros: That's my point. ;-)
<apeiros> neither will a parser?
<dminuoso> apeiros: parser combinators do
<apeiros> you have to "use" it at some point
TvL2386_ has quit [Quit: leaving]
<dminuoso> apeiros: That's the thing, you can talk about results without having to use it
<apeiros> o0
<dminuoso> let me show you how it would look in ruby
TvL2386 has joined #ruby
ta_ has quit [Remote host closed the connection]
ta_ has joined #ruby
guille-moe has joined #ruby
amatas has joined #ruby
ta_ has quit [Ping timeout: 276 seconds]
ta_ has joined #ruby
beauby has joined #ruby
gregf_ has quit [Ping timeout: 260 seconds]
maum has quit [Remote host closed the connection]
cdg has joined #ruby
hahuang65 has quit [Ping timeout: 276 seconds]
Matthew1 has quit [Ping timeout: 264 seconds]
cdg_ has joined #ruby
Guest56947 has quit [Ping timeout: 240 seconds]
ams__ has joined #ruby
cdg has quit [Ping timeout: 255 seconds]
cdg_ has quit [Ping timeout: 240 seconds]
ta_ has quit [Remote host closed the connection]
ta_ has joined #ruby
aupadhye has quit [Quit: Leaving]
aupadhye has joined #ruby
n13z has joined #ruby
ta_ has quit [Ping timeout: 255 seconds]
gary has joined #ruby
gary is now known as Guest56907
gregf_ has joined #ruby
Guest56907 has quit [Ping timeout: 240 seconds]
gary_ has joined #ruby
gary_ is now known as Guest31891
<dminuoso> apeiros: Haha. I need to think about how to do mutual recursion in Ruby.
<dminuoso> Im missing the most crucial combinator
alfiemax has quit [Remote host closed the connection]
ta_ has joined #ruby
Guest31891 has quit [Ping timeout: 248 seconds]
alfiemax has joined #ruby
<apeiros> more complex than expected? :)
<dminuoso> apeiros: well let me show you what I have already
<dminuoso> apeiros: This is the basic idea: https://gist.github.com/dminuoso/71a4ed1e7c4e01501fa1739724001d2e
<dminuoso> err
<dminuoso> This.
<dminuoso> apeiros: Lets assume for a second that some/many worked, then you could incrementally build up parsers like: number = many.(digit)
alfiemax has quit [Ping timeout: 256 seconds]
<dminuoso> or space = satisfy.(-> e { e =~ /\s/ })
<dminuoso> and a parser that consumes many spaces: spaces = many.(spaces)
<apeiros> and what's your advantage over /\d+/ (consuming) and /(?=\d+)/ (non-consuming)?
<dminuoso> apeiros: Let me build a few more combinators, and then reimplement your parser
<apeiros> I wish I had as much time as you seem to have for such things :D
<dminuoso> apeiros: I wanted a parser combinator library for one of our ruby things anyway. :D
Serpent7776 has joined #ruby
gary__ has joined #ruby
jenrzzz has joined #ruby
gary__ has quit [Ping timeout: 248 seconds]
tomlukeywood has joined #ruby
gary__ has joined #ruby
jaruga has joined #ruby
tomlukeywood has quit [Remote host closed the connection]
tomlukeywood has joined #ruby
dionysus69 has joined #ruby
gary__ has quit [Ping timeout: 260 seconds]
tomlukeywood has quit [Remote host closed the connection]
jnyw has quit [Quit: WeeChat 2.0.1]
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
Chuguniy has joined #ruby
GodFather has quit [Read error: Connection reset by peer]
GodFather has joined #ruby
megamosaren has joined #ruby
megamosaren has quit [Client Quit]
KeyJoo has quit [Ping timeout: 276 seconds]
Skoom has joined #ruby
gary has joined #ruby
gary is now known as Guest868
mtkd has quit []
mtkd has joined #ruby
Guest868 has quit [Ping timeout: 256 seconds]
gary_ has joined #ruby
gary_ is now known as Guest80914
apeiros has quit []
amatas_ has joined #ruby
Guest80914 has quit [Ping timeout: 248 seconds]
dvdingus has joined #ruby
amatas_ has quit [Quit: amatas_]
amatas_ has joined #ruby
drewmcmillan has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
apparition has joined #ruby
pabs has quit [Ping timeout: 260 seconds]
pabs has joined #ruby
guille-moe has quit [Remote host closed the connection]
workmad3 has quit [Ping timeout: 260 seconds]
Chuguniy has quit [Ping timeout: 268 seconds]
Chuguniy has joined #ruby
dionysus69 has quit [Remote host closed the connection]
Cavallari has joined #ruby
Cavallari1 has joined #ruby
gary__ has joined #ruby
Chelsea has quit [Ping timeout: 248 seconds]
Matthew1 has joined #ruby
Cavallari has quit [Ping timeout: 264 seconds]
Cavallari1 is now known as Cavallari
gary__ has quit [Ping timeout: 248 seconds]
sundhell is now known as sundhell_away
Cavallari1 has joined #ruby
ta_ has quit [Ping timeout: 260 seconds]
clemens3 has quit [Ping timeout: 276 seconds]
Cavallari has quit [Ping timeout: 248 seconds]
Cavallari1 has quit [Ping timeout: 240 seconds]
zapata has quit [Read error: Connection reset by peer]
zapata has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
ldnunes has joined #ruby
Cavallari has joined #ruby
cdg has joined #ruby
ta_ has joined #ruby
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ldnunes has quit [Read error: Connection reset by peer]
ldnunes has joined #ruby
Matthew1 has quit [Remote host closed the connection]
gary has joined #ruby
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gary is now known as Guest64495
beauby has quit [Ping timeout: 260 seconds]
cdg has quit [Ping timeout: 255 seconds]
drewmcmillan has joined #ruby
Guest64495 has quit [Ping timeout: 255 seconds]
jenrzzz has quit [Ping timeout: 276 seconds]
drewmcmillan has quit [Client Quit]
AJA4350 has joined #ruby
jenrzzz has joined #ruby
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
chocoelho has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
John_Ivan has joined #ruby
John_Ivan has joined #ruby
John_Ivan has quit [Changing host]
rabajaj has quit [Remote host closed the connection]
jenrzzz has joined #ruby
workmad3 has joined #ruby
gary_ has joined #ruby
gary_ is now known as Guest3688
drewmcmillan has joined #ruby
nowhereman_ has joined #ruby
Guest3688 has quit [Ping timeout: 248 seconds]
nowhere_man has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
nadir has joined #ruby
eblip is now known as eb0t-
OyoKooN has joined #ruby
apeiros_ has joined #ruby
jenrzzz has joined #ruby
OyoKooN has quit [Client Quit]
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 248 seconds]
Cavallari1 has joined #ruby
beauby has joined #ruby
nowhereman_ has quit [Ping timeout: 256 seconds]
Cavallari has quit [Ping timeout: 240 seconds]
Cavallari1 is now known as Cavallari
drewmcmillan has joined #ruby
arne_ has joined #ruby
<arne_> hello fellow rubiest
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<arne_> im really unhappy with all existing ways to handle websockets in ruby
<arne_> would it be in any way stupid to build a c extensionf or thath?
<apeiros_> arne_: it seems unnecessary
<apeiros_> what benefit to you expect from a C extension?
apeiros_ is now known as apeiros
Cavallari1 has joined #ruby
<arne_> apeiros: performance... and nicer way to do it?
<arne_> because existing ones require weird rack session hijacking?
Cavallari has quit [Ping timeout: 240 seconds]
Cavallari1 is now known as Cavallari
<arne_> and i am guessing those would not be rack-implementation agnostic, meaning i can't switch from one webserver to another
raynold has quit [Quit: Connection closed for inactivity]
<apeiros> arne_: you'll almost certainly not have any notable performance benefit
<apeiros> I suspect the issue is more with how it's forced through an infrastructure which isn't built for websockets (rack in your example)
<apeiros> and building a native extension won't magically make those problems go away. you're still on the same architecture there.
<dminuoso> apeiros: This is freaking hard without a type checker..
<havenwood> arne_: Have you checked out AnyCable?: http://anycable.io/
shinnya has joined #ruby
gary has joined #ruby
<apeiros> dminuoso: you mean the parser project?
jenrzzz has quit [Ping timeout: 256 seconds]
gary is now known as Guest24820
<arne_> uhhh cool havenwood
<arne_> well, there is this webframework i really like
<arne_> and it uses rack
<arne_> i would love it so much if it had websockets
<havenwood> arne_: What framework?
<arne_> roda
<arne_> i mean it has websockets, using faye
<arne_> but that sucks
<havenwood> arne_: Roda is probably my favorite.
<havenwood> arne_: +1
<arne_> so good
<havenwood> arne_: You can use AnyCable with Roda.
<arne_> just as sequel, i love jeremyevans
<arne_> havenwood: as i understood it, anycable is just a way to "route" websockets?
<havenwood> Here's a Sinatra example with AnyCable: https://github.com/palkan/litecable/tree/master/examples/sinatra
<arne_> what would be at the end of that route?
Guest24820 has quit [Ping timeout: 264 seconds]
<arne_> havenwood: sound reasonable, thanks
<dminuoso> apeiros, havenwood https://eval.in/958885
<dminuoso> Monadic parser combinators in Ruby.
<dminuoso> =)
<dminuoso> A monadic non-deterministic parser combinator.
<dminuoso> Fully capable of describing LL(1) grammars
<havenwood> arne_: Discourse uses MessageBus.
<dminuoso> Should now include some examples how to use this.
RougeR has quit [Ping timeout: 256 seconds]
<dminuoso> And `some`/`many` can probably rewritten much more easily, but meh I dont know how to do loops in Ruby anymore.
<arne_> i don't know messagebuse :(
<havenwood> arne_: If I recall correctly, it was created for Discourse after frustration with other options.
<arne_> i don't know Discourse :(
<havenwood> It's a popular, large Rails app.
<havenwood> arne_: https://www.discourse.org/
<arne_> and they use websockets alot and abstracted over it?
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<havenwood> arne_: WebSockets are an optional transport, but I don't think they're actually favored. I can't recall where I found it, but there's an interesting piece where Sam discusses why.
<havenwood> arne_: Elixir with Phoenix Channels starts to look appealing at some point. ;-)
<arne_> context is that i am writing my own framework, which i am happy with, and i'd like a SPA-app that only communicates with ruby over websockets with normal-http as fallback
<arne_> and optional usage of http
<havenwood> arne_: HTTP/2 is nice.
<havenwood> I like that Phoenix supports H2 now. Cowboy 2 ftw.
<arne_> i never looked at elixir
<havenwood> it's quite nice
<havenwood> arne_: I'm waiting for someone to make a nice Ruby framework using the http-2 gem - speaking of quite nice: https://github.com/igrigorik/http-2
gary_ has joined #ruby
<arne_> yeah last time i aked the exact same question in there
<arne_> i was brought to http-2, too
gary_ is now known as Guest24546
<arne_> do you think, if you wrote an app with that, you would get a problem with incompatible clients
<arne_> like some IE
<havenwood> arne_: https://caniuse.com/#feat=http2
<workmad3> havenwood: did http2 support ever make it into rack 2?
<havenwood> workmad3: nope
<workmad3> didn't think so... I guess that's half the problem with ruby frameworks still :/
<arne_> havenwood: well, maybe i will do that
<arne_> i keep you updated
<havenwood> workmad3: they managed to support push, but no h2 beyond thqt
<arne_> the fuck is uc browser for android
<havenwood> arne_: the california universities roll their own browser ¯\_(ツ)_/¯
<havenwood> actually, looks like that one is Alibaba Group of China
ghormoon has quit [Ping timeout: 252 seconds]
<havenwood> nevermind
<arne_> who gives a shit about the chinese, amiright?
mtkd has quit []
Guest24546 has quit [Ping timeout: 240 seconds]
<arne_> havenwood: why doesn't racl just support http2?
<arne_> what's the issue?
minimalism is now known as portage
<arne_> i figure i could reach a bunch of github issues
mtkd has joined #ruby
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<arne_> and while we're at it
<arne_> why does rack not just support websocket in the first place
dvdingus has quit [Ping timeout: 256 seconds]
Psybur has joined #ruby
Psybur has quit [Changing host]
Psybur has joined #ruby
<arne_> havenwood: after reading some about http2, what would be different to rack except for server push
ghormoon has joined #ruby
k0mpa has joined #ruby
RougeR has joined #ruby
RougeR has joined #ruby
RougeR has quit [Changing host]
mikeiniowa has quit [Remote host closed the connection]
<havenwood> arne_: Basically everything would be different, and that's the problem. Rack is built for request/response.
<havenwood> HTTP/2 the request/response is always streaming--persistent, message-oriented and bi-directional.
<arne_> sounds like exactly what i would love about a webframework
mikeiniowa has joined #ruby
<arne_> always message-oriented? but.. would a answer to a request not still be a reponse?
<arne_> what's the problem, i don.t follow
<workmad3> arne_: it's a response, but the response doesn't have a fixed end knowable in advance
<arne_> that's od
<arne_> and that's required for rack?
<havenwood> arne_: You can't handle H2 with Rack's expected inputs and outputs. They can change Rack to support H2, but it'd break all the existing apps that expect the Rack spec.
<workmad3> arne_: no, that's the change that http2 made (and websockets)
<arne_> that's also the reason streaming isn't default in rack, i get it
<arne_> workmad3: are websockets still needed considering the asynchron nature of http2?
<havenwood> andersh: no
<workmad3> arne_: depends on who you ask
<havenwood> oops, MT
<arne_> workmad3: if i ask someone who says websockets are still needed, why?
<arne_> is the http2 gem a server already, or just a protocol implementation?
<workmad3> arne_: if you ask someone with a lot of deep knowledge who thinks they're still needed, you'll probably get a lot of technical details that goes into the weeds about why websockets are better or how http2 messed up X, Y or Z
<arne_> i will play around with it, thanks alot, http2 might be want i want
gary__ has joined #ruby
<arne_> the http-2 gem looks weird
<arne_> is ruby really good at stuff like stream.on(:event_name)
<arne_> i mean, is ruby performing well in those asynchron-style code?
<workmad3> but yeah, I'd mostly go with http2 nowadays if you're not tying yourself to an existing framework that only supports http1 + websockets
<arne_> there is no full featured http2 server for ruby i guess?
sundhell_away is now known as sundhell
clemens3 has joined #ruby
<arne_> evented ruby code looks weird
<havenwood> arne_: Someone was working on one based off the http-2 gem. I haven't seen it lately.
dionysus69 has joined #ruby
synthroid has joined #ruby
<havenwood> arne_: The Elixir/Phoenix folk are well ahead on that front. There are lots of opportunities in Ruby to blaze the trail related to H2.
surrounder has left #ruby ["WeeChat 2.0.1"]
<arne_> i am not willing to learn a language that looks like ruby but isn't, would really confuse me
shinnya has quit [Ping timeout: 256 seconds]
<havenwood> arne_: Elixir doesn't really look like Ruby.
gary__ has quit [Ping timeout: 240 seconds]
<arne_> def hello do
<arne_> IO.puts "Hello World"
<arne_> end
<arne_> :>
<havenwood> arne_: Not that that stop me from trying to make it! https://github.com/havenwood/elixir.rb
<arne_> havenwood: you monster
<havenwood> arne_: Okay, I see what you mean. But I don't get confused.
<workmad3> arne_: you should probably get used to it if you're going to have a career in software development... you'll end up going through lots of languages that look like other languages but aren't
<dminuoso> arne_: It does not look like ruby.
<arne_> workmad3: im programming quite a while now, it's more like a "i don't want to"
<arne_> than a "i can't
<dminuoso> Like almost every language on this planet they merely took some syntax inspiration.
<dminuoso> If elixir looks like ruby, your ruby code is non-idiomatic.
<arne_> havenwood: okay fine :D i look at elixir
<workmad3> I need to get back to learning elixir and phoenix... keep on getting started on that route and getting distracted
<arne_> if i read this, i already lost motivation
jenrzzz has quit [Ping timeout: 240 seconds]
<arne_> redirect(conn, to: article_path(conn, :index))
<arne_> i want it like roda does it or not at all
<havenwood> arne_: In Elixir land, Plug is similar to Ruby's Rack.
<havenwood> arne_: You can make a pure Plug app.
<dminuoso> My main beef with Elixir is just the heavy use of macros.
<havenwood> arne_: But it turns out, Phoenix isn't much on top of plug. it's nice conventions.
<havenwood> dminuoso: Phoenix uses a ton of macros...
<dminuoso> havenwood: It's not similar. It's 10 times better.
<dminuoso> Writing efficient Rack middlewares is a PITA.
<havenwood> <3 Plug
<dminuoso> They are mindtwisting.
<dminuoso> :)
<arne_> i'd love to write stuff in haskell but i am still to stoopid :(
conta has quit [Read error: Connection reset by peer]
<arne_> but i am confident i could write something good in/for ruby
gary__ has joined #ruby
conta has joined #ruby
Serpent has joined #ruby
Serpent7776 has quit [Ping timeout: 252 seconds]
Serpent is now known as Serpent7776
portage is now known as minimalism
gary__ has quit [Ping timeout: 256 seconds]
<havenwood> dminuoso: monadic parser combinators in... on my
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
mtkd has quit []
dinfuehr has quit [Ping timeout: 248 seconds]
mtkd has joined #ruby
dinfuehr has joined #ruby
k0mpa has quit [Remote host closed the connection]
drewmcmillan has joined #ruby
drewmcmillan has quit [Ping timeout: 255 seconds]
gary has joined #ruby
gary is now known as Guest59550
drewmcmillan has joined #ruby
Guest59550 has quit [Ping timeout: 260 seconds]
Puffball has joined #ruby
memo1 has joined #ruby
marr has quit [Ping timeout: 256 seconds]
jenrzzz has quit [Ping timeout: 248 seconds]
AJA4350 has quit [Quit: AJA4350]
dalitom has joined #ruby
<memo1> Hi, in the following expression, what is the meaning of ".." if day == :mon .. day == :tues
lxsameer has quit [Quit: WeeChat 1.9.1]
<dalitom> hey guys.. please help!! So I have class1.rb amd class2.rb files, I want to use class2 functions in class1 so in class 2 I do require 'class1', right ?
<havenwood> memo1: look up flipflop operator
<dalitom> So now I do not know how to use it in class2, :/
<dalitom> please help
Puffball has quit [Quit: Puffball]
jenrzzz has joined #ruby
Puffball has joined #ruby
jcalla has joined #ruby
<dminuoso> dalitom: Top level functions are scoped to files.
<dminuoso> dalitom: The regular solution is to place them into the singleton class of a module if you just want to have "plain" functions.
<dalitom> right I just want to use some function from class1
haylon has joined #ruby
jcalla has quit [Ping timeout: 264 seconds]
<dminuoso> dalitom: Just create some module
dionysus69 has quit [Ping timeout: 240 seconds]
<dminuoso> >> module Foo; def self.bar; puts 42; end; end; puts Foo.bar()
<dminuoso> You can require the other file, and then refer to `Foo` to access that module.
Azure has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dalitom> Thank you guys
<dalitom> !!
gary_ has joined #ruby
troys has joined #ruby
gary_ is now known as Guest32334
<memo1> havenwood: ok, thank you
Guest32334 has quit [Ping timeout: 240 seconds]
ineb has quit [Ping timeout: 240 seconds]
ineb has joined #ruby
memo1 has quit [Ping timeout: 256 seconds]
jcalla has joined #ruby
DLSteve_ has joined #ruby
za1b1tsu has joined #ruby
clemens3 has quit [Ping timeout: 240 seconds]
ta_ has quit [Remote host closed the connection]
ta_ has joined #ruby
memo1 has joined #ruby
sundhell is now known as sundhell_away
ta_ has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
alex`` has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
setchp has joined #ruby
setchp has left #ruby [#ruby]
Cavallari1 has joined #ruby
synthroid has quit [Remote host closed the connection]
synthroid has joined #ruby
lxsameer has joined #ruby
Cavallari has quit [Ping timeout: 240 seconds]
Cavallari1 has quit [Ping timeout: 248 seconds]
alex``` has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
memo1 has quit [Ping timeout: 256 seconds]
nadir has quit [Quit: Connection closed for inactivity]
tvw has quit [Ping timeout: 256 seconds]
lavamind has left #ruby [#ruby]
marr has joined #ruby
gary has joined #ruby
Rapture has joined #ruby
gary is now known as Guest7366
Guest7366 has quit [Ping timeout: 252 seconds]
dionysus69 has joined #ruby
Mike11 has joined #ruby
delaz has joined #ruby
jnollette_ has quit [Remote host closed the connection]
delaz has left #ruby [#ruby]
delaz has joined #ruby
jnollette has joined #ruby
Gnut has joined #ruby
mostlybadfly has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
GeorgesLeYeti has joined #ruby
<GeorgesLeYeti> Hi
InfinityFye has joined #ruby
<havenwood> GeorgesLeYeti: hi
<GeorgesLeYeti> It is possible to associate values in array to variable. Like [a, b] = [1, 2] => a = 1 and b = 2
despai has joined #ruby
<workmad3> GeorgesLeYeti: you can do `a, b = [1,2]
schneide_ has quit [Remote host closed the connection]
<GeorgesLeYeti> Ho ok
<GeorgesLeYeti> Ty :D
<workmad3> GeorgesLeYeti: and if you want to catch 'all the rest', you can use a *... e.g. `a,b,*c = [1,2,3,4,5]` will assign [3,4,5] to c
<GeorgesLeYeti> Perfect ty a lot workmad3
memo1 has joined #ruby
schneide_ has joined #ruby
Silthias has joined #ruby
gary_ has joined #ruby
aufi has quit [Quit: Leaving]
gary_ is now known as Guest10835
Mia has quit [Remote host closed the connection]
kapil___ has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
nowhereman_ has joined #ruby
snath has quit [Ping timeout: 240 seconds]
memo1 has quit [Ping timeout: 240 seconds]
TomyWork has joined #ruby
Guest10835 has quit [Ping timeout: 256 seconds]
anisha has quit [Quit: This computer has gone to sleep]
apparition has quit [Quit: Bye]
mtkd has quit [Ping timeout: 252 seconds]
gary has joined #ruby
za1b1tsu has quit [Quit: Leaving]
gary is now known as Guest90575
mtkd has joined #ruby
sgen has joined #ruby
clemens3 has joined #ruby
sgen has quit [Client Quit]
Guest90575 has quit [Ping timeout: 255 seconds]
<apeiros> GeorgesLeYeti: a,b = 1,2 # works fine too
memo1 has joined #ruby
sgen has joined #ruby
haylon has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 248 seconds]
rippa has joined #ruby
Silthias1 has joined #ruby
Silthias1 has left #ruby [#ruby]
Silthias has quit [Ping timeout: 276 seconds]
chocoelho has quit [Ping timeout: 255 seconds]
Silthias has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
zacts has quit [Quit: WeeChat 1.9.1]
zacts has joined #ruby
<kspencer> I'm seeing alot of varied information about this, but if I want to write tests, what is it I should be doing in terms of gem files and vcs files, from what I read I should have a source_code_uri metadata entry, spec.files should exclude test-like directories, and I should be pushing tests to a vcs, but just the gem library itself + needed other files like Gemfile, LICENSE to rubygems.org or other gemcutter-compatible gem repository
reber has joined #ruby
vondruch has quit [Quit: vondruch]
synthroid has quit [Remote host closed the connection]
synthroid has joined #ruby
<havenwood> kspencer: it sounds like you're on the right track. can you show code or do you have any more specific questions?
<apeiros> kspencer: into the repository belongs everything necessary to develop/work on the gem (except for credentials, like usernames/passwords/tokens)
synthroid has quit [Ping timeout: 256 seconds]
<apeiros> kspencer: into the .gem file (which you build via `gem build your.gemspec` or potentially indirectly since you use gemcutter) belongs everything necessary to use the gem (again, except config/credentials)
<apeiros> (there is an argument to be made to include the tests into the .gem file, though)
<kspencer> well, I've also been looking, and my gem is a thor + highline CLI app, and I've also been wondering what the best course of action is with making tests, I see many different ways, although I'm currently trying out is https://github.com/dergachev/rspec-tutorial/tree/master/spec
* apeiros prefers minitest
<apeiros> but that's a thing of personal taste
<kspencer> apeiros: yes but then there's also the https://github.com/rubygems/rubygems/issues/735
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<kspencer> aka 'test files should not be installed'
<apeiros> that's a *shrug* issue IMO :D
<apeiros> I mean the only downside this "bug" has is that you load a ridiculously small amount of additional data to the users drives
<kspencer> I've not seen many minitest with cli's though so I can't say I'd have any luck with that out of the box
<apeiros> (unless you have massive fixture data)
<apeiros> eh?
<kspencer> I don't see many cli's with minitest testing, unless I'm looking in the wrong place
<apeiros> is your cli interactive? if not, then a well built cli is just an adapter to your library anyway.
<apeiros> so the distinction library/cli-app is largely meaningless
mtkd has quit []
<apeiros> I think the cli<->lib connection is one of the rare cases where I'd do a whitebox test (ensure e.g. `foo bar` invokes `Foo::Cli.run(["bar"])`) and then rely on the unit tests for the lib.
<kspencer> My code may be a mess, but if I could properly make that distinction, I'll send you the gh repo if that's alright? apeiros
gary_ has joined #ruby
gary_ is now known as Guest12268
<apeiros> kspencer: sure, feel free to paste the repo url in the channel
<apeiros> I'm not sure I'll get around to look at it today, though
<apeiros> but there's plenty of people here
<apeiros> seems to me like you can just write unit tests
Guest12268 has quit [Ping timeout: 240 seconds]
vondruch has joined #ruby
halt has joined #ruby
<workmad3> apeiros: even if it is interactive, a well written CLI should be testable... make sure you're accepting an input source rather than hard-coding $stdin, and then you can test by passing in appropriate inputs as StringIO objects
<apeiros> workmad3: absolutely
halt is now known as Guest16299
<workmad3> but yeah, I'll typically take the actual bin-script as a 'too obvious to need a test' type thing, as it'll usually be a single invocation of a class passing in stdin, stdout and ARGV when I write them...
<apeiros> workmad3: I was more getting at "if you know unit testing, then you can unit test a CLI app without additional knowledge". but I guess that was actually somewhat pointless since you'll want to test the output anyway, no matter how well you separated the concerns.
<kspencer> workmad3: Thor (the gem I'm using for the #start method) allows you to create an instance of your 'App' without running it using #new, as #start will run everything
<workmad3> yeah, I'll pass in a StringIO for output too :)
<kspencer> so how should I go about creating a test for say the outputs or should I test for status on some and regex and success on others
mtkd has joined #ruby
mr_foto has joined #ruby
vdl has quit [Quit: WeeChat 1.6]
<apeiros> gtg, toodles!
<workmad3> (also, annoyingly, it seems from that page that Thor doesn't allow you to inject stdin or stdout for other environments... I've not noticed that before as when I use Thor I tend to treat the steps as close to rake tasks, so I'll keep them single line and move the actual behaviour into testable objects, etc)
apeiros has quit []
chocoelho has joined #ruby
sgen has quit [Remote host closed the connection]
vdl has joined #ruby
aguestuser has quit [Remote host closed the connection]
gary__ has joined #ruby
aguestuser has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
<kspencer> I'll see what I can do with this but I'm not too sure how to go from here
synthroid has joined #ruby
jeffreylevesque has joined #ruby
Silthias has left #ruby [#ruby]
conta has quit [Ping timeout: 256 seconds]
mtkd has quit []
jenrzzz has joined #ruby
drewmcmillan has joined #ruby
Gnut has quit [Ping timeout: 268 seconds]
jaruga has quit [Quit: jaruga]
gary__ has quit [Ping timeout: 260 seconds]
GeorgesLeYeti has quit [Quit: Leaving]
schneide_ has quit [Remote host closed the connection]
despai has quit [Quit: ...]
memo1 has quit [Ping timeout: 255 seconds]
gary has joined #ruby
QCF has joined #ruby
gary is now known as Guest50254
Chuguniy has quit [Read error: Connection reset by peer]
schneide_ has joined #ruby
Chuguniy has joined #ruby
schneide_ has quit [Read error: Connection reset by peer]
regedit_ has joined #ruby
Guest50254 has quit [Ping timeout: 248 seconds]
mcr1 has quit [Ping timeout: 265 seconds]
aufi has joined #ruby
regedit_ is now known as regedit
gary_ has joined #ruby
gary_ is now known as Guest46703
elcontrastador has joined #ruby
QCF is now known as ecnelises
memo1 has joined #ruby
Guest46703 has quit [Ping timeout: 240 seconds]
despai has joined #ruby
gary__ has joined #ruby
snath has joined #ruby
andikr has quit [Remote host closed the connection]
apeiros_ has joined #ruby
ecnelises has quit []
Mike11 has quit [Quit: Leaving.]
Chuguniy has quit [Quit: Leaving]
troys has quit [Read error: Connection reset by peer]
gary__ has quit [Ping timeout: 252 seconds]
mtkd has joined #ruby
gary__ has joined #ruby
troys has joined #ruby
alfiemax has joined #ruby
Azure has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
despai has quit [Quit: ...]
gary__ has quit [Ping timeout: 248 seconds]
herbmillerjr has quit [Quit: Konversation terminated!]
hoylemd has quit [Quit: g'bye]
raynold has joined #ruby
hoylemd has joined #ruby
hoylemd has quit [Client Quit]
hoylemd has joined #ruby
dviola has joined #ruby
biberu has joined #ruby
ldepandis has joined #ruby
s3nd1v0g1us has joined #ruby
s3nd1v0g1us has quit [Max SendQ exceeded]
s3nd1v0g1us has joined #ruby
s3nd1v0g1us has quit [Max SendQ exceeded]
gary__ has joined #ruby
Pisuke has quit [Ping timeout: 240 seconds]
Sembei has joined #ruby
Serpent7776 has quit [Quit: Leaving]
hoylemd has quit [Quit: g'bye]
mcr1 has joined #ruby
leitz has joined #ruby
schneide_ has joined #ruby
jcarl43 has joined #ruby
hoylemd has joined #ruby
gary__ has quit [Ping timeout: 256 seconds]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<leitz> Enjoying the book "Mastering Ruby Closures"
<leitz> Learning stuff.
schneide_ has quit [Ping timeout: 255 seconds]
zautomata has quit [Quit: WeeChat 1.9.1]
hoylemd has quit [Quit: g'bye]
darkhanb has joined #ruby
mtkd has quit []
hoylemd has joined #ruby
aupadhye has quit [Remote host closed the connection]
fyrril has joined #ruby
aufi has quit [Quit: Leaving]
hoylemd has quit [Client Quit]
jamesaxl has joined #ruby
mtkd has joined #ruby
mr_foto has quit []
beauby has quit [Ping timeout: 240 seconds]
orbyt_ has joined #ruby
desperek has joined #ruby
* dminuoso pokes havenwood
<dminuoso> Functional assistance is required!
<dminuoso> How does one write ruby for this to not suck? https://gist.github.com/dminuoso/6fa6f02132b0c95a5cc7178146608a1b
mostlybadfly has quit [Quit: Connection closed for inactivity]
karapetyan has joined #ruby
karapetyan has quit [Client Quit]
<dminuoso> The obvious solution: cons = -> (e, a) { [e, *a] }; some = -> v { v.fmap(cons).ap(many[v]) }; many = -> v { some v | pure([]) } kind of blows up any call stack in existence.
hoylemd has joined #ruby
kapil___ has quit [Ping timeout: 255 seconds]
kapil___ has joined #ruby
hoylemd has quit [Client Quit]
n008f4g_ has joined #ruby
hoylemd has joined #ruby
conta has joined #ruby
hoylemd has quit [Client Quit]
n0m4d1c has joined #ruby
RougeR has quit [Ping timeout: 260 seconds]
jaruga has joined #ruby
hoylemd has joined #ruby
alfiemax has quit [Remote host closed the connection]
conta has quit [Remote host closed the connection]
jaruga has quit [Quit: jaruga]
PaulCapestany has quit [Quit: .]
hahuang65 has joined #ruby
memo1 has quit [Ping timeout: 252 seconds]
gary has joined #ruby
gary is now known as Guest57458
mcr1 has quit [Ping timeout: 276 seconds]
n008f4g_ has quit [Ping timeout: 240 seconds]
PaulCapestany has joined #ruby
zkv has quit [Ping timeout: 265 seconds]
hahuang65 has quit [Ping timeout: 260 seconds]
Guest57458 has quit [Ping timeout: 240 seconds]
Psybur_ has joined #ruby
ledestin has joined #ruby
Psybur has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 264 seconds]
dionysus69 has quit [Remote host closed the connection]
_aeris_ has quit [Ping timeout: 255 seconds]
RougeR has joined #ruby
<leitz> Have things really gone quiet?
jnollette has quit [Ping timeout: 255 seconds]
alfiemax has joined #ruby
<apeiros_> sssshhh
* leitz 's head makes a loud popping sound as it explodes. He was trying to comprehend block to proc conversion.
_aeris_ has joined #ruby
TomyWork has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
hahuang65 has joined #ruby
rexan has joined #ruby
<raynold> Ahh it's a wonderful day
levifig has joined #ruby
<dminuoso> leitz: blocks are procs are lambdas
<dminuoso> leitz: They only differ in subtle, annoying but largely irrelevant semantics.
mcr1 has joined #ruby
jnollette has joined #ruby
claudiuinberlin has joined #ruby
gary_ has joined #ruby
gary_ is now known as Guest71663
jenrzzz has quit [Ping timeout: 256 seconds]
<leitz> dminuoso, I'm still newbie enough to get confused by it. I think this is the third time I've read this chapter and am still grokking "yield".
rexan has quit [Ping timeout: 256 seconds]
Guest71663 has quit [Ping timeout: 276 seconds]
sumobob has joined #ruby
<sumobob> can anyone think of a better way to do something like this? Module::Client.new.get_all.map(&method(:new))
mkroman has quit [Quit: Reconnecting]
mkroman has joined #ruby
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso> sumobob: What is that supposed to do?
<dminuoso> And what are you trying to do?
<sumobob> all those models inherit from faraday middleware
<sumobob> it fetches data from external, and saves it
xenops has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<jamesaxl> hi ruby
quobo has joined #ruby
InfinityFye has quit [Quit: Leaving]
<havenwood> jamesaxl: hi
gary__ has joined #ruby
<dminuoso> leitz: Is the notion of passing functions as values strange to you?
<dminuoso> leitz: like passing callbacks to functions.
<leitz> dminuoso, not strange as in "bad", just getting my head around it. Ruby makes it easier in a way, since everything is an object.
<dminuoso> leitz: Except that's the thing about blocks.
<leitz> I just read about "send".
jenrzzz has quit [Ping timeout: 240 seconds]
<dminuoso> leitz: A block is basically a proc.. except without the object shell.
<dminuoso> leitz: And because it's not an object, you cant ever see it directly.
<dminuoso> But Ruby gives you primitives to somehow use these "invisible" functions. `yield` is basically Proc#call =)
<leitz> dminuoso, hence using the "&" for conversion?
<dminuoso> leitz: Right. & turns either a block into a proc or vice versa.
mtkd has quit []
<dminuoso> leitz: it simply just reifies or strips the object shell.
<dminuoso> def foo(&m) basically means "take the hidden parameter, put it inside an object and name it `m`"
<dminuoso> And when I say object I mean Proc.
gary__ has quit [Ping timeout: 240 seconds]
<dminuoso> And likewise foo(&f) means "take the proc f, throw the Object shell away, and pass it as a block"
<leitz> The book actually explained that bit well. I'm not sure I have it memorized yet, but it gave a pretty simple explination similar to yours.
<leitz> I'm on chapter 3, after 3 weeks. :P
<type1team> Do you know if Jekyll has any channels?
n0m4d1c_ has joined #ruby
<dminuoso> leitz: Basically if blocks throw you off, just rewrite into lambdas.
* leitz is more comfortable with blocks.
<dminuoso> leitz: The main quirky thing is just that visually it does not look like a block is a real parameter, although it kind of is - but it doesn't appear inside params.
<dminuoso> leitz: The reason we have this quirky block syntax that actually just passes another argument has two roots: a) it tends to be a bit cleaner for DSLs and b) its a miniscule performance optimization because no object creation is involved
<dminuoso> I rarely write blocks anymore because they hamper the reading flow
mtkd has joined #ruby
<leitz> The quirkiness doesn't bother me in its existance, just takes me a bit to learn. I mis-stated above; went back to redo chapter 2 because I didn't really get it. Procs and lambdas are in chapter 3. :)
<dminuoso> leitz: If it was up to me I'd throw away Procs. =P
<leitz> I have this mental fantasy of getting a job as a coder one day. Will have to understand other people's code. :/
n0m4d1c has quit [Ping timeout: 256 seconds]
gary has joined #ruby
amatas_ has quit [Remote host closed the connection]
ta_ has joined #ruby
gary is now known as Guest7301
sumobob has quit [Read error: Connection reset by peer]
sumobob has joined #ruby
Guest7301 has quit [Ping timeout: 276 seconds]
suhdood has joined #ruby
alfiemax has quit [Remote host closed the connection]
jenrzzz has joined #ruby
workmad3 has quit [Ping timeout: 248 seconds]
clemens3 has quit [Ping timeout: 248 seconds]
guille-moe has joined #ruby
rcs has quit [Ping timeout: 248 seconds]
rcs has joined #ruby
kenichi has quit [Ping timeout: 248 seconds]
kenichi has joined #ruby
mtkd has quit []
suhdood has quit [Ping timeout: 265 seconds]
conta has joined #ruby
karapetyan has joined #ruby
mostlybadfly has joined #ruby
conta has quit [Remote host closed the connection]
guille-moe has quit [Ping timeout: 265 seconds]
dviola has quit [Quit: WeeChat 2.0.1]
Xeago has quit [Ping timeout: 260 seconds]
mtkd has joined #ruby
* leitz thinks he needs a guidance counselor.
LocaMocha has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
memo1 has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
gary_ has joined #ruby
gary_ is now known as Guest71185
mtkd has quit []
Guest71185 has quit [Ping timeout: 256 seconds]
ogres has joined #ruby
<al2o3-cr> leitz: why would you need a guidence thingymabob?
sumobob has quit [Ping timeout: 252 seconds]
<al2o3-cr> leitz: the more you code the better you'll be
sumobob has joined #ruby
<leitz> al2o3-cr, the amount of learning I need is huge. The idea is to have someone look at my code and let me know what the next big learning "things" are for someone at my level.
<al2o3-cr> it's easy reading code, putting code into a perspective t actually function as it should is hard.
<leitz> I tried looking at the Tk stuff and wasn't able to "get" it. Pretty sure my skill level is less than a 2 on a 1 to 10 scale. Maybe even 1-100. ;)
<jcalla> learning to code takes time
gary has joined #ruby
<al2o3-cr> leitz: stop doubting yourself. pretty sure you understand the basics of ruby?
<jcalla> a lot of trying and failing along the way
gary is now known as Guest79237
* leitz has the failing down pat...
<al2o3-cr> absolutley.
<jcalla> then you're on your way!
<leitz> Sorry if I seem depressed about it; moving to be a coder has been a long, bumpy, and not really successful journey.
<jcalla> what do you currently do?
<leitz> I like Ruby enough to *want* to code in it more than most other leisure activities.
<leitz> jcalla, I'm a linux weenie by trade.
<al2o3-cr> leitz: if you're not sure, just ask.
<jcalla> what do you mean "linux weenie"?
<leitz> jcalla, my RHCE is dated 2003 and I haven't really moved off that track sense.
<leitz> since
AJA4350 has joined #ruby
<jcalla> what did you do with your RHCE?
<leitz> I support Linux servers and make derogatory comments about Java programmers who consume all system resources.
schneide_ has joined #ruby
<jcalla> ahh so you're a sysadmin?
suhdood has joined #ruby
<al2o3-cr> leitz: ruby should be a joy then =)
Guest79237 has quit [Ping timeout: 248 seconds]
<jcalla> if so, then you should start by rewriting your bash scripts in ruby
alfiemax has joined #ruby
<jcalla> then make your own ruby scripts to automate some tasks you do regularly
gary_ has joined #ruby
<al2o3-cr> try doing what ruby does in C my god ...
<jcalla> programming is a means, not an end
<al2o3-cr> ruby is simple
gary_ is now known as Guest17633
sameerynho has joined #ruby
<jcalla> that is how i got really good with programming, writing programs in my previous job to automate tasks that would normally take a while to complete
RougeR has quit [Ping timeout: 256 seconds]
<leitz> jcalla, took the SAGE lists of tasks and the Red Hat objectives and built myself a learning plan. The Ruby certification layout seems a bit light on detail besides "Well-used built-in classes and modules"
<leitz> jcalla, that was the plan until last year. The issue is me getitng tired of people *cough* griping about using an old version of Ruby.
<al2o3-cr> leitz: speak up.
<jcalla> leitz: try the scripting approach first. once you're comfortable with that, try making your way into an upstream ruby-based project that you can also use in your job
nowhereman_ has quit [Read error: Connection reset by peer]
<jcalla> i may be a bit biased, but this is a great community to learn in https://github.com/theforeman
nowhere_man has joined #ruby
<leitz> So I moved to coding a personal project. It holds my best work to date but there's still a lot to do in terms of more code as well as better.
alfiemax has quit [Ping timeout: 240 seconds]
Guest17633 has quit [Ping timeout: 256 seconds]
<al2o3-cr> leitz: better coder comes with experience like anything else. practice makes perfect
<jcalla> great! then keep going. do another project and then even more
<al2o3-cr> and understanding
terens has quit [Ping timeout: 264 seconds]
<al2o3-cr> put anyone in the deep end and they will sink.
<leitz> al2o3-cr, perfect practice makes perfect. My old basketball coach said that. I hate sports.
<al2o3-cr> leitz: but you love ruby
<leitz> Yeah, that's the thing; trying to figure out which bites to chew off next.
<jcalla> you aren't shooting for perfect yet. just good
<al2o3-cr> leitz: baby steps
<jcalla> hell... even working before good!
<leitz> al2o3-cr, yup, really enjoy Ruby. Can't install updated versions at work and many/most tools now don't work on Ruby 1.8.7.
<jcalla> everyone makes mistakes, which is why bugs exist
apeiros_ is now known as apeiros
<al2o3-cr> leitz: you got a computer yourself, install upto date ruby and practice in you spare time.
<jcalla> i work with some amazing developers, but they make mistakes. this is why our bugzilla is always active!
<jcalla> also, don't limit yourself to ruby for the sake of it, if you can't use it at work
phenom has joined #ruby
<jcalla> though if your work allows you to run containers, then you can always isolate a project in one
aufi has joined #ruby
<dminuoso> An environment that forces Ruby 1.8.7 onto you is worth reconsidering.
Dimik has joined #ruby
<leitz> jcalla, my theory is to learn better coding (OOP/TDD) using Ruby. The idea is that the language that inspires me to code gets more code written, even if Python or C are more direclty job related.
<dminuoso> I mean it may be a different story if its some isolated system, but if that's what your IT landscape looks like..
<leitz> In theory possible to move to another language after getting "good enough".
<lupine> leitz: read practical object-oriented design in ruby
<lupine> job done
<leitz> dminuoso, work is 1.8.7 or bust. I told them to use Python. At home it's Ruby 2.6.
<al2o3-cr> leitz: 1.8.7 is older than me
<leitz> lupine, read it twice.
<dminuoso> Ruby 2.6?
<dminuoso> Boy you are fast.
<jcalla> leitz: in my previous job, we had extremely restrictive environments! the only tool i had to use for programming was MS Office applications!
<lupine> sounds like you're all set then
<jcalla> so you bet i wrote a ton of programs for work in excel and access
aufi has quit [Client Quit]
schneide_ has quit [Remote host closed the connection]
<al2o3-cr> python is a cool language
<dminuoso> lupine: I stick to my point.
<dminuoso> If your IT landscape forces Ruby 1.8.7 onto you, it suggests that you are in an antiquated shop.
<al2o3-cr> just prefer ruby
<jcalla> i love python. my primary language. but ruby has some neat tricks and interesting quirks
<leitz> dminuoso, haven't had anyone tell me I'm on an old version in a while. ;)
<lupine> dminuoso: sure, but plenty of those shops exist
<jcalla> 10.times is much nicer than for _ in range(10):
<dminuoso> lupine: Any such shop is worth jumping.
<dminuoso> jcalla: Want to know whats even better?
<lupine> if you have the option, sure
<dminuoso> jcalla: 1.step.lazy
RougeR has joined #ruby
<jcalla> dminuoso: always
<dminuoso> jcalla: That's when the _real_ fun begins.
jenrzzz has quit [Ping timeout: 240 seconds]
<dminuoso> Generate an infinite and gain loop fusion for free.
<leitz> dminuoso, this shop pays the bills and is stable.
<dminuoso> *infinite list
<leitz> We don't use Ruby so version is irrelevant.
<al2o3-cr> dminuoso: like a generator in python?
<dminuoso> al2o3-cr: Nope
<al2o3-cr> ah
<dminuoso> al2o3-cr: It's basically an infinite but lazy list.
<al2o3-cr> you never seem to amaze me mr dminuoso
sumobob has quit [Ping timeout: 260 seconds]
<dminuoso> >> 1.step.lazy.map(&:to_s).map { |e| "Hi " + e }.take(10).map(&:reverse).force
<dminuoso> >> 1.step.lazy.map(&:to_s).map { |e| "Hi " + e }.map(&:reverse).take(5).force
* dminuoso kicks ruby[bot]
<al2o3-cr> take and force?
<dminuoso> oh wait
dminuoso has quit [Changing host]
dminuoso has joined #ruby
<dminuoso> >> 1.step.lazy.map(&:to_s).map { |e| "Hi " + e }.map(&:reverse).take(5).force
<ruby[bot]> dminuoso: # => ["1 iH", "2 iH", "3 iH", "4 iH", "5 iH"] (https://eval.in/959125)
schneide_ has joined #ruby
<dminuoso> al2o3-cr: You dont have to .force usually
sumobob has joined #ruby
<dminuoso> The beauty is that this fuses the loops.
<al2o3-cr> i was gonna say
mcr1 has quit [Ping timeout: 264 seconds]
<al2o3-cr> so simple though
<al2o3-cr> simplicity is one of the greatest things you can do to food.
<al2o3-cr> simplicity is one of the greatest things you can do to food.
<al2o3-cr> oops
<al2o3-cr> like carbonara. simple.
gary__ has joined #ruby
<dminuoso> al2o3-cr: You can do a lot of cool things with it
<dminuoso> like
<al2o3-cr> believe me a played them all =)
* al2o3-cr waits...
* jcalla waits....
jenrzzz has joined #ruby
<leitz> al2o3-cr, jcalla here's a good example of where I struggle. I read dminuoso's code and have not the slightest clue what it does. Part of me assumes this is something for "much later" while another part says "well, do you really have what it takes?"
nadir has joined #ruby
suhdood_ has joined #ruby
<jcalla> leitz: take it one step at a time. and actually say to yourself what each part does
<al2o3-cr> leitz: understand the basics first.
sumobob has quit [Ping timeout: 265 seconds]
<dminuoso> leitz: 1.step.lazy generates an infinite list [1,2,3,4,5,6,7....]
<leitz> al2o3-cr, that's what I'm looking for; the definition of "the basics".
<dminuoso> >> to = -> (t, n) { (n / t).round * t }.curry; 1.step.lazy.map(&to[5]).take(20).zip(1.step.lazy).force # al2o3-cr / jcalla
<ruby[bot]> dminuoso: # => [[0, 1], [0, 2], [0, 3], [0, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [10, 10], [10, 11], [10, 12 ...check link for more (https://eval.in/959126)
<jcalla> leitz: have you done the codeacademy course for ruby? pretty decent intro
<dminuoso> zipping with an infinite series is a cleaner and more combinator way of doing .with_index
gary__ has quit [Ping timeout: 264 seconds]
suhdood has quit [Ping timeout: 260 seconds]
<al2o3-cr> dminuoso: you're doing to much haskell =)
sumobob has joined #ruby
<dminuoso> al2o3-cr: heh
<dminuoso> al2o3-cr: Did you see my https://eval.in/959123 ?
<leitz> jcalla, my code passed Travis-CI, how's that? :)
<al2o3-cr> dminuoso: yeah :p
<dminuoso> :P
<leitz> And I do better learning from books.
<jcalla> leitz: what do you mean?
<dminuoso> al2o3-cr: You should see my other library..
<jcalla> for an upstream project?
<al2o3-cr> but dminuoso ruby isn't haskell ;)
<dminuoso> al2o3-cr: Ruby has a fairly strong FP influence
<al2o3-cr> even how nice it is
<leitz> jcalla, I read a few TDD things and started writing tests before code. Sandi Metz's "99 Bottles of OOP" was a great help too.
<dminuoso> Im just turning on the knob a bit
<dminuoso> al2o3-cr: And honestly what Im doing is very basic FP stuff, nothing advanced.
<leitz> Big lesson is "change one line at a time". I really needed that as I often confused myself.
<jcalla> dminuoso: you should play around with brainf*ck
<dminuoso> al2o3-cr: The real crazy stuff is not possible because it mostly relies on a powerful type system.
<al2o3-cr> dminuoso: you can't even do `def foo; def bar; return :blah; end; end`
<leitz> jcalla, so I keep my project on github and linked it to Travis-CI to test on pushes.
<jcalla> leitz: and you write your own tests?
<dminuoso> al2o3-cr: Im an AMP proponent, so it's pure all the way.
<leitz> Though I need to figure out how to test for a bug I found a few days ago.
<leitz> jcalla, yep.
alfiemax has joined #ruby
<dminuoso> al2o3-cr: If I had used my Q library some of it would have been cleaner because it monkey patches half of ruby core to curry properly and accept lambdas everywhere.
<jcalla> leitz: then you're further along than you think
<dminuoso> al2o3-cr: I even have fully polymorphic functions like.. fmap or pure work for any Functor/Monad/Applicative.
<al2o3-cr> fp in is not
sumobob has quit [Ping timeout: 240 seconds]
<al2o3-cr> python lua maybe
<dminuoso> al2o3-cr: Reality begs to differ, FP is coming back more and more. :)
<leitz> I have, but haven't comprehedned, Binder's "Testing OO systems", Have read Beck's TDD book.
<leitz> Set Binder aside for a little bit as I moved from 1.8.7 to 2.6.
<dminuoso> al2o3-cr: Even if you look at the most popular languages, the FP influence is high. C++ type system takes a lot of inspiration, they got optional types, lambdas, higher kinded types..
dviola has joined #ruby
<dminuoso> Java - same stuff (no HKTs though), they even have interfaces (which are kind of like C++ concepts or Haskell typeclasses)
<dminuoso> A lot of the core libraries in those languages have been transformed into HOFs
<dminuoso> C++ is slowly moving away from iterator pattern to more <algorithm> heavy stuff using lambdas
<al2o3-cr> dminuoso: yeah, ruby is based on message sending and no way in fp paradigm whatsoever.
<dminuoso> al2o3-cr: It absolutely is.
<dminuoso> Every time you use a block
<dminuoso> It's a higher order function.
<al2o3-cr> a closure in fp
<weaksauce> leitz eloquent ruby is a great book if you are looking for something that touches on the basics and good practices
<dminuoso> al2o3-cr: The closure is not the important part.
<dminuoso> The HOF part is.
<dminuoso> The fact that you pass functions as values is one of the main driving ideas of FP.
<dminuoso> and foo.map { |e| e * 2 } passes a function to map.
alfiemax has quit [Ping timeout: 256 seconds]
Xeago has joined #ruby
<al2o3-cr> dminuoso: you're probably right =)
<dminuoso> The fact that we have Proc with #curry gives you the remaining power to use this
<dminuoso> >> to = -> (t, n) { (n / t).round * t }.curry; 1.step.lazy.map(&to[5]).take(20).zip(1.step.lazy).force
<ruby[bot]> dminuoso: # => [[0, 1], [0, 2], [0, 3], [0, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [10, 10], [10, 11], [10, 12 ...check link for more (https://eval.in/959127)
<dminuoso> Is pure ruby and FP centric.
gary__ has joined #ruby
locsmif has joined #ruby
<dminuoso> The main problem is just purity in that Ruby allows referentially intransparent functions, mutation of arguments
<dminuoso> You can think of Ruby as an amalgation of Smalltalks message sending and FP ideas.
<dminuoso> Its just that most ruby developers dont dive deep into the latter
<al2o3-cr> i understand your ideas
drewmcmillan has joined #ruby
clemens3 has joined #ruby
<leitz> weaksauce, I had a short but pleasent e-mail chat with Russ Olsen. Have both ER and his Design Patterns book. Working through "Masting Ruby Closures" and need to plan on the next book to dive into after that.
<leitz> Hence my "guidance counselor" note.
<weaksauce> nice leitz... very well written book imo and probably one of the best programming books i have read
gary__ has quit [Ping timeout: 240 seconds]
<leitz> weaksause, ER, DP, or MRC?
<leitz> Have read some of each and like them all.
<weaksauce> ER
<leitz> and I need to spell weaksauce correctly next time.
<weaksauce> haven't seen his dp book.
<weaksauce> weaksalsa
<al2o3-cr> pico de gallo
<weaksauce> just looked up his blog... last post was in 2015...
<dminuoso> al2o3-cr: Also then there's things like flat_map which expose the Monadic interface of Array. ;p
<dminuoso> (or Array#join if you are a categorical theory purist)
<leitz> weaksauce, I like his DP book, same level of easy to read and lots of info.
<dminuoso> Which I think is widely underused.
alfiemax has joined #ruby
<leitz> I would like to use more patterns, but not just for pattern's sake.
Skoom has quit [Read error: Connection reset by peer]
<al2o3-cr> dminuoso: i'm not that smart =)
<leitz> The theory is that it would push me to learn even more.
<dminuoso> al2o3-cr: flat_map { ... } is just map { ... }.flatten
<al2o3-cr> it is.
<weaksauce> looks to be a worthy book leitz
<dminuoso> That's all there is to it. :P
<al2o3-cr> dminuoso: a-ok ;)
<guardian> hello, this is a thing difficult to google: I'm launching a test with bundle exec m ./path/to/test.rb. Inside test.rb I try to use pry but when launching the test the debugger doesn't break. Does someone know how to debug such tests?
mtkd has joined #ruby
reber has quit [Remote host closed the connection]
<morenoh149> is anyone experienced in compiling ruby on osx. I'm having some issues and it's been blocking me for a week now
sumobob has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
<dminuoso> morenoh149: Gist your problem
Psybur_ has quit [Ping timeout: 260 seconds]
<dminuoso> guardian: Normally it should work. If it doesn't break it either means execution never hits that line of code or perhap stdin/stdout is being redirected and you do not see it.
<morenoh149> dminuoso: https://gist.github.com/morenoh149/e774cb45dba51bf257a2c7cec4c97ee6 in the first file, openssl is never found
<leitz> al2o3-cr, Ruby 1.8.7 was released 31 May 2008. :)
xenops has quit [Ping timeout: 240 seconds]
<dminuoso> morenoh149: This might sound obvious but.. have you tried following the instructions?
<morenoh149> dminuoso: I've followed this to the letter https://github.com/postmodern/chruby/wiki/Ruby#installation
<morenoh149> the 2nd set
<dminuoso> morenoh149: Ah mmm.
<dminuoso> morenoh149: Did you install openssl with brew?
<weaksauce> morenoh149 have you considered ruby-install?
<morenoh149> I even did the instructions outlined at https://github.com/raggi/openssl-osx-ca#readme
<weaksauce> seems to work pretty well for me
<morenoh149> dminuoso: yes with brew
<morenoh149> weaksauce: I can try that instead
sumobob has quit [Ping timeout: 276 seconds]
<morenoh149> weaksauce: but ruby-install doesn't list 2.4.2 which is what I need
<dminuoso> morenoh149: That is truly strange.
Papierkorb has joined #ruby
<guardian> dminuoso: nope it doesn't for some reason
mcr1 has joined #ruby
<dminuoso> morenoh149: What are you compiling from?
<weaksauce> morenoh149 it does for me
<weaksauce> update your ruby install?
<morenoh149> weaksauce: I did ruby-install -L is that enough?
Papierkorb has left #ruby ["Konversation terminated!"]
<weaksauce> or just do ruby-install ruby-2.4.2 and see what happens
<dminuoso> weaksauce: Honestly "dont use the vanilla way" is not a real good solution in #ruby
<dminuoso> This should work.
<weaksauce> dminuoso well if banging your head into the wall for a week is the vanilla way perhaps a change of course is applicable
* leitz steps away for a bit.
amatas has quit [Quit: amatas]
jenrzzz has quit [Ping timeout: 256 seconds]
<dminuoso> weaksauce: Ive never had a single problem with this. If there are issues that block users from compiling the most recent version, it's a bug and needs fixing.
amatas has joined #ruby
<dminuoso> or it's some system misconfig
<morenoh149> I'll try 2.4.3 and see what happens
<weaksauce> i've seen openssl problems all the time
<morenoh149> I thought maybe it was a discrepancy between zsh and bash but both have access to the homebrew ssl
<dminuoso> morenoh149: What revision are you compiling from?irb
<dminuoso> oops ignore that
<dminuoso> Was trying to redraw =)
<dminuoso> morenoh149: What's your RUBY_PLATFORM?
Antiarc_ has joined #ruby
<morenoh149> dminuoso: empty
<dminuoso> morenoh149: That sounds wrong.
gary has joined #ruby
<morenoh149> as an env var?
<dminuoso> morenoh149: No inside Ruby ;
<dminuoso> ;)
gary is now known as Guest53393
<dminuoso> It should read "x86_64-darwin17"
<morenoh149> => "x86_64-darwin15"
kapil___ has quit [Quit: Connection closed for inactivity]
Antiarc_ has quit [Client Quit]
amatas has quit [Client Quit]
Antiarc has quit [Remote host closed the connection]
amatas has joined #ruby
n008f4g_ has joined #ruby
<weaksauce> morenoh149 did you add the path to your ssl libs?
Antiarc has joined #ruby
<weaksauce> to your .zshenv
Guest53393 has quit [Ping timeout: 240 seconds]
<dminuoso> weaksauce: Its not necessary
<weaksauce> well. in the time we just talked i installed 2.4.3 using ruby-install
<morenoh149> all I added to .zshrc is source /usr/local/share/chruby/chruby.sh; source /usr/local/share/chruby/auto.sh
<morenoh149> me too
<weaksauce> ¯\\_(ツ)_/¯
<dminuoso> morenoh149: `grep SSL_library_init "$(brew --prefix openssl)/include/openssl/ssl.h"`
Antiarc has quit [Client Quit]
<dminuoso> does this produce a result for you?
Antiarc has joined #ruby
nowhere_man has quit [Ping timeout: 268 seconds]
<morenoh149> dminuoso: 3 lines
Antiarc has quit [Client Quit]
Antiarc has joined #ruby
<morenoh149> so I installed ruby 2.4.3p205 and chruby into it, but when running the project `bundle install` I get Your Ruby version is 2.5.0, but your Gemfile specified 2.4.2
alfiemax has joined #ruby
Antiarc has quit [Client Quit]
<dminuoso> morenoh149: Be sure to rehash
<dminuoso> morenoh149: Otherwise you might get the wrong bundle binstub
<dminuoso> At least with rails I've had weird issues like that before.
<morenoh149> how do you rehash
<morenoh149> well I can search
<dminuoso> morenoh149: just `rehash` in your zsh
workmad3 has joined #ruby
gary_ has joined #ruby
<morenoh149> til
<dminuoso> morenoh149: You should _actually_ get a command not found error since you probably have not installed the `bundle` gem for your new gem version
Antiarc has joined #ruby
Antiarc has quit [Remote host closed the connection]
gary_ is now known as Guest60620
Antiarc has joined #ruby
xfbs has joined #ruby
sumobob has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
synthroi_ has joined #ruby
workmad3 has quit [Ping timeout: 248 seconds]
Guest60620 has quit [Ping timeout: 265 seconds]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<morenoh149> dminuoso: I chruby into 2.4.2 and still get `Your Ruby version is 2.5.0, but your Gemfile specified 2.4.2`
<dminuoso> morenoh149: Did you `rehash` again?
<morenoh149> to clarify I have compiled and installed 2.4.2 but without openssl (because it wasn't found)
<morenoh149> dminuoso: just did, same error
<dminuoso> morenoh149: What does `which bundler` give you?
alfiemax has joined #ruby
synthroid has quit [Ping timeout: 276 seconds]
delaz has left #ruby [#ruby]
<morenoh149> /usr/local/bin/bundler
<weaksauce> morenoh149 do gem install bundle and then run bundle again
<weaksauce> er s/bundle/bundler
jnollette has quit [Ping timeout: 255 seconds]
<weaksauce> bundler for me fell back to system ruby when there wasn't a gem for it for the current ruby
<morenoh149> `ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository` probably due to lack of https support
<dminuoso> morenoh149: That's the problem. You have a global installation shadowing your chruby's PATH.
alfiemax has quit [Ping timeout: 248 seconds]
<morenoh149> dminuoso: so do I have to fix whatever is updating the PATH or is the PATH updated dynamically by chruby?
<dminuoso> morenoh149: Lets fix the actual problem and build ruby with OpenSSL
jnollette has joined #ruby
<dminuoso> morenoh149: I think I found the problem
<dminuoso> morenoh149: Do you happen to have pkg-config from brew?
ldnunes has quit [Quit: Leaving]
<morenoh149> dminuoso: yes
<dminuoso> morenoh149: That's the issue on 2.4.2. Unlink pkg-config from brew, install, then relink again
<dminuoso> Or do anything to prevent ruby from picking up that brew's pkg-config =)
<morenoh149> dminuoso: unlink: pkg-config: No such file or directory
<dminuoso> morenoh149: no with brew.
<dminuoso> morenoh149: `brew unlink pkg-config`
<morenoh149> got it
biberu has quit []
<morenoh149> then recompile ruby?
<dminuoso> morenoh149: just `make` should be sufficient
<dminuoso> you might have to `make clean` first if it doesn't work
<morenoh149> still `../.././ext/openssl/extconf.rb:0: Failed to configure openssl. It will not be installed.`
<morenoh149> I ran make from the downloaded 2.4.2 sourcecode
<dminuoso> morenoh149: do a fresh configure
<dminuoso> its possible that the relevant paths are set at configure time
RougeR has quit [Ping timeout: 256 seconds]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<morenoh149> it's likely
<morenoh149> running ./configure --prefix="$HOME/.rubies/ruby-2.4.2" --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm):$(brew --prefix libffi)"
suhdood_ has quit [Ping timeout: 276 seconds]
n0m4d1c_ has quit [Ping timeout: 252 seconds]
alfiemax has joined #ruby
jenrzzz has quit [Ping timeout: 276 seconds]
<morenoh149> looks good! running make install
<dminuoso> morenoh149: Remember to relink your pkg-config if you want (the bug is fixed in later ruby versions)
alfiemax has quit [Ping timeout: 264 seconds]
<morenoh149> dminuoso: how do I fix the `Your Ruby version is 2.5.0, but your Gemfile specified 2.4.2` when running bundle install?
<morenoh149> I've chruby into the 2.4.2 I just compiled
<morenoh149> I also rehash
<dminuoso> morenoh149: Its not a rehash problem
<dminuoso> morenoh149: its a PATH problem
<dminuoso> morenoh149: Make it so your system ruby is not at the front.
<dminuoso> morenoh149: Or probably you are just missing the `bundler` gem
<dminuoso> which causes zsh to keep searching and find it in the systems ruby
hfp_work has quit [Ping timeout: 240 seconds]
<morenoh149> I shared my path here https://gist.github.com/morenoh149/e774cb45dba51bf257a2c7cec4c97ee6 does it look alright?
sameerynho has quit [Ping timeout: 260 seconds]
<dminuoso> morenoh149: You are simply just missing the gem `bundler` in your ruby version,
gary__ has joined #ruby
<dminuoso> morenoh149: gem install bundler
<dminuoso> and you are good.
<morenoh149> yeah just verified what chruby actually does to the path
RougeR has joined #ruby
dvdingus has joined #ruby
hfp_work has joined #ruby
WA9ACE has joined #ruby
jamesaxl has quit [Quit: WeeChat 2.0.1]
WA9ACE is now known as Guest5352
gary__ has quit [Ping timeout: 260 seconds]
Guest5352 is now known as WA9ACE
suhdood_ has joined #ruby
suhdood_ has quit [Client Quit]
alfiemax has joined #ruby
shinnya has joined #ruby
RougeR has quit [Quit: Leaving]
RougeR has joined #ruby
RougeR has joined #ruby
RougeR has quit [Changing host]
RougeR has quit [Read error: Connection reset by peer]
alfiemax has quit [Ping timeout: 265 seconds]
RougeR has joined #ruby
RougeR has joined #ruby
RougeR has quit [Changing host]
synthroi_ has quit []
ams__ has quit [Quit: Connection closed for inactivity]
alfiemax has joined #ruby
guille-moe has joined #ruby
memo1 has quit [Ping timeout: 256 seconds]
Gnut has joined #ruby
bijan_ has joined #ruby
n0m4d1c has joined #ruby
memo1 has joined #ruby
jcalla has quit [Quit: Leaving]
n0m4d1c has quit [Remote host closed the connection]
n0m4d1c has joined #ruby
dalitom has quit [Ping timeout: 260 seconds]
alfiemax has quit [Ping timeout: 276 seconds]
tomphp has joined #ruby
mrBen2k2k2k has quit [Ping timeout: 256 seconds]
guille-moe has quit [Ping timeout: 276 seconds]
ta_ has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
ta_ has joined #ruby
gary has joined #ruby
devil_tux has joined #ruby
gary is now known as Guest41364
Guest41364 has quit [Ping timeout: 264 seconds]
cagomez has joined #ruby
schneide_ has quit [Remote host closed the connection]
alex`` has quit [Quit: WeeChat 2.0.1]
devil_tux has quit [Quit: leaving]
alex`` has joined #ruby
eightlimbed has joined #ruby
theo_ has joined #ruby
theo_ has quit [Remote host closed the connection]
devil_tux has joined #ruby
dvdingus has quit [Ping timeout: 256 seconds]
amatas has quit [Quit: amatas]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Xeago has quit [Ping timeout: 240 seconds]
Xeago has joined #ruby
mtkd has quit [Ping timeout: 264 seconds]
tomphp has joined #ruby
bijan_ has quit [Quit: System has gone to sleep. ZZZzzz…]
gary has joined #ruby
gary is now known as Guest98895
nowhere_man has joined #ruby
roshanavand has quit [Ping timeout: 256 seconds]
Guest98895 has quit [Ping timeout: 240 seconds]
nowhereman_ has joined #ruby
nowhere_man has quit [Ping timeout: 268 seconds]
houhoulis has joined #ruby
devil_tux has quit [Quit: leaving]
electrostat has quit [Quit: uwotm8]
electrostat has joined #ruby
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
devil_tux has joined #ruby
<cagomez> is there a way to reference an implicit block that was passed to a method?
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
workmad3 has joined #ruby
<dminuoso> cagomez: three methods
<dminuoso> cagomez: a) you bind it into an argument using &
<dminuoso> b) you can yield it
<dminuoso> c) you can use Proc.new without a block (which will implicitly try to grab the block passed to the current method)
alex`` has quit [Ping timeout: 256 seconds]
<dminuoso> >> def f; Proc.new; end; a = f { puts "Hi" }; a.()
<ruby[bot]> dminuoso: # => Hi ...check link for more (https://eval.in/959159)
yokel has quit [Remote host closed the connection]
alex``` has quit [Ping timeout: 260 seconds]
devil_tux has quit [Quit: leaving]
<dminuoso> Dunno about exact details when you try to use Proc.new in different edge cases.
devil_tux has joined #ruby
<cagomez> dminuoso: I was trying to inspect what the block given was when I passed in `&:then` to `and_then` here: https://repl.it/repls/SvelteInsubstantialAfkgaming
yokel has joined #ruby
<cagomez> what exactly is happening on line 9?
<dminuoso> cagomez: Well you can reify blocks using the first and last method I just mentioned, but it will not really help you because you can't tell much about a Proc beyond its arity.
workmad3 has quit [Ping timeout: 248 seconds]
<dminuoso> cagomez: So & is the block<>proc conversion operator
<cagomez> ^ is &:upcase converting :upcase to a block?
xelkarin has joined #ruby
<dminuoso> cagomez: &:foo calls Symbol#to_proc which is implemented as class Symbol; def to_proc; proc{ |s| s.public_send(s) }; end
<dminuoso> (or .send Im not sure from the top off my head)
<dminuoso> And then it strips the Proc object away, turning it into a Block.
<cagomez> excellent, nice. so @value is being passed in as `s` in that proc?
<dminuoso> cagomez: Yes.
clemens3 has quit [Ping timeout: 240 seconds]
<dminuoso> >> class Integer; def to_proc; proc{ |e| e[i] }; end; end; [[0,1,2],[3,4,5]].map(&0)
<ruby[bot]> dminuoso: # => [0, 3] (https://eval.in/959160)
<dminuoso> cagomez: ^- As a random other example.
<dminuoso> So you can see you can implement to_proc for anything.
<cagomez> so is line 9 essentially passing @value as a param to whatever block was passed in?
<dminuoso> cagomez: Yes.
<dminuoso> Well, @value.dup
<cagomez> (as if the block were a method)
<dminuoso> cagomez: You can think of blocks as (hidden) procs.
<dminuoso> As (hidden) arguments.
<dminuoso> Because semantically and implementation wise thats exactly what blocks are.
<cagomez> how did your example above work? I can't tell what it's doing
<dminuoso> cagomez: The same thing as with Symbol#to_proc basically
<dminuoso> & turns something into a Block
<dminuoso> In order to do that, it tries to convert it into a Proc first by trying to use #to_proc on it.
jenrzzz_ has joined #ruby
<dminuoso> So the objects class must have #to_proc implemented
<dminuoso> I implemented it
<dminuoso> class Integer; def to_proc; proc{ |e| e[i] }; end; end;
<hanmac> &:symbol has some extra magic that it does not create a Proc if you only use the Block with yield
<cagomez> what is `i` though?
<cagomez> and does Integer not implement `to_proc` already? or did you just monkeypatch it by opening the class?
RougeR has quit [Ping timeout: 248 seconds]
<dminuoso> cagomez: Oh me being absolutely lazy. Imagine that was `self`
<dminuoso> cagomez: I just monkey patched it.
jenrzzz has quit [Ping timeout: 240 seconds]
<dminuoso> cagomez: I abused the fact that Integer is a Numeric and implements: http://ruby-doc.org/core-2.4.0/Numeric.html#method-i-i
<dminuoso> And then I abused the fact that Ruby has extremely weak typing.
learning-ruby has joined #ruby
<dminuoso> thus saving myself 3 characters.
<cagomez> what is the `i` in `e[i]`?
<dminuoso> cagomez: It turns `self` into an imaginary number :D
<learning-ruby> In the Ruby source code, what is the directory /ext for?
<cagomez> ah right. that's another syntax for .call, right?
<dminuoso> learning-ruby: Extensions.
n008f4g_ has quit [Ping timeout: 248 seconds]
<dminuoso> cagomez: For Proc yes, but thats not what Im doing.
<weaksauce> i does fail if called with anything other than 0 though.
<dminuoso> cagomez: Basically my Integer#to_proc is under the assumption that the argument to the proc is some container type.
<dminuoso> In particular an Array
<learning-ruby> dminuoso: thanks pal
<dminuoso> weaksauce: Yeah.
<weaksauce> self works in the general case
<cagomez> is there a way to make my own operator , such as :|, and alias it to my `and_then` method?
<dminuoso> Its just a weird habit I guess ¯\_(ツ)_/¯
<dminuoso> cagomez: def |
<dminuoso> cagomez: Or call it and_then and create an alias using
<dminuoso> &ri alias_method
<dminuoso> Someone should probably update this
<learning-ruby> If I want to only have in the Ruby source code directory the Ruby core classes, what directories should I remove? (ex: lib, ext...)
* dminuoso looks at adaedra
<dminuoso> learning-ruby: The root directory of the repository.
<dminuoso> learning-ruby: It's mostly spread out in those files. hash.c for example contains most of the implementation for Hash
<cagomez> where can I find a list of operators that are being used by Ruby? Is there a way to scope my new operator to this class?
<cagomez> ignore the first question ^
<dminuoso> cagomez: operators are just methods.
<dminuoso> cagomez: `a | b` is just syntax sugar for a.|(b)
<learning-ruby> dminuoso: oh, so if I ignore all of the directories and run rdoc on the root files only, it will give me all core classes?
gary_ has joined #ruby
<dminuoso> learning-ruby: I dont know whether it will be _all_, but most yes.
<cagomez> ah nice. is there an operator that you can suggest for this class? I like elixir's |>
<learning-ruby> tks again :)
devil_tux has quit [Quit: leaving]
gary_ is now known as Guest53604
<dminuoso> cagomez: >, >>, <, <<, |, &, **, >=, <=, =~, !~
<dminuoso> Oh and ^
<dminuoso> cagomez: Also a cool trick I use is to use lambdas as argument together with >>, > and >=
ferox has joined #ruby
<dminuoso> cagomez: that allows me to make code look like: m >-> e { puts e }
<dminuoso> m >=-> e { puts e }
<dminuoso> m >>-> e { puts e }
<dminuoso> m <-> e { puts e }
<dminuoso> m <<-> e { puts e }
<dminuoso> m <=-> e { puts e }
bijan_ has joined #ruby
Guest53604 has quit [Ping timeout: 240 seconds]
xelkarin has quit [Quit: WeeChat 1.9.1]
alfiemax has joined #ruby
xelkarin has joined #ruby
<xelkarin> #sgvlug
<dminuoso> cagomez: If you want something like elixir's |> I have something better for you.
<cagomez> what is that doing, exactly? are >>, >, >= your own operators, or does Ruby do something special when used with a lamba? I'm not sure what those snippets are doing
<dminuoso> cagomez: Its just a syntax trick. They do whatever I want
moei has quit [Quit: Leaving...]
<dminuoso> cagomez: class Proc; def *(o); ->(x) { self[o[x]] }; end; end
<craysiii> m O-|-< e { puts e }
ferox has quit [Changing host]
ferox has joined #ruby
<craysiii> m O-\-< e { puts e }
<craysiii> m O-/-< e { puts e }
<dminuoso> cagomez: That thing is essentially the same as |> except in reverse and point free.
<dminuoso> cagomez: if you want _exactly_ |> then upgrade to ruby 2.5
snath has quit [Ping timeout: 256 seconds]
<cagomez> ah ok. I really want to define my own operator but I have to consider others that will be working with this class, so I think I'll keep `and_then`
<dminuoso> You could even create a refinement to do: class Object; def -(l); yield_self(&l) end; end
<dminuoso> And then go crazy: object |-> (o) { o.increase } |-> (v) { ... }
<dminuoso> not sure whether that will parse
<dminuoso> Seems so.
<dminuoso> cagomez: Proc#* is a safe monkey patch.
alfiemax has quit [Ping timeout: 264 seconds]
<dminuoso> cagomez: *and_then is already implemented in Ruby 2.5 as yield_self :)
<cagomez> ah ok, thanks for your help. I've been playing with procs, lambdas, and I feel like I unlocked a new part of the language
<cagomez> seriously wow
<dminuoso> and with my miniscule hack you can make it look cool
<dminuoso> object |-> doubleIt |-> halfIt |-> takeSquareRoot |-> printIt
<dminuoso> Is what I ideally would want
<cagomez> yeah that looks great
<dminuoso> cagomez: So with Proc#* you would do this:
<dminuoso> t = printIt * takeSquareRoot * halfIt * doubleIt; t.(object)
<dminuoso> If you prefer you can also create Proc#>> like
<dminuoso> class Proc; def *(o); ->(x) { o[self[x]] }; end; end
<dminuoso> And do it
<dminuoso> t = doubleIt >> halfIt >> takeSquareRoot >> printIt; t[object]
<dminuoso> or >> and <<
<dminuoso> cagomez: And while we're at cool things
<dminuoso> &ri Proc#curry
<dminuoso> Most useful method in Ruby
eightlimbed has quit [Ping timeout: 256 seconds]
<cagomez> +1, I got to it use to curry a proc that I pass in to this class
zapata has quit [Quit: WeeChat 2.0.1]
<dminuoso> cagomez: And if thats not functional enough for you, you can take it to the next level with this: https://gist.github.com/dminuoso/b124a441ea1933cfb8c0e788091804fa
<dminuoso> Autocurrying methods
<dminuoso> defc :add { |a, b| a + b }
<dminuoso> `add` gives you a curried lambda. `add 2` gives you a curried lambda, applied with one argument
<cagomez> what is the use case?
RougeR has joined #ruby
RougeR has joined #ruby
RougeR has quit [Changing host]
<dminuoso> cagomez: I hate having to specify .() or [] when invoking lambdas
sumobob has quit [Ping timeout: 248 seconds]
<dminuoso> cagomez: But at the same time I want to be able to use a method as first class value (without having to go through the hoops of extracting it with .method() )
karapetyan has quit [Remote host closed the connection]
ghormoon has quit [Ping timeout: 256 seconds]
karapetyan has joined #ruby
<cagomez> so would `add 3` in your example (after `add 2) produce 5?
<dminuoso> cagomez: no you basically use it like
<dminuoso> adder = add 3; puts adder[10]
<dminuoso> Basically this becomes obvious once you start writing combinator functions and higher order functions and use functional composition.
alfiemax has joined #ruby
<dminuoso> But you kind of have to rewrite Proc#call and Proc#[] in order to be really great.
<dminuoso> (You have to rig it to always apply one argument at a time)
<cagomez> ah ok
<dminuoso> Otherwise you have to _know_ whenever you switch between lambdas and introduce a sudden and magical boundary like
<dminuoso> (Q.zipWith * Q.zipWith)[add][ary1, ary2]
<dminuoso> instead of
<dminuoso> (Q.zipWith * Q.zipWith)[add, ary1, ary2]
<dminuoso> I like the second better =)
DLSteve_ has quit [Quit: All rise, the honorable DLSteve has left the channel.]
<cagomez> same. is there a way to pass a non-op block? like yield to a block, but have it do nothing with the arg passed to the block? maybe { |x| x } ?
<dminuoso> cagomez: I have a function called id =)
<dminuoso> Q.id is exactly that
alfiemax has quit [Ping timeout: 248 seconds]
<dminuoso> cagomez: Though you can do this with vanilla ruby already
<al2o3-cr> qiddly
<dminuoso> &ri Object#itself
<dminuoso> cagomez: So you can use
<dminuoso> >> [1,2,3,4].map(&:itself)
<ruby[bot]> dminuoso: # => [1, 2, 3, 4] (https://eval.in/959166)
<al2o3-cr> or sqiggly
<dminuoso> This is mostly useful in this case
<cagomez> ah of course
karapetyan has quit [Remote host closed the connection]
<dminuoso> >> [1, 2, nil, 5, False].select(&:itself)
<ruby[bot]> dminuoso: # => uninitialized constant False ...check link for more (https://eval.in/959167)
<dminuoso> haha too much Haskell
<dminuoso> >> [1, 2, nil, 5, false].select(&:itself)
<ruby[bot]> dminuoso: # => [1, 2, 5] (https://eval.in/959168)
<dminuoso> Even wrote `filter` instead of `select`
jcarl43 has quit [Quit: WeeChat 2.0.1]
<dminuoso> cagomez: https://eval.in/959169 you can have much fun with functional programming in Ruby.
<dminuoso> cagomez: At the bottom you can see my use of >->
<dminuoso> and >>
memo1 has quit [Ping timeout: 240 seconds]
<dminuoso> "Application side" begins at line 306
<cagomez> if I create an alias for `foo` and call it `bar`, do you say that `foo is aliased to bar`, or is it the other way around?
eckhardt has joined #ruby
* dminuoso is not a native speaker and thusly not qualified to answer this question
sumobob has joined #ruby
banisterfiend has joined #ruby
gary has joined #ruby
gary is now known as Guest6903
xfbs has quit []
learning-ruby has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
alfiemax has joined #ruby
maum has joined #ruby
karapetyan has joined #ruby
<cagomez> in `yield @value`, is `@value` being yielded? or is the method yielding to a block and we are just passing @value as an argument?
Guest6903 has quit [Ping timeout: 260 seconds]
<dminuoso> cagomez: `yield @value` is semantically equivalent to: Proc.new.call(@value)
<dminuoso> cagomez: Or these two are equivalent: `def meth; yield @value; end;` `def meth(&blk); blk.call(@value); end;
alfiemax has quit [Ping timeout: 240 seconds]
<dminuoso> cagomez: so if you are just looking for good terminology "the block is called with @value as the argument" ;)
<cagomez> except the latter is supposedly less performant than the former?
<dminuoso> cagomez: the performance is largely irrelevant
<cagomez> (&block.call is slower than yield)?
<cagomez> ah ok. I like the latter because it looks cleaner
<banisterfiend> i still put the &block in the sig even if i'm yielding