<havenwood>
rmnull: For a tiny fix, a PR to GitHub suffices. For anything that might need discussion, a patch and issue on bugs.ruby-lang.org is customary.
<rmnull>
thanks, i'll take a look
orbyt_ has joined #ruby
ChmEarl has quit [Quit: Leaving]
gell5 has joined #ruby
gell5 has quit [Ping timeout: 264 seconds]
poro has quit [Quit: Leaving]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
donofrio has quit [Remote host closed the connection]
Guest93362 is now known as baweaver
baweaver has quit [Changing host]
baweaver has joined #ruby
nicholaslyang has joined #ruby
nicholaslyang has quit [Client Quit]
nicholaslyang has joined #ruby
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
gell5 has joined #ruby
gell5 has quit [Ping timeout: 246 seconds]
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sarna>
jhass: yep, had to upgrade ruby-build manually. thanks :)
sh7d has quit [Ping timeout: 260 seconds]
<sarna>
by the way - when people write ruby scripts (I mean one-file programs), do they make, like, a Main class or something? or just put everything at the top-level
sh7d has joined #ruby
akem has quit [Quit: Leaving]
akem has joined #ruby
<jhass>
can't say there's a definitive way
<jhass>
I have roughly three styles depending on complexity, long-levity and target audience. From just a bunch of top level code to cleaning that up with some method definitions to a full class based design as you say
<jhass>
for a gem offering a CLI it can often make sense to have your top level code be something like MyGem::CLI.new(ARGV) for testability primarily but also reusability
<sarna>
I see. thanks!
<jhass>
also these categories don't have clear borders to me. category 2 especially might sport some small entity classes or put the methods in a class to have common state etc.
<jhass>
just do what looks good to you :)
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sarna>
I spent some time writing go and python, I must relearn how not to overgeneralize everythin :)
<jhass>
nah, don't :)
<jhass>
just forget to make everything super explicit, assume some things are the way you need them to be :D
jenrzzz has quit [Ping timeout: 258 seconds]
DTZUZU has joined #ruby
<sarna>
I just migrated one script to ruby, felt super nice :) though probably not 100% idiomatic yet, but still I enjoyed the process
sarna has quit [Quit: Connection closed]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xco has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
imode has quit [Ping timeout: 246 seconds]
vondruch has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
dionysus69 has joined #ruby
conta has quit [Quit: conta]
snuz has joined #ruby
sarna has joined #ruby
jenrzzz has joined #ruby
tau has quit [Ping timeout: 265 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cnsvc_ has joined #ruby
darkstardev13 has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cnsvc_ has quit [Ping timeout: 240 seconds]
TomyWork has joined #ruby
ur5us has joined #ruby
Bounga has joined #ruby
<sarna>
`data.map{ |row| row['foo']}.to_set` <- how would I format this?
gell5 has joined #ruby
<yxhuvud>
personally I tend to put chained method calls on consecutive lines, but what you have is fine too
<leftylink>
almost exactly like that, but I additionally put a space before the opening brace and before the closing brace
gell5 has quit [Ping timeout: 260 seconds]
<sarna>
okay, thanks :)
al2o3-cr has quit [Quit: WeeChat 2.8]
<sarna>
one more question - why is the "filter" family of methods mutating-only? I mean filter!, select!, keep_if
<yxhuvud>
Becuase you have added a ! to the end of them. Try without.
<sarna>
oh! why aren't the regular ones listed in the docs?
darkstardev13 has quit [Remote host closed the connection]
darkstardev13 has joined #ruby
ur5us has quit [Ping timeout: 256 seconds]
darkstardev13 has quit [Remote host closed the connection]
darkstardev13 has joined #ruby
jenrzzz has quit [Ping timeout: 258 seconds]
roadie has joined #ruby
infinityfye has joined #ruby
fercell has joined #ruby
conta has joined #ruby
snuz has quit [Read error: Connection reset by peer]
<Cork>
anyone know what's up with bundler and rubygems.org?
quazimodo has joined #ruby
gell5 has joined #ruby
AndreYuhai has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
gell5 has quit [Ping timeout: 264 seconds]
kinduff has joined #ruby
<sarna>
seems like bundler is now included in the rubygems framework thingy?
<Cork>
na, it was my isp that mocked up ipv6 again
<Cork>
forcing ipv4 for rubygems.org helped
<AndreYuhai>
Hey there, how do I create this association: https://dbdiagram.io/d/5ede1f879ea313663b3a35e7 in Rails? I got confused. Should I go with has_and_belongs_to_many? I included explanation in the comments there.
<sarna>
oh well, I was confused since both were up for me :D
schne1der has joined #ruby
<Cork>
AndreYuhai: either has_and_belongs_to_many or a separate relation model
<AndreYuhai>
is there any way to recursively create objects from a hash within a hash or hashes within an array for an active record model or do I need to do that manually in my class' initialize method? https://dpaste.org/TJk3
<apotheon>
I think wget as a whole is a gigantic hack, as are most GNU things.
salerace has joined #ruby
salerace has quit [Quit: salerace]
salerace has joined #ruby
salerace has quit [Client Quit]
salerace has joined #ruby
salerace has quit [Client Quit]
salerace has joined #ruby
<adam12>
AndreYuhai: I doubt you could use that Hash as-is, but ActiveRecord can create nested objects. You'd need to enable it with `accepts_nested_attributes_for :badges`.
simi[m] has joined #ruby
<adam12>
AndreYuhai: You could make your own initializer (class method that calls new) which accepts the hash, transforms it, then creates a new User.
<AndreYuhai>
I was just wondering whether ActiveRecord already supports what I am trying to do. I will check that accepts_nested_attributes_for thing though. Thank you.
Bounga has quit [Remote host closed the connection]
Bounga has joined #ruby
<nychtel>
Huh. I wonder if it has something to do with using reallocated space for the symbol. Like, when Marshal serializes it, it includes the size of the object's allocated space
<jhass>
maybe? Idk. Maybe it just was a bug in 2.7.0 to return true? :D
<jhass>
I never digged into the marshal format, I think it's documented as something you should treat opaque
<nychtel>
I tried using .freeze on them, in case that'd free up any excess memory
<nychtel>
no dice
<nychtel>
Yeah, the format for object serialization should always be treated as a black box unless you're actively working on it
sauvin has quit [Read error: Connection reset by peer]
<nychtel>
Actually jhass it can't be just 2.7.0 because I tried that here on my machine
<nychtel>
2.7.1, 2.7.0, and 2.6.1
<nychtel>
2.6.5 and 2.5.5 online, and just the one 2.7.0 that worked. I wonder if the one that worked was pure ruby and the ones that didn't had some kind of gem polluting them.
FastJack has joined #ruby
<jhass>
idk, it's all very much the same, archlinux host, archlinux container, archlinux package
<jhass>
my archlinux laptop with 2.7.1 also gives false
<nychtel>
I noticed it didn't know about the Digest module, so I just wonder if in the name of purity they left out anything other than barebones ruby
<nychtel>
I don't know: should I submit a bug report or something? I can't find this behavior documented or discussed anywhere
<jhass>
(fwiw I run carc.in, so not sure if you mean me or the archlinux packager)
<jhass>
I mean it's documented that you basically should have no expecations of the output other than Marshal.load returning what you had put in?
<nychtel>
I assumed you run it since you knew what was under the hood. I was just suggesting the bug may be in some gem that isn't included on the server.
<nychtel>
Though that sounds unlikely - a gem modifying something core like that
<jhass>
yeah
<nychtel>
We were really hoping we could md5 the marshal dump to store heavy lifting from reports into redis in a simple way.
<nychtel>
I suggested we use something else as the key but the bossman seems pretty set on doing it this way if possible
<jhass>
what kind of object do you marshal?
<jhass>
maybe you can hash what you input instead?
dretnx has joined #ruby
<jhass>
nychtel: ah! It's encoding!
<nychtel>
Yeah, I suggested that but he was hoping to store some relations that are pretty heavyweight to compute
<nychtel>
I tried .encoding, I swear!
<jhass>
US-ASCII vs UTF-8 for me
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nychtel>
Huh. On my end they're both ASCII
<jhass>
it kinda makes sense, I fixed carc.in to force encodings to UTF-8 at some point but probably never applied that to the older ruby containers
<jhass>
so it interacts with the external encoding (ruby -E)
<nychtel>
Weird. I still get the problem on my end. The encodings are ==, but the dumps aren't
<nychtel>
I thought of encoding almost first thing. Weird that was actually the problem on your end :)
<jhass>
or maybe I did, actually all the carc.in's return true
dretnx has quit [Remote host closed the connection]
<nychtel>
Hhhmmmmmm, ok
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
conta has quit [Client Quit]
fercell has joined #ruby
<jhass>
but yeah, I have to agree that hashing marshal output seems brittle
<jhass>
maybe you could seralize to a more standardized format, JSON/YAML (still brittle, might have whitespace changes), JSONB/MsgPack/Protobuf/... id
<jhass>
*idk
<nychtel>
Yeah I'm not the coolest with that idea :)
hightower4 has quit [Ping timeout: 240 seconds]
<nychtel>
Yeah, the problem with a lot of those more standardized ones is they can't handle ruby code as well
conta has joined #ruby
<jhass>
some might argue that as an additional benefit :D
<nychtel>
cool, thanks jhass
<jhass>
yw, was fun one
<nychtel>
I found one other way around it: interpolation
<jhass>
well
<nychtel>
"#{:symbol}"
<jhass>
whatever works for you :D
<nychtel>
jhass - some might argue that: I'm one of those some :)
<nychtel>
Storing executable code is rarely a good idea, but I suppose it's really just a caching mechanism so if something goes wrong we can catch it and just do the full report : ... sloooooowly
<nychtel>
I think the issue has to do with the character encoding of the ruby code vs. the character encoding of the system it's running on.
drincruz has joined #ruby
<jhass>
yeah, hence carc.in is unaffected because it invokes ruby -E UTF-8
<jhass>
and internal default is UTF-8 since 2.0
<AndreYuhai>
Am I doing something wrong using `accepts_nested_attributes_for` here: https://dpaste.org/fvw0 ?
<jhass>
that symbol.to_s would use the exernal encoding is strange though
<adam12>
AndreYuhai: The hash key is book_attributes
nicholaslyang has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
schne1der has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
fratis has quit [Read error: Connection reset by peer]
SuperLag has joined #ruby
matti has quit []
matti has joined #ruby
SuperL4g has quit [Ping timeout: 240 seconds]
ellcs1 has quit [Ping timeout: 256 seconds]
dionysus69 has quit [Ping timeout: 246 seconds]
cnsvc_ has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
Bounga has joined #ruby
xco has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jetchisel has joined #ruby
nicholaslyang has joined #ruby
nicholaslyang has quit [Client Quit]
cnsvc_ has joined #ruby
imode has quit [Ping timeout: 260 seconds]
tau has joined #ruby
tau has joined #ruby
nicholaslyang has joined #ruby
nicholaslyang has quit [Client Quit]
orbyt_ has joined #ruby
<xco>
hello everyone. when i do `$SAFE` in irb i get $SAFE will become a normal global variable in Ruby 3.0
<xco>
question: $SAFE is not normal? how's that?
<xco>
i mean how's $SAFE not a normal global variable, what is a "normal" global variable?
<akem>
What will replace $SAFE?
<xco>
akem mmm, not sure i get it. what will replace $SAFE? i don't know.
<akem>
xco, SAFE is used to protect execution of stuff that is considered dangerous IIRC.
<akem>
$SAFE
<xco>
akem yup that i know
nicholaslyang has joined #ruby
<akem>
xco, That's why it is not a normal variable.
cnsvc_ has quit [Ping timeout: 240 seconds]
<akem>
xco, What version of ruby are you running?
<xco>
2.7.1 akem
<akem>
Ok, i run 2.7.0 here, that's why i don't have the warning.
<xco>
akem hm, i switched to 2.7.0 with IRB, and i still have "(irb):1: warning: $SAFE will become a normal global variable in Ruby 3.0"
<xco>
IRB = RVM sorry
<akem>
xco, Yeah, i have the warning in fact.
<akem>
in IRB at least
<xco>
yeah so a follow-up question will be is "$!" a "normal" global variable? if so why is $SAFE not a normal one. this is what i'm trying to understand
<akem>
What is "$!" usage?
<xco>
it shows the latest error message
<akem>
xco, How i understand it, you cannot use $SAFE for your own purpose, it is already interpreted by the ruby language.
<xco>
akem i think you can
<akem>
Ha ok. I never use it, nm. :P Good to know.
<xco>
you can manipulate it to your purpose
<akem>
xco, You can, but it will also change ruby behavior related to execution at the same time.
<akem>
Because internal ruby stuff look at this variables' value already.
<xco>
akem yes, then you can hide it in a proc so it doesn't leak outside
gell5 has quit [Remote host closed the connection]
gell5 has joined #ruby
claw has quit [Ping timeout: 246 seconds]
claw has joined #ruby
Bounga has quit [Ping timeout: 272 seconds]
roadie has quit [Ping timeout: 272 seconds]
nofxx__ has quit [Remote host closed the connection]
<cyrus_mc_>
in question calls @http = Net::HTTP::Persistent.new 'fluent-plugin-logzio', :ENV and that results in unexpected error error_class=ArgumentError error="wrong number of arguments
<cyrus_mc_>
Trying to understand why, what is the difference when defining a method parameters as name = nil vs name: nil
drincruz has quit [Ping timeout: 260 seconds]
<havenwood>
cyrus_mc_: The latter is called a keyword argument.
<havenwood>
cyrus_mc_: The former determines the variable by its position, like if it's first or second. The new version determines the variable by its name, like: name: 'fluent-plugin-logzio'
<cyrus_mc_>
Ah. so when the code that is broken calls @http = Net::HTTP::Persistent.new 'fluent-plugin-logzio', :ENV it should be calling it how?