havenwood changed the topic of #ruby to: Ruby 3.2.2, 3.1.4, 3.3.0-preview1: https://www.ruby-lang.org | Rules: https://ruby-community.com | Logs: https://libera.irclog.whitequark.org/ruby
<mooff> don't forget to run hopes && prayers
<ox1eef_> xD
caedmon has joined #ruby
caedmon has quit [Remote host closed the connection]
Munto has joined #ruby
<johnjaye> i'm reading the semantics of include vs require
<johnjaye> it sort of makes sense. but why can I write "include Math" at the irb prompt and then write log10 instead of Math.log10
<johnjaye> as i understand it this shouldn't do that
filipiz has joined #ruby
<johnjaye> because there's no "class" i'm in at the irb promp
<johnjaye> t
donofrio_ has joined #ruby
<johnjaye> on the other hand I can't require Math or require "Math"
donofrio has quit [Ping timeout: 246 seconds]
weatheredwatcher has joined #ruby
caedmon has joined #ruby
aesthetikx has quit [Ping timeout: 240 seconds]
donofrio has joined #ruby
donofrio_ has quit [Ping timeout: 250 seconds]
caedmon has quit [Ping timeout: 250 seconds]
donofrio_ has joined #ruby
donofrio has quit [Ping timeout: 256 seconds]
caedmon has joined #ruby
caedmon has quit [Ping timeout: 248 seconds]
shokohsc51088 has joined #ruby
shokohsc5108 has quit [Ping timeout: 240 seconds]
shokohsc51088 is now known as shokohsc5108
<ox1eef_> You can write 'include Math' at an irb prompt, and write "log10" instead of "Math.log10". You don't need to require math, it is a core module and available automatically.
<Munto> johnjaye, when you include a Module, all the methods are directly available; so you don't need to prefix them with the module name
<johnjaye> why do i have to write require 'date' and not require 'math'
<johnjaye> is date a gem?
<ox1eef_> And when it comes to irb, or the top level of a script, self is a reference to 'main'. An instance of Object. When you write 'include Math' at the top level, you are including the methods into the Object class. But that's a feature of main, and more complex than I can explain (I don't even fully understand it).
<ox1eef_> Date is both a core class, and a standard library.
<johnjaye> so in a ruby source file what would I do to get cos
<ox1eef_> When you require date, you can importing the features from the standard library, and when you don't it is available as a core class.
<johnjaye> would it be ok to do include Math there?
<ox1eef_> You can do that.
<johnjaye> so date is part of the standard library as is math but math is different somehow
caedmon has joined #ruby
<johnjaye> that's why i thought maybe date is a gem
<ox1eef_> Math is a core module. Every class and module that's available without requiring it is a core module or class.
<johnjaye> i see date in the /usr/lib/ruby/gems tree
<ox1eef_> Date is a core class, but extra features can be required via the standard library (require 'date').
<johnjaye> that's a very strange statement
<johnjaye> how do you get extra features from the standard library
<ox1eef_> So my mistake, maybe that has changed or was never the case, Date is not a core class anymore seemingly, you can have to require 'date' to access it.
<johnjaye> ok. that makes sense. otherwise i would expect to see a 'math' folder in the gems directory
<johnjaye> benchmark, bigdecimal,bundler,cgi,csv,date
<ox1eef_> But something can be a core class or module, and extended by the standard library. That's a feature of Ruby, so why not use it when it makes sense.
<johnjaye> those are the first six gems it my local install
<johnjaye> oh ok. that's true
<johnjaye> hmm. you're saying some of these things like cgi or csv could also be core classes?
<johnjaye> meaning it appears in both the core class and the gem directory?
<ox1eef_> No. Those are standard library only.
<ox1eef_> Whether or not it is core can generally be determined by being able to reference it without requiring anything.
caedmon has quit [Ping timeout: 260 seconds]
<johnjaye> is there a different class you can think of that is both a core class and also can be required for more features
<johnjaye> well. this is more complex than i thought
<ox1eef_> Only Date. Almost sure that was the case once upon a time. But it is no longer the case.
<johnjaye> it says here i have 49 standard gems installed
<johnjaye> but i have a local 2.7
<johnjaye> i was thinking of just installing 3.3 in my /usr/local tree
<johnjaye> abbrev and base64 must have been added since 2.7 then
<ox1eef_> You should install it somewhere where you user can read from and write to, like ~/.rubies/3.3
aesthetikx has joined #ruby
<ox1eef_> If you have any intention to use rubygems, and that's normal in Ruby, you should never run 'gem install <anything>' as root.
<ox1eef_> ./configure --prefix=$HOME/.rubies/3.3; make; make install - and then add $HOME/.rubies/3.3/bin to your $PATH
<johnjaye> apparently the bundled gems are in /usr/lib/ruby/vendor_ruby along with a bunch of other stuff. i assume debian puts it there
<ox1eef_> It does. And that's most likely just the standard library.
<johnjaye> formatador, ffi, kramdown,multi_json
<johnjaye> ah ok i'l recompile with that as the prefix then. thanks
<ox1eef_> Not all of those are stdlib. Maybe none of them actually. Anyway don't bother with debian's ruby, their setup is not good, compile yourself and use a setup similar to what I described.
<johnjaye> how do you run gems on a per version basis
<johnjaye> or it just is in the bin folder already
<filipiz> check rbenv https://github.com/rbenv/rbenv
<ox1eef_> something like bin-name _X.X.X_ <args>.
<johnjaye> ironically debian also has that as a installable package
<johnjaye> gem -v maybe?
<ox1eef_> The ruby ecosystem has tools for these problems, but if you want to keep it simple and stay vanilla, then it's not the time to get into them.
<johnjaye> v for version
<johnjaye> ok
<ox1eef_> What gem executable have you two versions of?
<johnjaye> no i was asking if that's what you do
<johnjaye> meaning. for ruby 2.1 you'd have a gem exe 2.1, 2.2 an exe 2.2, etc
<johnjaye> but it sounds like rbenv tool manages that for you maybe
<ox1eef_> Oh. I see. Without any other tools, and just the configure script, you use --program-suffix=32
<ox1eef_> Then ruby is installed as ruby32, gem32, etc.
<johnjaye> eh. ok
<johnjaye> seems odd to me but hey
<johnjaye> for now i'll just do the command as you described it
<ox1eef_> That's without tools like chruby, and rbenv. You can build and install as many rubies as you want into ~/.rubies/X.X/, and have something like chruby manage switching between them. But without chruby, you would usually use --program-suffix.
<johnjaye> cool.
Linux_Kerio has joined #ruby
filipiz has quit [Quit: Time to sleep :) see you tomorrow]
konsolebox has joined #ruby
konsolebox has quit [Ping timeout: 244 seconds]
_ht has joined #ruby
grenierm has joined #ruby
jmcantrell has quit [Quit: WeeChat 4.0.4]
otisolsen70 has joined #ruby
otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #ruby
_ht has quit [Quit: _ht]
Nixkernal has joined #ruby
Nixkernal has quit [Remote host closed the connection]
Nixkernal has joined #ruby
jmcantrell has joined #ruby
otisolsen70 has quit [Quit: Leaving]
jmcantrell has quit [Client Quit]
otisolsen70 has joined #ruby
otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #ruby
Linux_Kerio has quit [Read error: Connection reset by peer]
Linux_Kerio has joined #ruby
Nixkernal has quit [Remote host closed the connection]
Nixkernal has joined #ruby
shokohsc5108 has quit [Ping timeout: 252 seconds]
shokohsc5108 has joined #ruby
nona has quit [Ping timeout: 252 seconds]
willfish has joined #ruby
nona has joined #ruby
<nona> when running "rspec", all is fine, but when running "rspec spec/blah_spec.rb", it complains like in https://stackoverflow.com/questions/76735349 ... unfortunately the person never received an answer what else to try to solve this. someone here have any idea?
<nona> ("DEPRECATION WARNING: Initialization autoloaded the constants...")
konsolebox has joined #ruby
crespire1 has quit [Ping timeout: 252 seconds]
<nona> HAH!! Solved it!
crespire has joined #ruby
<nona> Genius debugging method: write some gobbledeegook right before the not-yet-loaded constant's definition, then the traceback will show the offending caller :)
cameron_ has joined #ruby
ollysmith has quit [Quit: ZNC 1.8.2+deb3.1 - https://znc.in]
ollysmith has joined #ruby
ollysmith has quit [Client Quit]
ollysmith has joined #ruby
taupiqueur_shiny has joined #ruby
nona has quit [Read error: Connection reset by peer]
cameron_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
leon__ has joined #ruby
nona has joined #ruby
<leon__> I have a module that I use from a rake task, and from tests. I want to use my (rails) ActiveRecord classes in them. How do I wire that together?
grenierm has quit [Ping timeout: 246 seconds]
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
yaw has joined #ruby
Guest23 has joined #ruby
<yaw> i'm wondering if there's a shorthand for the method receiver within the method itself at a call-site.
<yaw> during definition with a class, self.method (or mere method) will retrieve the value you want. but not during a call like instance.method(...)
<yaw> at the call site for instance.method(...) is there a shorthand for accessing instance so that i don't have to write, for example, instance.method(instance.another_method)?
<yaw> it appears that the `instance` is required (in the argument body) mainly because at parse/interpretation time, ruby is doing mainly a textual analysis and so isn't evaluating expressions within the context of instance?
Guest23 has quit [Client Quit]
Linux_Kerio has quit [Read error: Connection reset by peer]
Linux_Kerio has joined #ruby
cameron_ has joined #ruby
cameron_ has quit [Client Quit]
Linux_Kerio has quit [Read error: Connection reset by peer]
Linux_Kerio has joined #ruby
cameron_ has joined #ruby
<pvalenta> Hello, I am playing with Ractor. It looks nice but Ractor.select somehow stops endless loop after one ractor is done. Here is sample code: https://pastebin.com/GvVSu0k1 ...what is wrong with it, please?
<ruby[bot]> pvalenta: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
mx has quit [Quit: ZNC 1.8.2 - https://znc.in]
mx has joined #ruby
<pvalenta> Hello, I am playing with Ractor. It looks nice but Ractor.select somehow stops endless loop after one ractor is done. Here is sample code: https://gist.github.com/xvalen/0f18353c3721a1eb963f5d9ce5a5c73f ...what is wrong with this code, please?
<adam12> leon__: Can you show an example? You should just be able to include the module like you always do.
<adam12> pvalenta: The issue is subtle and hidden away from you. When you `Ractor.select`, it might raise `Ractor::ClosedError`. Which is fine, but that exception inherits from `StopIteration`. So it quietly breaks your loop.
egality has joined #ruby
<adam12> Here's my workaround. It's not very elegant, and I am not sure there is better way to do it. Ractors seem to know very little able themselves. https://gist.github.com/xvalen/0f18353c3721a1eb963f5d9ce5a5c73f?permalink_comment_id=4671561#gistcomment-4671561
<pvalenta> adam12, thank you
<pvalenta> adam12, it's nice solution
Linux_Kerio has quit [Read error: Connection reset by peer]
Linux_Kerio has joined #ruby
<adam12> pvalenta: Looking at the Ruby source, there's also Ractor::Selector.
<adam12> pvalenta: Seems like Ractor.select is built on top of it, but Ractor::Selector is flexible. It also says that it will remove closed ractors automatically.
filipiz has joined #ruby
<adam12> Ractor::Selector looks maybe new? I am not sure it's in 3.2...
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
cameron_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
shokohsc51085 has joined #ruby
shokohsc5108 has quit [Ping timeout: 250 seconds]
shokohsc51085 is now known as shokohsc5108
Perflosopher has quit [Quit: Ping timeout (120 seconds)]
Perflosopher has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
kiwi_36 has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
Nixkernal has quit [Ping timeout: 245 seconds]
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
r3m has quit [Quit: WeeChat 4.1.0-dev]
r3m has joined #ruby
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
caedmon has joined #ruby
konsolebox has quit [Ping timeout: 244 seconds]
_ht has joined #ruby
willfish has quit [Ping timeout: 248 seconds]
Bish has quit [Ping timeout: 246 seconds]
weatheredwatcher has quit [Quit: leaving]
Bish has joined #ruby
taupiqueur_shiny has quit [Ping timeout: 246 seconds]
jess has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
taupiqueur_shiny has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
filipiz has joined #ruby
ultralan has joined #ruby
dviola has quit [Quit: WeeChat 4.0.4]
John_Ivan has quit [Quit: Disrupting the dragon's slumber one time too often shall eventually bestow upon all an empirical and indiscriminate conflagration that will last for all goddamn eternity.]
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
hernan_ is now known as hernan
ultralan has quit [Remote host closed the connection]
filipiz has quit [Read error: Connection reset by peer]
taupiqueur_shiny has joined #ruby
filipiz has joined #ruby
willfish has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
willfish has quit [Ping timeout: 246 seconds]
jmcantrell has joined #ruby
<pvalenta> adam12, it's not in 3.2
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
cameron_ has joined #ruby
cameron_ has quit [Client Quit]
filipiz has quit [Read error: Connection reset by peer]
Linux_Kerio has quit [Ping timeout: 256 seconds]
filipiz has joined #ruby
willfish has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
caedmon has quit [Ping timeout: 256 seconds]
eddof13 has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
r3m has quit [Remote host closed the connection]
r3m has joined #ruby
filipiz has joined #ruby
r3m has quit [Client Quit]
r3m has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
goldfish has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
_ht has quit [Quit: _ht]
nona has quit [Ping timeout: 245 seconds]
otisolsen70 has quit [Quit: Leaving]
fercell_ has joined #ruby
fercell has quit [Ping timeout: 250 seconds]
filipiz has quit [Read error: Connection reset by peer]
weatheredwatcher has joined #ruby
filipiz has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
yaw has quit [Ping timeout: 245 seconds]
yaw has joined #ruby
yaw has quit [Ping timeout: 256 seconds]
tomtmym has quit [Quit: Gone.]
filipiz has quit [Read error: Connection reset by peer]
lena64t has joined #ruby
yaw has joined #ruby
lena64t has quit [Client Quit]
filipiz has joined #ruby
lena64t has joined #ruby
yaw has quit [Ping timeout: 246 seconds]
yaw has joined #ruby
yaw has quit [Ping timeout: 246 seconds]
yaw has joined #ruby
yaw has quit [Ping timeout: 260 seconds]
yaw has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
lena64t has quit [Remote host closed the connection]
filipiz has quit [Read error: Connection reset by peer]
lena64t has joined #ruby
filipiz has joined #ruby
weaksauce has quit [Quit: Textual IRC Client: www.textualapp.com]
nona has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
weaksauce has joined #ruby
filipiz has joined #ruby
yaw has quit [Ping timeout: 260 seconds]
eddof13 has joined #ruby
yaw has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leon__ has quit [Ping timeout: 245 seconds]
goldfish_ has joined #ruby
goldfish has quit [Read error: Connection reset by peer]
yaw has quit [Ping timeout: 260 seconds]
kiwi_36 has quit [Remote host closed the connection]
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
yaw has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
yaw has quit [Ping timeout: 252 seconds]
filipiz has joined #ruby
willfish has quit [Quit: WeeChat 4.0.2]
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
yaw has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
yaw has quit [Ping timeout: 252 seconds]
filipiz has joined #ruby
filipiz has quit [Read error: Connection reset by peer]
filipiz has joined #ruby
filipiz has quit [Read error: Connection reset by peer]