havenwood changed the topic of #ruby to: Ruby 3.3.0, 3.2.3, 3.1.4 https://www.ruby-lang.org | Rules https://ruby-community.com | Logs https://libera.irclog.whitequark.org/ruby
user23 has quit [Remote host closed the connection]
JordiGH has joined #ruby
donofrio__ has joined #ruby
donofrio_ has quit [Ping timeout: 260 seconds]
JordiGH has quit [Ping timeout: 256 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
Obsdark has quit [Quit: Nettalk6 - www.ntalk.de]
szkl has quit [Quit: Connection closed for inactivity]
jenrzzz has joined #ruby
wyclif has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
cek has quit [Quit: Connection closed for inactivity]
FetidToot has quit [Quit: The Lounge - https://thelounge.chat]
FetidToot has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
<havenwood> March challenge, slip `#FrOzEn-StRiNg_LiTeRaL:tRuE` into a codebase. (It works.)
<havenwood> A little fun with frozen string magic comments before they're frozen by default, now that that's been decided for future Ruby.
JordiGH has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
wyclif has quit [Ping timeout: 264 seconds]
wyclif has joined #ruby
__jmcantrell__ has joined #ruby
jmcantrell has quit [Killed (lead.libera.chat (Nickname regained by services))]
__jmcantrell__ is now known as jmcantrell
jmcantrell_ has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
JordiGH has quit [Ping timeout: 246 seconds]
grenierm has joined #ruby
wyclif has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
wyclif has joined #ruby
wyclif has quit [Ping timeout: 260 seconds]
wyclif has joined #ruby
Starfoxxes has quit [Ping timeout: 268 seconds]
wyclif has quit [Ping timeout: 268 seconds]
wyclif has joined #ruby
osc4rpt has quit [Ping timeout: 268 seconds]
osc4rpt has joined #ruby
dalan0382283350 has quit [Quit: dalan0382283350]
dalan0382283350 has joined #ruby
dalan0382283350 has quit [Quit: dalan0382283350]
dalan0382283350 has joined #ruby
dalan0382283350 has quit [Client Quit]
dalan0382283350 has joined #ruby
dalan0382283350 has quit [Client Quit]
dalan0382283350 has joined #ruby
_ht has joined #ruby
_ht has quit [Remote host closed the connection]
<rapha> i made a test file with that in it and ran it, sort of expecting my computer to blow up or something. nothing happened, havenwood.
_ht has joined #ruby
sam113101 has quit [Remote host closed the connection]
sam113101 has joined #ruby
<rapha> also, it doesn't keep a string from being frozen.
<rapha> but then, neither does frozen_string_literal: true or #freeze. not even a warning. wth?
<rapha> oooh, i *can* reassign the variable
<rapha> ok so havenwood's thing works but doesn't blow up computers, which is reassuring.
jmcantrell has quit [Quit: WeeChat 4.2.1]
jmcantrell_ is now known as jmcantrell
helmut has joined #ruby
<helmut> Hello, I'm trying to learn Ruby/RSpec with possibly biasing Python background. I've gotten through the basics, but I'd like to have a deeper understanding of how things work. Could you help me understand what mechanism causes "it" to be available inside describe SomeClass do ... end? Also how do I parse "be >= 0" (what is that syntactically / how can I examine that in irb)? Thanks in advance.
<sphex> helmut: The block passed to "describe" (and "context") is invoked with a "self" (default receiver) that is an object that responds to the "it" method. So if you call "it" within a describe block, you're just calling a method on an object that "describe" has decided.
<sphex> "describe" is a method added to the Module module and the top-level "main" object (unless you disable RSpec's "monkey patching", in which case you have to call "RSpec.describe" instead), so it looks like a new keyword of sort, but it's just a method really.
<helmut> sphex: very helpful answer. it becomes a lot clearer now.
<helmut> sphex: I also happen to understand "be >= 0" now. be is a class Be that happens to have a weired <= method
<helmut> so be >= 0 actually is be.>=(0) If I understand correctly
<sphex> helmut: yes
Guest99 has joined #ruby
<helmut> cool. this settles all the mysteries I had with rspec thus far. Now looking into writing proper tests. :)
<rapha> or you could just use MiniTest without all that mystery :)
<rapha> (but i get it, to spec or not to spec is a personal preference)
<helmut> I am extending a feature on an existing code base that uses rails+rspec (while at the same time learning all those technologies including Ruby itself). I rather not change their framework.
<rapha> oh, fair enough
<sphex> helmut: And also, the object that becomes "self" in a "describe" block, is actually a class. So you can define methods within that block with "def". And the examples will be run within an instance of that class, so the methods will be available to them. And when you nest a "describe" block, its class object will have the parent describe's class as its superclass. So if you define methods, they inherit.
<helmut> sphex: that extends my understanding. thank you.
<sphex> np
<helmut> With my extensive Python background, I now wish Python had a similar block feature to Ruby. The most similar concept in Python is a "context manager" that can call code before and after a block. Unlike Ruby's blocks, it cannot however a) skip the block b) run the block multiple times c) pass multiple arguments into the block.
<sphex> rspec does a lot of "class stuff" at the same time that can make the whole thing seem really complicated...
<rapha> blocks are pretty lovable indeed
<rapha> on the other hand, i often wish for some of python's ecosystem
<helmut> I fear you cannot have it all simultaneously, but we can learn from one another and I am pretty sure that having learned Ruby blocks will influence the way I write Python in future. Very cool experience.
<rapha> :)
<rapha> i've only dabbled in python myself. now there's a bicycle fork test stand driven by a raspberry pi using pyqt, which was also a horizon-widening experience
<helmut> Judging from what I've seen in Ruby thus far, the language is different in some areas but not significantly more expressive one way or the other. The amount of available modules is different though (which is not saying anything about their quality).
<helmut> If either language gets rid of the GIL that might change the equation slightly ;)
<rapha> well, there's JRuby and Rubinius :)
<rapha> re expressiveness, i feel that's also, to some degree, down a lot to how well one language or the other "clicks" with someone
Guest99 has quit [Quit: Textual IRC Client: www.textualapp.com]
Guest99 has joined #ruby
Guest99 has quit [Client Quit]
Linux_Kerio has joined #ruby
osc4rpt has quit [Ping timeout: 255 seconds]
osc4rpt has joined #ruby
Inline has joined #ruby
grenierm has quit [Ping timeout: 250 seconds]
donofrio_ has joined #ruby
donofrio__ has quit [Ping timeout: 264 seconds]
Inline has quit [Quit: Leaving]
Guest99 has joined #ruby
Guest99 has quit [Client Quit]
<[0x1eef]> Rubinius is dead :/
ht_ has joined #ruby
_ht has quit [Ping timeout: 255 seconds]
ht_ is now known as _ht
deadmarshal_ has quit [Ping timeout: 272 seconds]
graywolf has joined #ruby
<graywolf> Hello. Is the format for Gemfile.lock documented somewhere?
<graywolf> I would like to write a parser for it, so I am curious what the format actually is.
<[0x1eef]> graywolf: There's a parser built into Bundler. Why not use that?
<[0x1eef]> Bundler::LockfileParser.
<graywolf> I need to parse it from a different language, so while I could spawn a subproccess and send json over a pipe, ruby is not a fastest thing to start up...
<[0x1eef]> Ah I see. Then maybe use LockfileParser as a reference. I'm not sure the format is documented anywhere else.
<graywolf> I will take a look, thanks
<rapha> that's sad [0x1eef] :(
<rapha> graywolf: ruby as such starts up in the blink of an eye. you're probably seeing something else taking a while.
<rapha> ruby -e 'puts "Hello World"' 0.09s user 0.00s system 114% cpu 0.077 total
<graywolf> I get 0.039s for that, which is few orders of magnitude more that just reading a text file, parsing it, and spitting out some text. It is not an issue when run once or twice, but when run in a loop on hundreds or thousands Gemfile.lock files it would add up.
<graywolf> Hm, maybe I could just spawn a persitent subprocess to avoid that...
donofrio__ has joined #ruby
<graywolf> I will give that a try
donofrio__ has quit [Remote host closed the connection]
<adam12> havenwood: That's fun. I refuse to use the underscored' version of frozen-string-literal but it is definitely the more popular version.
donofrio__ has joined #ruby
donofrio_ has quit [Ping timeout: 268 seconds]
<[0x1eef]> It will be good when we can drop it altogether.
<adam12> Agreed.
donofrio__ has quit [Remote host closed the connection]
JordiGH has joined #ruby
<adam12> I broke down and decided to not send the `env` hash. I need to inject a dependency and it's too leaky to send it as part of the Hash. I originally wrapped it in a delegate but I just dont' see what it's getting me.
<rapha> graywolf: mine was on WSL. one would think that makes it slower.
<rapha> oh, hundreds of thousands of files, nevermind.
<[0x1eef]> 'bundle exec' is especially slow for me. But I think jruby has the slowest boot time of all rubies, unless you use nailgun or something.
wyclif has quit [Ping timeout: 268 seconds]
egality has quit [Remote host closed the connection]
deadmarshal_ has joined #ruby
pounce has quit [Ping timeout: 246 seconds]
szkl has joined #ruby
meimei has quit [Ping timeout: 256 seconds]
dalan0382283350 has quit [Ping timeout: 264 seconds]
dalan03822833505 has joined #ruby
wyclif has joined #ruby
ht_ has joined #ruby
wyclif has quit [Ping timeout: 272 seconds]
_ht has quit [Ping timeout: 246 seconds]
ht_ is now known as _ht
Guest99 has joined #ruby
wyclif has joined #ruby
wyclif has quit [Ping timeout: 256 seconds]
Guest99 has quit [Quit: Textual IRC Client: www.textualapp.com]
Guest24 has joined #ruby
Linux_Kerio has quit [Read error: Connection reset by peer]
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Read error: Connection reset by peer]
user71 has joined #ruby
<Guest24> Hello
<Guest24> Sorry for the noob question, I tried to Google but I don't know how to express what I want
<Guest24> I have this :
<Guest24> posts.each do |post|
<Guest24>   post = post['data']
<Guest24>   puts post['title']
<Guest24> end
<Guest24> Is there a better way to avoid doing "post = post['data']"?
<Guest24> Thank you in advance
<[0x1eef]> posts.each { puts _1.dig('data', 'title') }
brokkoli_origin has quit [Remote host closed the connection]
ewoud has quit [Ping timeout: 256 seconds]
brokkoli_origin has joined #ruby
wyclif has joined #ruby
<Guest24> Uhhh
<Guest24> I should have precised that title isn't the only thing I want to get
<Guest24> But things like author or link or whatever
wyclif has quit [Ping timeout: 264 seconds]
<rapha> [0x1eef]: what surprises me is how slow rails's rake tasks on MRI are to boot...
<rapha> Guest24: how about Hash#select?
<rapha> actually no, that's not what you want
<rapha> but i know there is one
<rapha> #fetch_values perhaps
<rapha> but that's not the one i was thinking of
<gr33n7007h> puts posts['data'].fetch_values(v1, v2, v3, ...)
<rapha> also #values_at
<rapha> and if you convert your String keys into Symbol keys first, it's nicer to type and read
<Guest24> Okay
<Guest24> Thanks!
<Guest24> Have a nice day
<[0x1eef]> rapha: The 'environment' task dependency.
<rapha> hmm
<rapha> not one to easily get rid of
<[0x1eef]> Yep. But sometimes you don't need it.
<gr33n7007h> i like you can use `it` in blocks for 4.3
<gr33n7007h> very nice =)
<gr33n7007h> *3.4
Guest24 has quit [Quit: Client closed]
wyclif has joined #ruby
<rapha> oh that IS a nice addition
<rapha> looking forward to IT :D
<gr33n7007h> indeed =)
wyclif has quit [Ping timeout: 264 seconds]
<rapha> still stuck on 2.7.8 at work tho :/
<gr33n7007h> rapha: eol now ~1y and a security risk need to update :(
<gr33n7007h> even 3.0 eol next month
<rapha> dont think we're not aware
<rapha> been working on upgrading to rails7 on the side for a year or more now
<rapha> management won't allow to really dedicate time to it
<gr33n7007h> management screw everything up fr
<rapha> not shit
<rapha> no*
<adam12> rapha: I've never had issues getting time if we really needed it in the past, but what I generally do is piecemeal throughout the year. 2.7 to 3.0 was a very small switch flipped, but it was a couple dozen PRs over a 12 month period. On my last long contract, they knew it was going on, but it was spread out in small pieces between the rest of the
<adam12> feature work.
wyclif has joined #ruby
<rapha> piecemeal is what we're doing adam12. and i don't know what kinds of shops you've worked for in terms of in-fighting at and underneath C-level, but i hope for you none like this. wouldn't wish that on my worst enemy tbh.
wyclif has quit [Ping timeout: 272 seconds]
brokkoli_origin has quit [Ping timeout: 255 seconds]
brokkoli_origin has joined #ruby
wyclif has joined #ruby
<[0x1eef]> I think that's one thing that can be a good indicator for a lot of things. If you encounter a ton of problems upgrading ruby there's something wrong somewhere.
wyclif has quit [Ping timeout: 264 seconds]
brokkoli_origin has quit [Remote host closed the connection]
brokkoli_origin has joined #ruby
dalan03822833505 has quit [Quit: Ping timeout (120 seconds)]
dalan0382283350 has joined #ruby
wyclif has joined #ruby
wyclif has quit [Ping timeout: 246 seconds]
dalan03822833508 has joined #ruby
dalan0382283350 has quit [Ping timeout: 268 seconds]
dalan03822833508 is now known as dalan0382283350
wyclif has joined #ruby
wyclif has quit [Ping timeout: 256 seconds]
wyclif has joined #ruby
wyclif has quit [Ping timeout: 255 seconds]
deadmarshal_ has quit [Ping timeout: 264 seconds]
wyclif has joined #ruby
deadmarshal_ has joined #ruby
wyclif has quit [Ping timeout: 256 seconds]
wyclif has joined #ruby
wyclif has quit [Ping timeout: 240 seconds]
graywolf has quit [Quit: WeeChat 4.0.4]
wyclif has joined #ruby
pgib has quit [Remote host closed the connection]
r3m has quit [Quit: WeeChat 4.3.0-dev]
_ht has quit [Quit: _ht]
wyclif has quit [Ping timeout: 260 seconds]
user71 has quit [Quit: Leaving]
weaksauc_ has quit [Quit: Textual IRC Client: www.textualapp.com]
wyclif has joined #ruby
weaksauce has joined #ruby
wyclif has quit [Ping timeout: 256 seconds]
wyclif has joined #ruby
wyclif has quit [Ping timeout: 260 seconds]
brandonld has joined #ruby
brandonld has quit [Ping timeout: 264 seconds]
crespire1 has quit [Remote host closed the connection]
crespire has joined #ruby
wyclif has joined #ruby
wyclif has quit [Ping timeout: 256 seconds]
<rapha> or rails ... or any security-related gem, really. basically, if you're telling people in no uncertain terms that their software is insecure and the response you're getting is essentially one of "ah, nah, it'll be fine, we've always done it like this". that's when you know.
<rapha> havenwood: you're really having fun over there, aren't you? :)
wyclif has joined #ruby
[0x1eef_] has joined #ruby
[0x1eef] has quit [Ping timeout: 256 seconds]
wyclif has quit [Ping timeout: 255 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
wyclif has joined #ruby
Vonter has quit [Ping timeout: 256 seconds]
Vonter has joined #ruby
wyclif has quit [Ping timeout: 264 seconds]
<adam12> rapha: This is why I've generally disliked Rails for upgrades since it's all or nothing. When it's a bunch of assorted libraries they can move at their own pace which simplifies a lot.
wyclif has joined #ruby
brandonld has joined #ruby
wyclif has quit [Ping timeout: 264 seconds]
brandonld has quit [Ping timeout: 260 seconds]