donofrio has quit [Remote host closed the connection]
ur5us has joined #ruby
schne1der has joined #ruby
impermanence has quit [Ping timeout: 256 seconds]
infinityfye has quit [Ping timeout: 258 seconds]
infinityfye has joined #ruby
quazimodo has quit [Ping timeout: 246 seconds]
jetchisel has quit [Ping timeout: 264 seconds]
entel has quit [Quit: Connection closed for inactivity]
jetchisel has joined #ruby
jetchisel has quit [Client Quit]
gell5 has joined #ruby
leftylink has quit [Ping timeout: 256 seconds]
tris has quit [Ping timeout: 256 seconds]
leftylink has joined #ruby
tris has joined #ruby
gell5 has quit [Ping timeout: 258 seconds]
<IsoLinCHiP>
Any suggestions for a job queueing library that supports status and retaining results? Preferably with a SQL DB Backend. I would like to async issue jobs to queues, which other workers can pickup and register their completion/failure back with the system and return some abritrary result data. Delayed_job came close, but doesnt seem to support keeping a record of completed jobs with results.
<xco>
in Ruby when a thread with keys is dead, you can still access the keys, why's that? :/
<havenwood>
xco: a key with cobwebs
<havenwood>
xco: You can still set thread variable keys as well.
<CommunistWolf>
it's data, and it's still around. I can see it being useful for accessing calculations or debugging info prior to disposing of the thread
<xco>
yeah, but for a dead thread this shouldn't be the case no?
<havenwood>
xco: Folk often also confuse fiber variables with thread variables.
<CommunistWolf>
why not?
<havenwood>
xco: The #[] and #[]= are Fiber-local variables.
<xco>
CommunistWolf cause it's uh... dead!
<CommunistWolf>
but it's still allocated
<CommunistWolf>
the runstate is orthogonal to the data
<havenwood>
it's... living dead
<xco>
CommunistWolf interesting
<xco>
havenwood ha!
sagax has joined #ruby
<CommunistWolf>
to put it another way: why would you want to forbid something that would be possible if only you hadn't put the restriction in?
<xco>
this is confusing the sh*t out of me
<CommunistWolf>
should access be forbidden while the thread is paused or sleeping too? it's such a weird thing to link the data to
<CommunistWolf>
like "th read-local" or "current scope"
<CommunistWolf>
$? ? really? *sigh*
<havenwood>
xco: Like CommunistWolf hints, those magic RegExp globals are actually Fiber-local, not Thread-local.
<xco>
CommunistWolf you never get to see these globals around everyday, i've seen ONLY one person use such globals in ruby
<havenwood>
xco: It just happens a new Thread gets a new Fibber.
<CommunistWolf>
xco: I use $? quite a lot
<xco>
havenwood aren't Fibers a spin on threads?
<CommunistWolf>
12 years of professional ruby, and I didn't know it was actually thread-local
<CommunistWolf>
life=suffer
<xco>
havenwood hm!
CrazyEddy has joined #ruby
<havenwood>
xco: A Thread is backed by a real system thread. A Fiber isn't. A thread is self scheduling. A Fiber isn't.
<IsoLinCHiP>
havenwood: Thanks, I did considder logging, but since I would like to orchestrate dependancies between jobs, parsing the logs to get the results for the next stage would be inconvenient. Ill look into the plugin you mentioned, I still havent given up hooking into DJ somehow to add status and result support, but its trickey to dig through all that code
<havenwood>
xco: Fibers are much lighter weight than Threads. I can spin up a few thousand Threads on this laptop but a millions of Fibers until I run out of RAM.
<xco>
havenwood this i didn't know
<havenwood>
xco: A Fiber by default has a 4k stack. You can actually fairly easily set the size to something else though.
<xco>
in all honestly i've never got to write any code that requires a Thread/Fiber :D i'm just learning about these out of boredom, do you have an gem on your repo where you use Threads? i'll like to check it out
<xco>
havenwood ^
<havenwood>
xco: Enumerators are backed by a Fiber under the hood, so `1.upto(3)` spins up a Fiber.
<xco>
yeah that i know
<havenwood>
They're super quick to spin up, thanks in large part to ioquatix's work.
<xco>
i can even implement my own enumerator with fibers
<havenwood>
Isolate.new(bare: true) do |isolate| # Goodbye Threads
<xco>
havenwood wait, is this something coming to Ruby 3? i can't keep up
<xco>
haha
<havenwood>
xco: Yeah, Isolates (Guilds) are Ruby 3.
<havenwood>
xco: Isolates will handle parallel computation and then an Async Fiber Selector for I/O.
<xco>
ok got it...
<xco>
so Threads will vanish completely? havenwood
<havenwood>
xco: Yup, no place for Threads other than backward compatibility. Matz deeply dislikes them, so I recon they'll be gone by Ruby 4.
<xco>
or they plan to keep it for backward compat?
<xco>
ah
<xco>
you read my mind
<havenwood>
xco: Maybe Ruby 5, so more than a decade.
<havenwood>
Perhaps
<xco>
now my i'm thinking what will happen if you dont' do undef Thread
<xco>
:D
<xco>
when using Isolates
<havenwood>
that's just pseudo-code for what "bare" triggers
<xco>
oh
<havenwood>
iir
<havenwood>
xco: So you can just have as many Isolates as you have cores, and Fiber-backed I/O is super if you can suspend the Fiber while you wait like Falcon does with an Async adapter for I/O like DB, disk, network call, etc.
<havenwood>
xco: Falcon can have tons of Fibers, each for a connection and they just suspend while they wait for I/O.
<havenwood>
xco: Great for web servers in general and also for things like WebSockets.
<havenwood>
xco: Going from thousands to millions is awesome.
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
xco: And using all cores without multiple processes is... well, standard these days. :P
<ncakerlist>
"The for loop is rarely used in modern ruby programs." i assume the same is true for while loops.
<ncakerlist>
so finally i got rid of for loop
<leftylink>
the clear reason why `for` is rarely used is that #each does the same. sometimes, you cannot replace `while` with an equivalent. sometimes you can.
<leftylink>
if one would like to create a scope for reasons such as "I don't want a temporary to escape", I am reminded of a conversation I once had in this channel
<leftylink>
2019-10-25 22:45:07 < leftylink> I guess if I wanted temporaries not to escape I could use a function or something
<leftylink>
those interested in such a concept could perhaps look at that conversation for inspiration.
Garb0 has joined #ruby
CrazyEddy has quit [Remote host closed the connection]
Garb0 has quit [Ping timeout: 240 seconds]
CrazyEddy has joined #ruby
Tempesta has quit [Quit: See ya!]
Tempesta has joined #ruby
drincruz has joined #ruby
jingjinghack has quit [Quit: WeeChat 2.1]
bsdbandit-01 has quit [Ping timeout: 246 seconds]
bsdband79 has joined #ruby
drincruz has quit [Ping timeout: 264 seconds]
AndreYuhai has joined #ruby
<AndreYuhai>
Hey there, can I pass parameters to a proc like: Foo.new.tap(&:set_name('some name')) ?
postmodern has quit [Quit: Leaving]
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has quit [Remote host closed the connection]
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
drincruz has joined #ruby
bsdband79 has quit [Ping timeout: 272 seconds]
teyas has joined #ruby
Benett has quit [Remote host closed the connection]
<al2o3-cr>
ncakerlist: most people use Kernel#loop instead of a while loop.
gdonald has joined #ruby
bsdbandit-01 has joined #ruby
<teyas>
hello family, I am looking for a gem that would help generate UML/Class Diagrams from my ruby source code. I am running Ruby 2.6 on Windows 10. PLEASE HELP.. Tried following ways. 1. Umlify gem - generates 1KB sized PNG which doesn't open. 2. ruby2uml gem - I am not able to understand how to use it (no clear info under "Usage" on rubydoc<dot>info/gems/ruby2uml/0.1.3) 3. ruby-uml gem - it was written and tested with Ruby1.8, so didn't work
<teyas>
4.os6sense/
<teyas>
xumlidot (this is NOT a gem or rubygems<dot>org, its a github repo) - I am again not able to understand whether its a gem, needs installation or not. or whether it will work on Linux with a chmod +x
<al2o3-cr>
bk in 10 marinating tandoori chicken :P
yCrazyEdd has joined #ruby
<xco>
ok
CrazyEddy has quit [Ping timeout: 246 seconds]
yCrazyEdd is now known as CrazyEddy
gell5 has joined #ruby
teyas_ has joined #ruby
<teyas_>
any suggestions?? :(
teyas has quit [Ping timeout: 260 seconds]
gell5 has quit [Ping timeout: 246 seconds]
teyas has joined #ruby
teyas_ has quit [Remote host closed the connection]
teyas has quit [Client Quit]
teyas has joined #ruby
<teyas>
posting the question again
<teyas>
hello family, I am looking for a gem that would help generate UML/Class Diagrams from my ruby source code. I am running Ruby 2.6 on Windows 10. PLEASE HELP.. Tried following ways. 1. Umlify gem - generates 1KB sized PNG which doesn't open. 2. ruby2uml gem - I am not able to understand how to use it (no clear info under "Usage" on rubydoc<dot>info/gems/ruby2uml/0.1.3) 3. ruby-uml gem - it was written and tested with Ruby1.8, so didn't work
<teyas>
4.os6sense/<teyas> xumlidot (this is NOT a gem or rubygems<dot>org, its a github repo) - I am again not able to understand whether its a gem, needs installation or not. or whether it will work on Linux with a chmod +x
<teyas>
os6sense/xumlidot
drincruz has quit [Quit: WeeChat 2.8]
AndreYuhai has quit [Quit: Leaving]
Ishido has joined #ruby
<phaul>
it looks like it's a gem it just wasn't uploaded to rubygems
akem has quit [Ping timeout: 258 seconds]
Ishido has quit [Client Quit]
<phaul>
clone it locally enter it and then gem build to get a gem file. that you can install with gem install
donofrio has joined #ruby
CrazyEddy has quit [Ping timeout: 246 seconds]
chris____ has joined #ruby
troulouliou_div2 has quit [Ping timeout: 256 seconds]
CrazyEddy has joined #ruby
<phaul>
teyas: I just installed it myself and it blows up on it's own source code. so there is that
chris____ has quit [Ping timeout: 256 seconds]
<xco>
phaul really appreciate how you go extra miles to help out!!
troulouliou_dev has joined #ruby
troulouliou_div2 has joined #ruby
ldepandis has joined #ruby
troulouliou_dev has quit [Remote host closed the connection]
gitter1234 has joined #ruby
troulouliou_div2 has quit [Excess Flood]
troulouliou_div2 has joined #ruby
conta has joined #ruby
akem has joined #ruby
Benett has joined #ruby
troulouliou_div2 has quit [Ping timeout: 246 seconds]
entel has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gell5 has joined #ruby
<teyas>
which one ?
<teyas>
phaul: xumlidot ?
codefriar has joined #ruby
troulouliou_div2 has joined #ruby
mikecmpbll has quit [Ping timeout: 265 seconds]
<phaul>
teyas: yes , that's the one I tried
mikecmpbll has joined #ruby
roadie has quit [Remote host closed the connection]
teyas has quit [Read error: Connection reset by peer]
roadie has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
meinside has quit [Quit: Connection closed for inactivity]
teyas has joined #ruby
ChmEarl has joined #ruby
<teyas>
phaul: woww... so there is no solution
<teyas>
phaul: xumlidot gave nice example outputs in that directory
teyas has quit [Read error: Connection reset by peer]
conta has quit [Ping timeout: 240 seconds]
teyas has joined #ruby
xco has joined #ruby
orbyt_ has joined #ruby
Jenny9234 has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Jenny9234>
I've been programming in Ruby for years, but still not found any good resource on how to properly structure a project (lib directory, tests, what goes where, etc)
<Jenny9234>
Does anyone have any blog, video or other suggestions on the topic?
<apotheon>
Jenny9234: The book Eloquent Ruby has some gem structure stuff in it, too.
<Jenny9234>
Thanks apotheon
nychtel has quit [Ping timeout: 260 seconds]
<apotheon>
Jenny9234: I'm guessing you know about the standard relationship of names to file hierarchies, too, but in case you don't check out this as well . . .
<phaul>
teyas: you can try installing it yourself, it might work for you. follow the steps I described
<Jenny9234>
I didn't actually. That's really useful to know!
<phaul>
teyas: if it doesn't work just do gem uninstall not much to lose
<apotheon>
Jenny9234: I'm glad I could help.
leitz has joined #ruby
<Jenny9234>
Thank you, I appreciate it
teyas has quit [Read error: Connection reset by peer]
nychtel has joined #ruby
nychtel has quit [Ping timeout: 246 seconds]
nychtel has joined #ruby
chris__ has joined #ruby
braj has quit []
dionysus69 has quit [Ping timeout: 256 seconds]
teyas has joined #ruby
mikecmpbll has quit [Ping timeout: 246 seconds]
leah2 has quit [Ping timeout: 256 seconds]
mikecmpbll has joined #ruby
rtyler has joined #ruby
<rtyler>
greetings, I was hoping somebody might be able to help me understand some behavior with SSLSocket that I am seeing.
<rtyler>
basically when I pipe 100 lines of data to openssl s_client, it ensures that all 100 lines are received by the server before disconnecting
<rtyler>
when I use the following ruby script: https://gist.github.com/rtyler/32968c568369b9376ec602855273d191 it seems to not be flushing and waiting for the connection to properly terminate, such that the receiving server will receive some number of messages between 1-100 and then a "Connection reset by peer" error.
<jhass>
rtyler: did you try close instead of sysclose?
<rtyler>
I did just now, it exhibits the behavior unfortunately
<jhass>
mmh
<jhass>
I see nothing wrong unfortunately
<jhass>
net/http wraps the whole afair into BufferedIO, but I can't really imagine that to make a difference
<jhass>
otherwise it does pretty much exactly what you do
<rtyler>
yeah, I'm quite perplexed, I have no idea what openssl s_client is doing differently, and I'm loathe to dive into that mess of C
r29v has joined #ruby
imode has joined #ruby
cyrus_mc_ has joined #ruby
gell5 has joined #ruby
schne1der has quit [Ping timeout: 240 seconds]
<rtyler>
preplexion continues >_<
gell5 has quit [Ping timeout: 260 seconds]
<teyas>
phaul: I dont see the steps, could u please paste them again ?
<ncakerlist>
ok i understood p now, jhass as you said p(x) is puts(x.inspect)
<jhass>
I wouldn't think of the return value f inspect to be a "raw" value or so. It's just a string that wants to help you understand what the object is
<jhass>
puts 1; and puts "1"; look the same, but p(1) and p("1") help you to understand what's the number and what's the string
<ncakerlist>
i searched about ruby on duckduckgo , i got youtube recommendations of ruby on mobile wtf
xco has joined #ruby
<ncakerlist>
you can't escape google even if you don't use google.com
Fusl has quit [Max SendQ exceeded]
Fusl has joined #ruby
ncakerlist has quit [Read error: Connection reset by peer]
ellcs1 has joined #ruby
ncakerlist has joined #ruby
infinityfye has quit [Quit: Leaving]
<ncakerlist>
can i use ruby as a shell
<jhass>
sure
<jhass>
irb
<jhass>
or
<jhass>
?pry
<jhass>
mmh, bot is borked
<jhass>
!pry
<leftylink>
sounds fun!
<jhass>
well, or pry after gem install pry :)
<ncakerlist>
in python i need to import sys,os and then if sys.os i just can't mkdir folder to make a directory and closing and opening files too is a pain... i just gave up on python
<ncakerlist>
how is ruby different in terms of system control than python then.
<leftylink>
ahhhhh so the goal is to make things like that easy...! thta is very interesting. since a naive way one might think of doing it is "if I can't do it in pure ruby, then I'll just use backticks, that only two extra characters"
<leftylink>
BUT
<leftylink>
BUT
<leftylink>
what if I then decided "what if I want to not have to type the backticks"
<leftylink>
then maybe one would craft a particular method_missing that automatically backticks it
<leftylink>
:0 :0 :0 :0 :0
<leftylink>
WHOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
<jhass>
mmh, where did the Shell stdlib go?
<jhass>
anyways, include FileUtils should get you pretty far
postmodern has joined #ruby
<leftylink>
NOTE that I have NOT attempted to make such a method_missing myself since I need to figure out how it is to handle things like a b c where I think method_missing will be invoked for each of a, b, c... and I think the result for a will need to be substantially different than that for b and c
<leftylink>
I will give it a try now!
<leftylink>
very exciting task!
<leftylink>
I thank you for giving me the idea
entel has joined #ruby
<leftylink>
mmm yes, it is a little difficult. for "a b c" for example, first you get the method_missing for c (of course), then for b, then for a (of course)
<leftylink>
so the method_missing needs to have an understanding of this fact
<ncakerlist>
`ls` the output is not pretty?
<ncakerlist>
`ls -l` is even worse
<jhass>
ruby is not meant to be used as a shell :) Neither is python
<jhass>
I mean it's not optimized for this usecase at all
<ncakerlist>
i don't want optimization just basic ability to read the output of ls
<ncakerlist>
is `ls` calling /usr/bin/ls , then why is it scrambled
<jhass>
you see that's already a trade off. Make it easy to read and make it easy to use programmatically are quite different goals. That's why writing shell scripts has so many corner cases to consider
mozzarella has quit [Ping timeout: 246 seconds]
<jhass>
puts `ls`
<jhass>
irb calls inspect just like p
garyserj has joined #ruby
<ncakerlist>
but ls does output newlines so irb does what to swallow them and morph them
<jhass>
nothing
<jhass>
backticks returns the command output as a string
<jhass>
irb calls inspect on that string to show it
barg has quit [Ping timeout: 264 seconds]
SeepingN has left #ruby ["The system is going down for reboot NOW!"]
<ncakerlist>
i also can't changet the directory `cd ..`
<ncakerlist>
Errno::ENOENT (No such file or directory - cd)
<jhass>
yes, cd is a shell builtin, not a comman in /bin or /usr/bin
<ncakerlist>
hmm i new you would say that
<jhass>
FileUtils.cd
<leftylink>
ah adds an interesting twist
<leftylink>
so `cd` will have to be understood
<leftylink>
oh nooooooooooooo
<leftylink>
trouble with "cd .." because .. also indicates a range
<ncakerlist>
can you show me the exmaple with FileUtils
schne1der has joined #ruby
<jhass>
FileUtils.cd("my_directory")
<ncakerlist>
ok can i from FileUtils import cd and then cd 'mydir'
<ncakerlist>
LoadError (cannot load such file -- FileUtils)
<ncakerlist>
require 'FileUtils'
<leftylink>
hey so http://sprunge.us/4BG5Hq is kinda close (require it in irb and good sh*************************t happens
<leftylink>
but
<leftylink>
still can't deal with cd ..
<jhass>
require "file_utils"; include FileUtils
<leftylink>
might need to make my own repl........................... too much work
<leftylink>
................................
<ncakerlist>
sorry i am digressing maybe i should just take light before leaerning basics first...
<ncakerlist>
i have noted it down though.
vondruch has quit [Ping timeout: 260 seconds]
<ncakerlist>
i yet managed to learn the basics given in 20 minute ruby tutorials, i could have never imagined such a feat with python - it tooks me months
reyfi9e has quit [Quit: Konversation term]
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
<jhass>
:)
<ncakerlist>
or maybe i am developing brain muscles after programming python- which was my first langage
reyfi9e has joined #ruby
<jhass>
tbf they're in the same ballpark of languages and learning programming and learning a programming language are two different things that you just happen to do at the same time in the beginning
<jhass>
yeah :)
<leftylink>
now that I look at it, I am pretty sure this donesn't know how to deal with / either
<leftylink>
I could define a particular ArgOrCmd#/ that does the right thing
<leftylink>
but I don't feel like it right now
<jhass>
or maybe recognize the fact that Ruby doesn't want to be a shell :)
<jhass>
alias r='ruby -pe' and live with it
schne1der has quit [Ping timeout: 240 seconds]
gell5 has joined #ruby
bsdbandit-01 has joined #ruby
codefriar has joined #ruby
TCZ has joined #ruby
<leftylink>
hmm
ncakerlist has quit [Read error: Connection reset by peer]
<rubydoc>
stderr: -e:4: syntax error, unexpected ')'... check link for more (https://carc.in/#/r/995r)
<leftylink>
NOPE
<leftylink>
but I guess nobody would have a use for such a range anyway
<leftylink>
so why bother allowing it to be craeted with a literal
ncakerlist has joined #ruby
<leftylink>
coolear heads prevail once again.
bodqhrohro_ has joined #ruby
<leftylink>
we have ot use logic and reason to understand why things are the way they are
bodqhrohro has quit [Ping timeout: 256 seconds]
<leftylink>
and practical considerations
<leftylink>
there can be many complex decisions that go on without our nkowing
<ncakerlist>
how do we make a language that we made make syscalls like shells
<ncakerlist>
making language is easy but i don't know what procedure is used dto make them interace with linux
<jhass>
uh, that question could be answered on many many levels
<jhass>
it kinda depends on what the runtime or backend of your language is
<ncakerlist>
the asiest way is what i prefer
<ncakerlist>
let's say i made scheme then making it is easy but interfacing it with OS
poro has joined #ruby
<ncakerlist>
it takes only one page of code to make a programming language
<jhass>
how did you make your language?
<jhass>
what tools?
<ncakerlist>
you mean lexers/parsers ?
<jhass>
mh, no that's the less interesting part to answer this question
<ncakerlist>
i didn't currently but i think i can make it
<ncakerlist>
what tools are you talking then jhass
<jhass>
the parser and lexer just gives you the AST, you need something that interpretes that AST (an interpreter) or transforms it into some other code (a transpiler)
<jhass>
so whatcha doing with the AST?
<jhass>
how do you run the code of your language?
<ncakerlist>
scheme interpreter what else
<jhass>
so, an interpreter in scheme, cool
inradius has joined #ruby
<ncakerlist>
it takes barely a page of code to make a programming language
<jhass>
what you need to do is have the interpreter know predefined functions
<poro>
do you just map stuff to C stuff?
<jhass>
and call the appropriate scheme functions for these functions
<jhass>
it hooks calling Dir.chdir to the C function
<jhass>
called dir_s_chdir
<jhass>
which in turn calls the syscall chdir
<jhass>
from glibc
<apotheon>
Ruby's great for defining DSLs.
<apotheon>
I just noticed something about writing programming languages. I'm probably somewhat off the topic.
AndreYuhai has joined #ruby
wickedbloodfart has quit [Quit: wickedbloodfart]
<ncakerlist>
can i "freeze" the source code of an interpreter to get machine code ? without needing to make a compiler
<jhass>
no :)
<ncakerlist>
the interpreter too is ultimately giving out machine code so can't we "steal " that from low level underhand yes we can but i would like to
<jhass>
no, what you're describing is called a just in time compiler or JIT for short
<jhass>
an interpreter is exactly not doing that, it's at runtime interpreting the operations
<ncakerlist>
JIT doesn't freeze the script
<jhass>
some languages cheat a bit by generating a binary which embeds the user code and an interpreter for it
<apotheon>
"at runtime" as in "some parts of it don't get jitted until it receives user input"
<jhass>
Ruby doesn't JIT at all (well, until 2.7 where they added some experimental stuff that you need to explicitly enable)
<jhass>
it uses a VM, which is just an internal transformation step to make interpreting a little bit faster
<jhass>
so it doesn't directly interpret user code but an internal bytecode generated from it
<jhass>
but never (outside the experimental JIT) it generates machine code and then points the program counter to it
<ncakerlist>
i used to think every interpreter had a VM
BH23 has quit [Ping timeout: 264 seconds]
<jhass>
no, ruby didn't until Ruby 2.0 :)
inradius has quit [Remote host closed the connection]
<jhass>
it operated directly on the parsed AST (afaik)
<ncakerlist>
which year was ruby 2.0 released
<jhass>
uh, 2013
<ncakerlist>
i am wondering did the performance improve after that due to the VM ?
<jhass>
I mean you'll almost always will have some interpreter state, like a stack and whithin what's the local variables and some heap like place to store objects and stuff, so that's maybe a bit like a VM, but I think most people distinguish it by having it run on some kind of bytecode which is more lowlevel than the user code
<jhass>
I think so, yeah
<jhass>
I mean Ruby's stdlib is majorily C, so maybe not as much as you would think
<jhass>
since most time you spend in stdlib functions really, map this array, add these two numbers, write this to some IO
dionysus69 has quit [Ping timeout: 240 seconds]
inradius has joined #ruby
troulouliou_div2 has quit [Quit: Leaving]
TCZ has quit [Quit: Leaving]
ncakerlist has quit [Ping timeout: 256 seconds]
jottr has joined #ruby
gell5 has joined #ruby
fercell has quit [Quit: WeeChat 2.8]
AndreYuhai has quit [Quit: Leaving]
Jonopoly has quit [Quit: WeeChat 2.8]
<inradius>
learning a bit about module_function (inspired by looking at Ruby's open-uri lib). What's the reasoning behind using module_function to monkey patch Kernel#open? Is it related to Kernel methods are mixins with the top level 'main' object? (wild guess)
<jhass>
module_function is not used to "monkey patch Kernel#open", Kernel#open, like all methods on Kernel, is defined as a module_function, so an overide needs to preserve that
<jhass>
module_function is used in Kernel so the methods are available as both, instance methods by the include Kernel into Object and singleton methods so you can call them as Kernel.open too
<jhass>
the latter being useful in scenarios where you have something shadowing the Kernel#open method or you have a BasicObject subclass for example
jetchisel has joined #ruby
<jhass>
recalling module_function is necessaty because module_function actually makes a copy to the singleton class, not a delegator or so
poro has quit [Quit: Leaving]
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
<inradius>
Is including Kernel into Object what makes calling open() possible?
<jhass>
yeah
<jhass>
because main (the toplevel scope) is just an instance of it
<jhass>
eh, an instance of Object
<jhass>
that makes it work for the toplevel. And then your classes inherit Object of course
<inradius>
makes a lot of sense, but I don't quite understand the wording. This is still a monkey-patch correct? It's modifying the original Kernel#open method to open uri's, is the right way to describe module_function usage here to override the open methods?
ellcs1 has quit [Ping timeout: 260 seconds]
<jhass>
module_function is part of the monkey patch, it's not a way of implementing a monkey patch
<inradius>
got it
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
Garb0 has joined #ruby
<inradius>
btw, where's the source code for how Kernel methods are defined as module_functions?