havenwood changed the topic of #ruby to: Ruby 3.3.0, 3.2.2, 3.1.4 https://www.ruby-lang.org | Rules https://ruby-community.com | Logs https://libera.irclog.whitequark.org/ruby
Al2O3 has quit [Quit: Textual IRC Client: www.textualapp.com]
Al2O3 has joined #ruby
bambanxx has joined #ruby
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
rvalue has quit [Ping timeout: 264 seconds]
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
Linux_Kerio has quit [Ping timeout: 245 seconds]
bambanxx has joined #ruby
rvalue has joined #ruby
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
bambanxx has joined #ruby
aesthetikx has joined #ruby
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
graywolf has quit [Quit: WeeChat 4.0.4]
m_antis has joined #ruby
poems has quit [Ping timeout: 268 seconds]
poems has joined #ruby
CrazyEddy has quit [Remote host closed the connection]
<hexology> are there any books, tutorials, etc. that focus on using ruby for "data processing"? like what you might otherwise use perl, awk, or python for
<hexology> it was brought to my attention recently that ruby is supposed to be good for that kind of thing. i've historically always used python for it, but i'm interested in exploring
<adam12> hexology: Text Processing with Ruby I think? From OReilly.
<hexology> ah perfect
<hexology> looks like the pragmatic bookshelf has it https://pragprog.com/titles/rmtpruby/text-processing-with-ruby/
<adam12> Oh yeah, maybe they are the publisher.
<hexology> i like them, happy to give them my money
<adam12> Yep. 100%
<hexology> i assume this is not a rapidly changing domain, right? that is, this book isn't likely to go out of date quickly?
<adam12> bbl
<hexology> ah, ty for the advice
<adam12> hexology: I use Ruby for scripting every day since like 2004 and I don't think anything has changed, really.
<adam12> They even stole all the convenient command line args I was already using from Perl
<hexology> oh nice, that's really useful
<hexology> python needs a 3rd-party tool for things like perl -ne
<hexology> (on the cli, i mean)
<adam12> Nope. `ruby -ne` is built in.
<adam12> As well as BEGIN/END and lots of other choice stuff.
<hexology> that's very appealing. ty again!
poems has quit [Ping timeout: 256 seconds]
araujo has quit [Ping timeout: 268 seconds]
sam113101 has quit [Ping timeout: 268 seconds]
poems has joined #ruby
sam113101 has joined #ruby
fercell has joined #ruby
fercell_ has quit [Ping timeout: 255 seconds]
brokkoli_origin has quit [Remote host closed the connection]
brokkoli_origin has joined #ruby
CRISPR has joined #ruby
CRISPR has quit [Ping timeout: 252 seconds]
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby
bambanxx has joined #ruby
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
Vonter has quit [Ping timeout: 268 seconds]
bambanxx has joined #ruby
Paris has joined #ruby
Paris has quit [Client Quit]
xdminsy has joined #ruby
grenierm has joined #ruby
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
bambanxx has joined #ruby
Paris has joined #ruby
bambanxx has quit [Ping timeout: 276 seconds]
Al2O3 has quit [Quit: Good mourning, good after nun, g'nite, and goober evenings.]
Al2O3 has joined #ruby
Al2O3 has quit [Client Quit]
Al2O3 has joined #ruby
Al2O3 has quit [Client Quit]
Al2O3 has joined #ruby
Al2O3 has quit [Client Quit]
Al2O3 has joined #ruby
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
Linux_Kerio has joined #ruby
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 256 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 245 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 268 seconds]
jenrzzz has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 252 seconds]
jenrzzz has quit [Ping timeout: 252 seconds]
Paris has quit [Remote host closed the connection]
jenrzzz has joined #ruby
xdminsy has quit [Read error: Connection reset by peer]
_ht has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
araujo has joined #ruby
Starfoxxes has quit [Ping timeout: 260 seconds]
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz_ has quit [Ping timeout: 245 seconds]
<rapha> adam12: thanks for mentioning minitest-bisect ... that'll come in real handy once i'm dealing with randomized test. yesterday, my question was phrased ambiguously, i now realize. it were 2 different tests and nothing about them random. it took a good while before finding the problem. one of the models has "acts_as_paranoid", which was curious, as the Gem wasn't installed. turns out, there's a newer
<rapha> one called "paranoia", which still uses the same method name, but other than that works a bit differently, e.g. to destroy something, *that* method is called really_destroy! And then, it doesn't cascade, but okay, riddle solved. I will never get, though, why people in the Rails world insist on monkey patching and undiscoverable magic all the time.
Starfoxxes has joined #ruby
CrazyEddy has joined #ruby
araujo has quit [Ping timeout: 276 seconds]
grenierm has quit [Ping timeout: 250 seconds]
spinningCat has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
CrazyEddy has quit [Remote host closed the connection]
MomosOrDeath1 has joined #ruby
MomosOrDeath has quit [Ping timeout: 245 seconds]
MomosOrDeath1 is now known as MomosOrDeath
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
ht_ has joined #ruby
_ht has quit [Ping timeout: 276 seconds]
ht_ is now known as _ht
Guest12 has joined #ruby
<Guest12> hello
Guest12 has quit [Client Quit]
pgib has quit [Remote host closed the connection]
<adam12> rapha: If you're using minitest, just be aware that tests are randomized by default.
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
dviola has joined #ruby
Aminda has quit [Quit: Default quit message is difficult to set. If you don't see me returning, ask me? You will find me, if you want to]
Aminda has joined #ruby
Artea has quit [Quit: ZNC 1.6.2 - http://znc.in]
Artea has joined #ruby
bambanxx has joined #ruby
jas-maelstrom has quit [Remote host closed the connection]
xdminsy has joined #ruby
<rapha> adam12: the tests i'm writing at the moment don't use any helper functions for creating things. i'm handcrafting them, which seems to be the best approach at the moment. or did you mean the order that tests are run in is randomized?
<rapha> adam12: also, was it with you (or perhaps ox1eef_?) where we had a chat about different testing frameworks and different ways of doing fixtures a few months back? i remember bookmarking something that was very new then and that i wanted to check out again now. can't find the bookmark anymore though :(
graywolf has joined #ruby
ht_ has joined #ruby
_ht has quit [Ping timeout: 252 seconds]
ht_ is now known as _ht
<ox1eef_> acts_as_paranoid changes the behavior of '.destroy' in a strange way (eg when you call it once, that's a soft delete, call it twice and that's a hard delete). I would look into rolling my own, or choosing an alternative. If you're stuck with it then good idea to read the docs and learn of its quirks.
jas-maelstrom has joined #ruby
<ox1eef_> Don't recall a conversation about fixtures. I think we discussed rack-test not so long ago.
<ox1eef_> Ah I see. You are using a fork. I'm not sure if what I said rings true for the fork, but I agree, I don't like those kind of monkey patches.
<ih8u> what's the best way to convert a string to kebab-case?
<leftylink> but what case did it come in? because depending on that, it could either be a join(?-) or a .tr(?_, ?-)
<leftylink> luckily the casing part is easy since it's just a .downcase
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
<ih8u> say, a title
jenrzzz has joined #ruby
<ih8u> leftylink: i don't see a join method
<leftylink> pandabot: ri Array#join
<ih8u> ah, i see
<ih8u> source is a string
<ih8u> may contain punctuation
<ih8u> basically i need to make a windows-proof filename
<ox1eef_> str.gsub(/[\s.], "-")
<ox1eef_> str.gsub(/[\s.]/, "-") *
jenrzzz has quit [Ping timeout: 276 seconds]
<ih8u> unless i'm mistaken, that swaps any whitespace for '-'
<ox1eef_> Or encode/decode as base64 if it is only for a script to understand.
<ox1eef_> That's right.
<ih8u> this is something i whipped up a while ago
<ih8u> .downcase.gsub(/\./, 'PPP').gsub(/[[:punct:]]/, '').gsub(/\s/, '-').gsub(/PPP/, '-').gsub(/--/, '-').gsub(/-$/, '')
<ox1eef_> You shouldn't need all those calls to gsub. One gsub, and a character class, should do it. There's also gems dedicated to slug generation.
<ih8u> what do you mean by "a character class"?
Pixi has quit [Ping timeout: 260 seconds]
Pixi has joined #ruby
Vetheon has joined #ruby
<Vetheon> So there is a Ruby IRC! So glad I found this after abandoning Discord.
jenrzzz has joined #ruby
<ox1eef_> Good choice.
<Vetheon> Is there a "general" or "offtopic" ruby channel, or is this the only one?
<leftylink> well, there is #ruby-offtopic for off topci matters
<Vetheon> Thanks
<leftylink> the channels are listed at https://ruby-community.com/pages/channels
<Vetheon> Ahh there's what I couldn't find
jenrzzz has quit [Ping timeout: 260 seconds]
Req has joined #ruby
Vetheon has quit [Changing host]
Vetheon has joined #ruby
Vetheon has quit [Remote host closed the connection]
Vetheon has joined #ruby
<ih8u> is there any way to force a web page to refresh when the back button is pressed?
<ih8u> without javascript
<Vetheon> Are you referring to the back button of the browser, or a back button on your page?
<ih8u> back button of browser
<Req> I may be wrong but i think it depens on your browser in a way. What i think you are asking is... lets say you have page 1 that has a list then you navigate to page 2 to "add something to list". at which point you would want to navigate back to page one to view the list with now the +1 item listed.
<Req> if it is the first case im not sure. You might want to create a back button on your page that takes you back to page 1. most users will likley hit the provided button rather then using the browser controls.
<Req> The way that most browsers work is when you hit the back button it will either load the previously loaded content. basicly it re-draws the page that you were at before using the previously loaded html/etc. The second way is that it just re-navigates to the URL that you were at before.
<Req> or just use JS
<Req> if it is the second case then its likley becasue of how you have urls setup. you probably generate a new "page 1" each time a new item is added to it. if thats the case you will want to have a link that does not change that just points to the latest version of "page 1"
<Req> im sure there is more professional ways that im looking up now but for now try to expand on your problem with your use case
<ih8u> my use case is pretty straightforward
<adam12> ih8u: Is this still Unpoly related? If it is, maybe you want to disable caching for some routes.
<ih8u> it could be, if that's the solution
<ih8u> unless there's a roda way to address this
<adam12> Unpoly uses historyState, which will store in the browser cache.
<adam12> So when you back-button, if there is a history entry with a cache page, it will use that.
<ih8u> you're familiar with roda, right?
<adam12> ih8u: Me? A little bit :P
<ih8u> would you know of a way to accomplish this within roda?
<adam12> Accomplish what?
<rapha> ox1eef_: it's not actually acts_as_paranoid in this project, but "paranoia". which doesn't have the double thing. It still does monkeypatch #destroy* and #delete*. i think if i'd be allowed to roll my own, then i'd implement something like a #soft_destroy and not overwrite ActiveRecord.
<rapha> we did discuss rack-test not long ago, ox1eef_. the convo about ruby testing frameworks (and that very minimal and very new one) must be half a year ago. it was with another regular here, but might have been not you or adam.
<rapha> ah, sorry, only read your third line now.
Vetheon has left #ruby [#ruby]
<rapha> oh, havenwood perhaps. havenwood: does that ring a bell, some new ruby testing (or perhaps just test fixtures) gem, still in the works around half a year ago?
<adam12> Oof. This looks like a good reason to hold off until 3.3.1. https://bugs.ruby-lang.org/issues/20104
<rapha> be glad you're not stuck on 2.7.8 adam12 :)
<adam12> rapha: lol. why stuck?
<rapha> because rails6. thankfully, not for long anymore, we're seeing the light at the end of the upgrade-to-7 tunnel, and then, finally, it'll be 3+ again.
<rapha> hmm, do you agree with the rules this guy made for himself? esp #1 & #2? https://masilotti.com/rails-test-fixtures/
<adam12> rapha: Yes, 100%
<adam12> In my projects, I don't actually use "fixtures" anymore, but mostly each project will have a few "examples", and they are in dev/prod tool
<adam12> s/tool/too/
<adam12> so I might say `Models::User::Examples.active` and that would return me an active User.
<rapha> and how do you maintain your examples? as seeds?
<adam12> But I definitely dont' make too many variants.
<adam12> Nah. Plain objects.
<adam12> or maybe Sequel model instances.
<rapha> let me rephrase, where do place those?
<adam12> Usually inside the model class itself.
<rapha> oh!
<rapha> and you use Sequel in your Rails projects, too?
<ih8u> adam12: refreshing entire page on back
<ih8u> or certain elements, if possible
<adam12> rapha: No. I don't use Rails much at all anymore.
<rapha> for tha^t, i envy you adam :D
<rapha> but i'm still a little flabberghasted
<adam12> ih8u: First off, I'd make sure you're setting the boring old HTTP caching headers to disable caching.
<adam12> ih8u: Then, make sure you're using POST to perform destructive actions. That will automatically clear the cache normally.
<adam12> ih8u: Another option is to listen to an event for unpoly going back, and then maybe trigger a page refresh. I don't normally ever have to do this tho, so I'd be curious what you're doing.
<adam12> rapha: My projects are either Roda apps, some Sinatra apps, or I've just built my own web "framework" for new projects. It doesn't have a name, and it's not really for public consumption, but its here: https://bugs.ruby-lang.org/issues/20104
<ih8u> i have a sidebar that displays one thing if logged in and another if logged out
<adam12> err
<rapha> so you'll have a bunch of models, say, Car has_many Wheels, and then *in* your app/models/car.rb (or however you structure your non-Rails projects), which is *a database-backed model*, you'll have ... a bunch of example objects ... as, ur, what? @@class_variables?
<adam12> ih8u: Try setting cache-control headers first.
<adam12> rapha: No class variables. It returns an instance. I store it off.
<ih8u> when i log out, the side bar changes as desired, but when i press the back-button it goes back to showing the logged-in version
<ih8u> which is potentially dangerous
<rapha> adam12: won't #create persist that to your database? again and again, causing an error if, say, the email needs to be unique?
<adam12> rapha: Yes. I run all my tests in a transaction that rollsback at the end.
<rapha> but you said you use the same examples for test+dev+prod - and you can't just rollback everything in prod :P
<adam12> rapha: I only create the record once, during test set up.
<adam12> rapha: No, but I'm just saying, if I wanted to pre-seed a QA environment, I just ask for examples of everything
<rapha> ah ok, so not in prod
<adam12> It could be prod.
<adam12> Maybe not necessarily Account, but for some items it could be.
<rapha> sounds potentially insecure
<adam12> It could be.
<rapha> oh, right, for a Product in a webshop or so, it might be ok
<rapha> am i understanding correctly that that Gist you posted would be the same code forr all environments? in that case i still don't understand how, in a non-QA environment, the #create & rollback would work?
<adam12> rapha: Well, I don't need to rollback in those environments.
<adam12> Those examples are only called during tests
<adam12> or when I want something to play with on the console.
<rapha> oooh that part of the code might just not ever be exercised in production
<rapha> got it now
<rapha> it's sort of amazing to have the examples for the model right there, IN the model
<rapha> sooooooooo much pain comes from levels and levels of indirection
<adam12> Yeah. I like at a glance looking at the shape of what the data might be
<adam12> Especially with something like an ActiveRecord or Sequel model, which generates attributes from database tables.
<rapha> yeah
<rapha> and i love that gem which maintains a comment of the current state of the database table for you on top of the model file
<rapha> oh, check out https://github.com/tendersearls/tldr ... not the one i'm looking for but very funny :)
<ih8u> adam12: how does one "set cache-control headers"?
<ih8u> my search is turning up explanations of what a cache-control is, but assume i know i to use them
<adam12> ih8u: I think in my projects I just set response.headers["Cache-control"] = "some-value"
<adam12> ih8u: I've normally just set no-cache or whatever the value is, at the top of the routing tree.
<adam12> rapha: Yeah, I'm using tldr on one of my libraries. I like that it has a built in runner, but I had to disable the emoji output since I find it super distracting.
<rapha> that sort of thing _is_
<adam12> ih8u: Actually, make sure you lower-case `cache-control`. I think that's a new Rack 3 thing you might run into.
<rapha> somehow became chic after the js hipsters took over
<ih8u> i can't seem to get anything to work
<ih8u> i put your code right after `route.do |r|`
<adam12> something like `no-store, no-cache`?
<adam12> Checked browser tools to see header being set on the response for those pages?
<ih8u> no-store seemed to do the trick
TomyLobo has joined #ruby
<ih8u> reading this, it seemed to suggest that no-cache was sufficient
ollysmith has quit [Quit: ZNC 1.8.2+deb4+b1 - https://znc.in]
ollysmith has joined #ruby
<ih8u> apparently, this also works: `response.cache_control no_store: true, no_cache: true`
<adam12> ih8u: Oh yes, I forgot that existed.
<ih8u> but i don't understand why no-cache by itself is not sufficient
<adam12> I feel like I ran into the same thing, which is why it took no effort to remember `no-store`
<adam12> 30 years of web cruft built up, I guess
<ih8u> this platform is insane
<ih8u> thank you for your help
<adam12> yw
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
mweckbecker has quit [Quit: leaving]
jenrzzz_ has quit [Ping timeout: 256 seconds]
Req has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
mweckbecker has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 255 seconds]
<havenwood> Interesting proposal implementation for an adding `extend Immutable` to Ruby https://bugs.ruby-lang.org/issues/18035
<havenwood> LGTM
<havenwood> It's been long in the running, but wondering if 3.4 if the time.
Paris has joined #ruby
havenwood has quit [Quit: The Lounge - https://thelounge.chat]
jenrzzz has quit [Ping timeout: 268 seconds]
havenwood has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 276 seconds]
jenrzzz has quit [Ping timeout: 276 seconds]
Paris has quit [Quit: quit]
_ht has quit [Quit: _ht]
rhe has quit [Ping timeout: 256 seconds]
rhe9 has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
rhe has joined #ruby
rhe9 has quit [Ping timeout: 256 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
xdminsy has quit [Ping timeout: 256 seconds]
graywolf has quit [Quit: WeeChat 4.0.4]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
whysthatso125070 has quit [Quit: The Lounge - https://thelounge.chat]
whysthatso125070 has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz_ has quit [Ping timeout: 276 seconds]
Paris has joined #ruby
whysthatso125070 has quit [Quit: The Lounge - https://thelounge.chat]
FullMetalStacket has joined #ruby
029AAIH49 has joined #ruby
048AAK7ZL has joined #ruby
048AAK7ZL has quit [Ping timeout: 245 seconds]
029AAIH49 has quit [Ping timeout: 264 seconds]
FullMetalStacker has joined #ruby
FullMetalStacket has quit [Quit: Konversation terminated!]
Al2O3 has quit [Quit: Good mourning, good after nun, g'nite, and goober evenings.]
Al2O3 has joined #ruby
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
Linux_Kerio has quit [Ping timeout: 264 seconds]
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby