havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.0, 3.0.3, 2.7.5: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
lfalcao has left #ruby [#ruby]
Guest7003 has quit [Ping timeout: 240 seconds]
donofrio has quit [Ping timeout: 256 seconds]
perrierjouet has quit [Quit: WeeChat 3.4]
donofrio has joined #ruby
samgranieri has quit [Ping timeout: 256 seconds]
hanzo has joined #ruby
ur5us has joined #ruby
donofrio has quit [Remote host closed the connection]
donofrio has joined #ruby
donofrio has quit [Read error: Connection reset by peer]
Rounin has quit [Ping timeout: 256 seconds]
kaivai_ has quit [Quit: ZNC - https://znc.in]
kaivai has joined #ruby
JayDoubleu_ has quit [Ping timeout: 256 seconds]
JayDoubleu_ has joined #ruby
kaivai has quit [Quit: ZNC - https://znc.in]
donofrio has joined #ruby
kaivai has joined #ruby
donofrio has quit [Remote host closed the connection]
donofrio has joined #ruby
donofrio has quit [Read error: Connection reset by peer]
aighearach has quit [Quit: Leaving]
kaivai has quit [Quit: ZNC - https://znc.in]
kaivai has joined #ruby
symb0l has quit [Quit: The Lounge - https://thelounge.chat]
kaivai has quit [Quit: ZNC - https://znc.in]
kaivai has joined #ruby
unyu has quit [Quit: WeeChat 3.4]
unyu has joined #ruby
fdan has joined #ruby
<fdan> Hi there, how can i convert this `expect(repo[:release_type].length).to be_between(1, 2).inclusive` to ensure that they are'nt arrays
ur5us has quit [Ping timeout: 250 seconds]
<nakilon> fdan add one more expect I guess
<nakilon> above that one
<fdan> i am not a ruby programmer
<fdan> do you mind if you can pass me the snippet to do the change
<nakilon> what exactly shouldn't be an Array?
<fdan> I have to update `expect(repo[:release_type].length).to be_between(1, 2).inclusive` this to ensure that they are not arrays
<fdan> nakilon how to do that
<nakilon> I wish there was a pstore method to check if I'm in a transaction already
<nakilon> so I could make a method with an optional transaction opening
unyu has quit [Quit: brb]
<nakilon> otherwise to avoid nesting I had to prefetch the query that is actually not an optimal thing to do
<fdan> nakilon are you answering me
<nakilon> no
<fdan> ok
<fdan> can you guide me
bluedust has joined #ruby
<havenwood> nakilon: Maybe just make your own little wrapper to detect if you're in a transaction? Something like? https://gist.github.com/havenwood/ddc1dcbac4867d7c443adf08a4a481f3
<havenwood> fdan: What shouldn't be an Array?
<fdan> i am going to change release_type to be a string
<fdan> so in the rspec, i will have to ensure that release_type is not an array in the spec file
<havenwood> fdan: Normally you don't test what things aren't.
<fdan> yes can we check that they're strings atleast
<havenwood> fdan: You can test whatever you want, but typically we use duck typing and don't care what's passed as long as it responds to the appropriate methods for your interface.
<havenwood> fdan: expect(repo[:release_type]).not_to be_an(Array)
<havenwood> fdan: That ^ is how you'd express that `repo[:release_type]` must not be an Array.
<havenwood> fdan: It's an odd test, to be sure, just since what else all must it not be?
<fdan> i see
<havenwood> fdan: If you really want to check types, I'd suggest using RBS and Steep to for type checking.
<fdan> havenwood: 'not_to be_an` is a method in rspec?
<havenwood> Yup, RSpec stuff.
<havenwood> You can generate fairly nice RBS type signatures these days with `typeprof` in Ruby 3.1.
<fdan> can you pass me the documentation for it
<fdan> could not find
<havenwood> fdan: https://bfy.tw/SWD3
<havenwood> fdan: I searched for "rspec not to" and it's the top link. ¯\_(ツ)_/¯
<havenwood> Maybe try a new search engine.
<fdan> sorry i search with not_to_be_an
<havenwood> fdan: Two methods, #not_to and #be_an.
<havenwood> fdan: nakilon linked you the latter.
<fdan> i see
<havenwood> fdan: I use Minitest, which ships with Ruby, and is less fancy.
<havenwood> RSpec has this little English-like domain-specific language for tests.
<havenwood> I'd recommend an RSpec tutorial if you want to get up to speed with RSpec.
<fdan> havenwood i have one more question. I have release_type: [Rn::Monitor::SDK_RELEASE, Rn::Monitor::NODE_RELEASE]
<nakilon> havenwood that's a cool wrapper but it's like another wheel
<fdan> how do i update this
* havenwood spins the wheel
<fdan> sorry i m coming from python experience and its my day 1 in ruby
<havenwood> fdan: How do you update it to what?
<havenwood> I don't understand the question.
<havenwood> nakilon: Yeah, it's not context aware like `Async do`, which is too bad.
<havenwood> I usually wrap PStore anyways, since it's interface is clunky, so I don't mind a layer of abstraction.
<fdan> previously release_type was an array in an .rb file, i changed it to string and hence the spec file also changes
<fdan> i dont know what i would have to update it to?
<nakilon> probably as a kludge I could pass a transaction object to my method so it will see the presence of context immediately in args
<havenwood> fdan: Okay. So you're showing us an Array with two constant variables and asking how to update it to a String? What are those constants? How do you make an Array a String? Your question doesn't make sense without context.
<havenwood> fdan: Have you shared this code and I missed it? You can't make an Array a String without deciding how you're going to represent a list as text.
<fdan> havenwood do you mind if i can DM you the code?
<havenwood> fdan: I feel like I'm about to go down a rabbit hole here. :P Can you say why you're making a String and show just one example of what you'd like the content of the String to be?
<havenwood> 🐇
<fdan> hey so basically we got duplicate tickets in jira from the ruby program
<havenwood> Feel free to share a link to a gist of the code here.
<havenwood> Okay, you got duplicate tickets, copy.
<fdan> yes
<havenwood> And why are you taking a list of things and turning it into text?
<fdan> sure, 1 sec
<fdan> this is the change i made
<fdan> i made this change because when the release_type was an array, when there is a second condition in the array
<fdan> the condition for that was never run as it was mutually exclusive
<fdan> hence i made this code change
<fdan> after i made the code change i am asked to update few more things, which i am not sure
<fdan> havenwood iam asked to update L19 https://i.imgur.com/GlSBc56.png
<fdan> do you get an idea
<havenwood> fdan: I understand the code but don't understand what you want.
<fdan> what does L19 do?
<havenwood> fdan: It's the key/value pair of a hash, where the key is a Symbol and the value is an Array with both sdk and node release types.
<fdan> after modifying to expect(repo[:release_type]).not_to be_an(Array), does L19 change?
<havenwood> No, don't do that.
<havenwood> Your whole "turn the Array into a String thing seems misguided with the code you've shown.
<havenwood> You have three cases, [Foo], [Bar], and both [Foo, Bar].
oxfuxxx has joined #ruby
<havenwood> The original code before your update said "do x if [Foo] or [Foo, Bar] and y if [Bar]" basically.
<fdan> havenwood why i ask is, i have made the change here some days before https://i.imgur.com/SvRY4O5.png
<havenwood> fdan: After your update, it doesn't make sense.
<havenwood> fdan: I think maybe just say what you want the logic to be? Obviously you didn't like options 1) [Node], [Node, SDK], and 2) [SDK].
<havenwood> fdan: What *do* you want the logic to be?
<havenwood> fdan: Are you trying to say it should never be both Node and SDK?
<havenwood> fdan: This test presumes you can have one, the other, or both.
<havenwood> If it's Node or both, "NODE_DEFAULT_ASSIGNEE"
<fdan> it can be node and sdk as well, but problem was previously they were in array
<fdan> now im going to change them to string
<havenwood> If it's SDK, "SDK_DEFAULT_ASSIGNEE"
<fdan> L313 and L319 will be a string
<havenwood> fdan: That seems completely unrelated to your problem to me. I'm scratching my head wondering why you want to involve a String at all?
<havenwood> Then being in an Array *really* doesn't seem like a problem to me.
<havenwood> I suspect you just want some logic change? What?
<fdan> yes the whole idea of changing from an array to string is, if an array simultaneously contains both node and sdk release
<fdan> the latter condition never really executed
<havenwood> So what if it does? Change your logic?
<fdan> hence we made this change https://i.imgur.com/6rrPZnD.png
<havenwood> fdan: That's just gibberish.
<fdan> now i want to make the release_type to be a string
<havenwood> fdan: Sorry, maybe someone else can follow, but I don't understand why you can't just adjust your logic slightly and still use an Array.
<fdan> havenwood it should never be an array. it should have only one item
<fdan> or how you will adjust the logic?
<fdan> when it was an array, we got duplicate tickets and we never got a ticket for sdk
<havenwood> fdan: Right, but that's because the logic said to do that, not because it's an Array.
<fdan> yes i agree
<fdan> do you have a better way to do this
<havenwood> fdan: Since I still have no clue what you want, let me suggest starting very explicitly. Sec, I'll show you an example.
<fdan> ok
<havenwood> fdan: You can certainly make this code more elegant, but I'm trying to show there are three cases and you can have three outcomes — whatever you want them to be.
<havenwood> You can do two on one case when, with a comma between to mean "either".
<havenwood> If you make it work with that ^ code it'll be easy for folk here to then help you refactor it.
<havenwood> fdan: If you want to flatten this and change your test case, go ahead, but maybe start with making the code logic work as is.
<fdan> ok
<havenwood> If you don't want to match one of those, remove it. Explicit is probably a safe place to start and it'll make it clear to anyone helping how to refactor.
<havenwood> fdan: Circle back if that works for you and folk here can help make it pretty.
<fdan> hmm sure
<fdan> havenwood what is the difference between the gist you have given and this https://bpa.st/QUZQ
<leftylink> 2022-02-08 05:49:14 < fdan> sorry i m coming from python experience and its my day 1 in ruby
<leftylink> so basically I think this is a lie
<leftylink> but I'm not sure whether I should withhold help based on it being a lie, or if I should just help anyway
<fdan> why
<fdan> its upto you. but i have no ruby experience
<leftylink> hey all I'm saying is I have a good memory
<leftylink> okay yeah
<leftylink> I think you're lying, and I have decided not to help because of it. I won't stop others from helping, but I'm simply informing others of what I have chosen to do
<leftylink> others are of course free to make their own individual choices - I'm not the boss of them
<fdan> i still understand how you're coming to a conclusion that i am lying
<leftylink> that is a good point though. if I don't explain how I came to that conclusion, there are two huge disadvantages 1. accused does not get a chance to respond to the accusations, 2. others have no reason to come to the same conclusions and potentially take the same actions. given those two disadvantages, I should explain how I came to that conclusion
<leftylink> so my reasons are 2021-08-06, 2021-08-27, 2021-08-30, and 2022-01-21. those are the days that led me to think it being day 1 is false
<fdan> yes i agree, but still its a day 1 at ruby, i have not formally learnt ruby yet
<leftylink> I see, so it must have been a expression I am not familiar with. I apologise. English isn't my first language, so I must have misunderstood you.
oxfuxxx has quit [Quit: Yankies Motherfh@ckers C0[k Astroboys]
infinityfye has joined #ruby
teclator has joined #ruby
keremcan has joined #ruby
keremcan has quit [Client Quit]
hanzo has quit [Quit: Connection closed for inactivity]
ur5us has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
Guest7003 has joined #ruby
Rounin has joined #ruby
bluedust_ has joined #ruby
bluedust has quit [Ping timeout: 256 seconds]
perrierjouet has joined #ruby
exondation has joined #ruby
rando25892 has quit [Quit: enemy at the gate]
keremcan has joined #ruby
mixfix41 has quit [Ping timeout: 256 seconds]
infinity_fye has joined #ruby
infinity_fye has quit [Client Quit]
infinityfye has quit [Ping timeout: 250 seconds]
infinityfye has joined #ruby
infinity_fye has joined #ruby
dviola has joined #ruby
keremcan has quit [Quit: Client closed]
ur5us has quit [Ping timeout: 240 seconds]
infinityfye has quit [Ping timeout: 256 seconds]
infinityfye_ has joined #ruby
infinity_fye has quit [Ping timeout: 256 seconds]
infinityfye has joined #ruby
infinityfye_ has quit [Ping timeout: 240 seconds]
Aylat has joined #ruby
Aylat has quit [Changing host]
Aylat has joined #ruby
goldfish has joined #ruby
infinity_fye has joined #ruby
infinityfye has quit [Ping timeout: 240 seconds]
infinityfye has joined #ruby
infinity_fye has quit [Ping timeout: 250 seconds]
infinity_fye has joined #ruby
infinityfye has quit [Ping timeout: 250 seconds]
infinityfye_ has joined #ruby
infinity_fye has quit [Ping timeout: 250 seconds]
gr33n7007h has quit [Quit: WeeChat 3.4]
infinity_fye has joined #ruby
infinity_fye has quit [Client Quit]
infinityfye_ has quit [Ping timeout: 250 seconds]
infinityfye has joined #ruby
taupiqueur has joined #ruby
roshanavand has joined #ruby
fdan has quit [Quit: Client closed]
reset has quit [Quit: reset]
roshanavand has quit [Ping timeout: 256 seconds]
reset has joined #ruby
unyu has joined #ruby
unyu has quit [Client Quit]
quintasan has quit [Ping timeout: 256 seconds]
quintasan has joined #ruby
TomyWork has joined #ruby
duds- has quit [Remote host closed the connection]
duds- has joined #ruby
oxfuxxx has joined #ruby
Aylat has quit [Read error: Connection reset by peer]
mixfix41 has joined #ruby
gproto23 has joined #ruby
unyu has joined #ruby
roshanavand has joined #ruby
John_Ivan has joined #ruby
quintasan has quit [Ping timeout: 240 seconds]
roshanavand has quit [Remote host closed the connection]
roshanavand has joined #ruby
taupiqueur has quit [Quit: taupiqueur]
quintasan has joined #ruby
acosta has joined #ruby
fef has joined #ruby
fandre1986 has joined #ruby
Rounin has quit [Ping timeout: 250 seconds]
bluedust_ has quit [Remote host closed the connection]
fandre1986 has quit [Quit: Connection closed]
bluedust has joined #ruby
oxfuxxx has quit [Ping timeout: 250 seconds]
Guest53 has joined #ruby
infinityfye has quit [Read error: Connection reset by peer]
<adam12> Gemdocs.org is now storing 27 GB of uncompressed docs over 4299 gems.
<adam12> Seems like we run about 100 gems a day for releases.
bluedust_ has joined #ruby
bluedust has quit [Ping timeout: 256 seconds]
oxfuxxx has joined #ruby
<mooff> nice :-)
oxfuxxx has quit [Ping timeout: 250 seconds]
unyu has quit [Ping timeout: 240 seconds]
bluedust has joined #ruby
unyu has joined #ruby
bluedust_ has quit [Ping timeout: 256 seconds]
weaksauce has quit [Ping timeout: 250 seconds]
oxfuxxx has joined #ruby
Guest27 has joined #ruby
Guest27 has quit [Client Quit]
oxfuxxx has quit [Ping timeout: 250 seconds]
oxfuxxx has joined #ruby
weaksauce has joined #ruby
goldfish has quit [Ping timeout: 240 seconds]
bluedust has quit [Remote host closed the connection]
<nakilon> leftylink heh are those his timestamps? I don't remember nicknames, but inability to even understand my first question "what exactly should be array?" I supposed it's not 1st ruby day but rather 1st computer day, but with timestamps it makes even worse sense
mjacob has joined #ruby
<mjacob> how do i get the Method object of some method of some object which has an overridden method 'method'?
<weaksauce> super?
<mjacob> weaksauce: wouldn't that work only within the overriden 'method' method?
<weaksauce> yes
TomyWork has quit [Remote host closed the connection]
<weaksauce> what's the context
<nakilon> probably the last line in this answer https://stackoverflow.com/a/18448863/322020
<kenichi> obj.method(:meth_name), no?
fef has quit [Ping timeout: 276 seconds]
<kenichi> ohhhh
<adam12> mjacob: Maybe you need send here.
<adam12> Actually..
<mjacob> i got it working with "Object.instance_method(:method).bind(controller.request).method(...)"
<mjacob> thank you all!
<adam12> I guess that breaks down if you actually need the original `method`.
<adam12> But a nice solution outside of that.
<mjacob> adam12: yes, actually, i want the method object of a method which is not called 'method'. sorry for the confusion.
<ox1eef> instance_method(..).bind(self).call is great knowledge to have in the toolbox.
<adam12> mjacob: Nah, it's not confusing. Just an interesting predicament.
<adam12> I guess you could maybe alias :method to :original_method or something, then method(:original_method).. but it does kind of defeat the purpose.
<adam12> That's if you needed method(:method) of course, which you don't :)
<adam12> If you could rename when binding, that would be neat.
bluedust has joined #ruby
___nick___ has joined #ruby
samgranieri has joined #ruby
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
___nick___ has joined #ruby
<mooff> the .: operator was supposed to help with that situation (grabbing a Method when #method is overridden)
Guest70 has joined #ruby
<mooff> i wish numbered parameters still looked like @1 @2 instead of _1, _2 :)
<mooff> _1 _2 just look out of place and confusing in Ruby code
<mooff> i think *even though* @abc refers to instance variables, @1 @2 were still intuitive, and felt right
<mooff> anyway, </shouting into the void as self therapy> :)
Guest70 has quit [Client Quit]
<mooff> i've got a singleton module - a module which extends itself - that represents a collection of bots
<mooff> it has methods like EvalBots.setup, EvalBots.reset, EvalBots.bots
<mooff> i'm trying to include Enumerable in it so i can EvalBots.find, EvalBots.first, etc
Aylat has joined #ruby
Aylat has joined #ruby
Aylat has quit [Changing host]
<mooff> i've done include Enumerable; def each() bots.each end, but the Enumerable methods see the collection as empty
pgeorgi has left #ruby [#ruby]
jlindgren has left #ruby [The Lounge - https://thelounge.chat]
<mooff> aah, need to def each(&blk) bots.each(&blk) end instead :)
constxd has quit [Ping timeout: 250 seconds]
ur5us has joined #ruby
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
___nick___ has joined #ruby
<ox1eef> or: def each; bots.each { yield(_1) }; end
<ox1eef> i dont think thatd handle foo.each returning an enumerator though.
<leah2> you can write def each(&); bots.each(&) end now i think
___nick___ has quit [Ping timeout: 256 seconds]
Guest53 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oxfuxxx has quit [Ping timeout: 256 seconds]
Aylat has quit [Read error: Connection reset by peer]
<ox1eef> oh nice, havent seen that before
oxfuxxx has joined #ruby
samgranieri has quit [Quit: samgranieri]
pgib has joined #ruby
<leah2> new in 3.1 or so
<leah2> or 3.0 maybe
<ox1eef> is it very specific to that case? can you reference & within 'def each(&)' ?
<leah2> i think the point it is has no name
<leah2> you can just pass it on
<ox1eef> yeah, seems it cant be referenced in any other context than the one proposed. great to have in your toolbox all the same.
<leah2> i think you can also do def each(...)
bluedust has quit [Remote host closed the connection]
<ox1eef> yep, that works too
<ox1eef> def each(...); @collection.each(...); end
<ox1eef> im using ruby 3.1
ur5us has quit [Ping timeout: 256 seconds]
constxd has joined #ruby
roshanavand has quit [Remote host closed the connection]
roshanavand has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
exondation has quit [Ping timeout: 256 seconds]