<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
<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]
<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]
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.