<al2o3-cr>
minall: if you don't want a newline added.
<havenwood>
minall: Options include #print, #p, and #warn.
<minall>
Thanks!, I made some examples by it
<minall>
I'll continue studying and come If I need help
<havenwood>
minall: #print doesn't add a newline, like al2o3-cr said. #p adds a newline, but also an #inspect for debugging. #warn also adds a newline, but prints to stderror instead of stdout.
hoijui has joined #ruby
<havenwood>
minall: #abort prints to stderr with a newline, like #warn, but also exits with an error status like: exit 1
<al2o3-cr>
havenwood: i didn't say print adds a newline?
<havenwood>
al2o3-cr: I haven't had coffee. Omits I meant.
<minall>
lol
<al2o3-cr>
havenwood: oh, nvm ;)
<minall>
Thanks!
zacts has joined #ruby
<havenwood>
The #pp is particularly handy too, now that it's required by default.
<simonfromspace>
can someone please ELI5 the difference between exlcude and include?
<simonfromspace>
regarding Modules and Classes, of course.
<havenwood>
simonfromspace: exclude isn't a thing
<havenwood>
simonfromspace: ah, I think you mean #extend
<havenwood>
simonfromspace: include and prepend are most often used within a class to make the instance methods of the included module also instance methods of the class.
<havenwood>
simonfromspace: prepend just differs from include in that it puts the methods *in front* of a method by the same name in the including class.
<havenwood>
simonfromspace: if you use #module_function in the module you're including via #include or #prepend, then the included instance methods will be private, not publicly exposed on instances of the class.
<havenwood>
simonfromspace: #extend is used less often than #include, since it extends instance methods to be class methods on the extending class.
<havenwood>
simonfromspace: So you have Klass and ExtendMe. Inside Klass, you `extend ExtendMe` and you can then do `Klass.method_from_extend_me` as a class method on Klass.
<havenwood>
simonfromspace: Which is used less often than Klass with IncludeMe. With #include, inside Klass you `include IncludeMe` and you can then do `Klass.new.included_method` as an instance method on Klass.
ttoocs has quit [Ping timeout: 246 seconds]
<havenwood>
simonfromspace: Does that make any sense?
towo_ has quit [Quit: I am the vanguard of your destruction. This exchange is over.]
duderonomy has joined #ruby
towo has joined #ruby
dStromboli has quit [Ping timeout: 272 seconds]
ThibG has left #ruby ["Leaving"]
dStromboli has joined #ruby
leitz has joined #ruby
<TomyWork>
hnnnng, why can # encoding: utf-8 not be in line 3
<simonfromspace>
havenwood, sorry yeah I meant extend. Thank you so much for that! It makes sense and I'll come back a couple times to refer back to your ELI5. Arigato!!!
<havenwood>
TomyWork: Magic comments are finicky.
<TomyWork>
yeah, and that to figure out that i have an ancient ruby version that doesnt default to utf-8 in the first place... cost me an hour
<TomyWork>
i was about to ask something stupid like "does ruby 1.9.3 support +="?
<TomyWork>
i was about to ask something stupid like "does ruby 1.9.3 support += on strings?"
<havenwood>
I do use solargraph, but so look forward to integrated autocomplete that's even smarter.
<adam12>
havenwood: neat! what editor are you using?
<havenwood>
adam12: i've been trying VSCode
chalkmonster has quit [Quit: WeeChat 2.7]
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
<zacts>
will ruby 2.* still live alongside ruby 3.*, or will ruby3 make ruby2 obsolete for new applications?
<zacts>
(I'm hoping it's not going to be like python2 and python3)
<adam12>
zacts: Pretty sure matz has no interest in a python2/python3 scenario (akin to the Ruby 1.8 and 1.9 scenario of past)
chalkmonster has joined #ruby
<zacts>
cool
chalkmonster has quit [Client Quit]
<adam12>
zacts: The Ruby 3 breaking changes look much smaller right now (keyword args mostly?)
<zacts>
how will Ruby 3 handle concurrency?
<adam12>
zacts: There's talks about the new guilds making it in; but who knows if they will be ready. There's ongoing work around fibers which might make for them to be more common / popular vs threads or processes.
<zacts>
ah ok, cool
<adam12>
zacts: Fibers are already in some use, but they need to wrap IO primitives and that's ongoing.
davidw has joined #ruby
<adam12>
zacts: And of course, optional gradual types.
<zacts>
(note: I'm just curious. I don't know how to program for concurrency quite yet, but I'm curious as to what is out there)
<zacts>
I have heard of fibers, but I wanted to see if something new was in the brew
<zacts>
but sounds like improvements to fibers for sure, but potentially guilds (but no promise for them)
<adam12>
zacts: Multiple options, all with pros/cons. A lot of it depends on the workload expected.
mikecmpbll has quit [Remote host closed the connection]
ChmEarl has joined #ruby
zacts has joined #ruby
bsdbandit-01 has quit [Ping timeout: 240 seconds]
citizentwo has joined #ruby
ewanchic has quit [Quit: Leaving.]
ewanchic has joined #ruby
royal_screwup21 has joined #ruby
orbyt_ has joined #ruby
ewanchic has quit [Ping timeout: 260 seconds]
orbyt_ has quit [Client Quit]
bsdband50 has joined #ruby
ewanchic has joined #ruby
cd has joined #ruby
ewanchic has quit [Client Quit]
ewanchic has joined #ruby
LinuxKnight has quit [Ping timeout: 240 seconds]
citizentwo has quit [Remote host closed the connection]
citizentwo has joined #ruby
siery has joined #ruby
bsdband50 has quit [Ping timeout: 272 seconds]
fphilipe has quit [Ping timeout: 265 seconds]
bsdbandit-01 has joined #ruby
dStromboli has quit [Ping timeout: 272 seconds]
dStromboli has joined #ruby
rippa has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
clemens3 has quit [Quit: WeeChat 2.1]
duckpupp- has quit [Remote host closed the connection]
xco has joined #ruby
duckpuppy has joined #ruby
chalkmonster has joined #ruby
conta has quit [Quit: conta]
chalkmonster has quit [Client Quit]
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
<simonfromspace>
yo, when I make a file, it outputs it in the repo folder. How do I make it output, either inside a folder inside the repo or on the desktop?
zacts has quit [Quit: zacts]
chalkmonster has joined #ruby
<adam12>
simonfromspace: Provide a full path to the file you want to write. File.write("/home/simonfromspace/Desktop/thefile", "contents").
<simonfromspace>
It's gonna be reviewed by someone and I don't know how their system is organized
ChmEarl has quit [Read error: Connection reset by peer]
LtHummus_ has quit [Ping timeout: 272 seconds]
chalkmonster has joined #ruby
dStromboli has joined #ruby
yan13to has joined #ruby
ChmEarl has joined #ruby
<simonfromspace>
adam12, jhass the single dot worked for now
<simonfromspace>
i think this is best for this project
teclator has quit [Ping timeout: 260 seconds]
LtHummus has joined #ruby
teclator has joined #ruby
tdy has quit [Quit: WeeChat 1.9.1]
jenrzzz has quit [Ping timeout: 272 seconds]
zacts has joined #ruby
yan13to has quit [Quit: leaving]
leitz has quit [Quit: Leaving]
code_zombie has joined #ruby
markopasha has quit [Remote host closed the connection]
hiroaki has joined #ruby
zacts has quit [Quit: zacts]
gix has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xco has joined #ruby
tdy has joined #ruby
smurfke has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
code_zombie_ has joined #ruby
code_zombie has quit [Ping timeout: 240 seconds]
xpitr has quit [Changing host]
xpitr has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<simonfromspace>
If you were asked to write unit tests for a scraper, what would you even test for exactly? I can't think of anything.
<apotheon>
simonfromspace: test for accurace of what it scrapes by having a local "webpage" in your test fixtures that you scrape and compare results against your test condition
<apotheon>
s/accurace/accuracy/
<simonfromspace>
oh nice
<apotheon>
You don't need to hurry so much that it becomes an accuRACE.
<apotheon>
Yeah, I test-drive the shit out of my code, so I think I'm pretty okay at coming up with test designs.
ur5us has joined #ruby
<apotheon>
I test-drive C.
<simonfromspace>
apotheon, nice to meet you, test master
<apotheon>
If you want to hire me for a job with that title, I'm game.
<apotheon>
I really like test-driving, and I really like refactoring. I find them fun.
<havenwood>
simonfromspace: I agree with a local file to test the content parsing of what would really be remote. You can replay web requests, but seems no need to test the HTTP client here: https://github.com/vcr/vcr
<apotheon>
Also, a job with "master" in the title typically pays well.
<simonfromspace>
This is a Ruby question, so on some of these pages, the magnet or some other item may not be available. How do I skip to the next one elegantly?
<simonfromspace>
Thanks for VCR. I'll try to figure out how to use it.
<apotheon>
I used the crap out of VCR on a project two employers ago.
<simonfromspace>
https://i.imgur.com/FckseyZ.png <---> This is a Ruby question, so on some of these pages, the magnet or some other item may not be available. How do I skip to the next one elegantly?
<simonfromspace>
apotheon, you must be a Super Senior Dev
cliluw has quit [Quit: Leaving]
cliluw has joined #ruby
<simonfromspace>
if it gets a nil response or error from the page, I want it to put a default value, maybe. any thoughts?
<havenwood>
simonfromspace: Are you familiar with the lonely person operator?
<apotheon>
simonfromspace: I might eliminate some of the duplication in the code in that image by use of tap, by the way.
<apotheon>
Too-long lines of code thanks to duplicated code kinda drives me batty sometimes.
<havenwood>
simonfromspace: Instead of `(0..itemcount).each do` you can use `itemcount.times do`.
<apotheon>
havenwood: You've been cemented in my mind as a good resource for info that hasn't crept into my coding cave yet.
<apotheon>
Oh, yeah, I totally didn't even notice the (0..itemcount) part.
<havenwood>
simonfromspace: I agree with apotheon that you should DRY out the `@parsed_page.css('tr.forum_header_boarder')`. Maybe start with a local variable?
<havenwood>
simonfromspace: Then DRY up the `thread_posts`s portion too.
<havenwood>
simonfromspace: Consider `.first` in place of `[0]`.
<havenwood>
simonfromspace: Show us more code if you'd like more feedback?
<havenwood>
(Are you allowed to get outside code reviews?)
<apotheon>
havenwood: I thought about "local variable", but . . . I like tap, too.
<havenwood>
apotheon: Or #then, when appropriate. :)
cliluw has quit [Read error: Connection reset by peer]
cliluw has joined #ruby
darkstardevx has quit [Remote host closed the connection]
darkstardevx has joined #ruby
<ytti>
when ever i think of golang, i think of what linus said about svn's slogan of 'cvs done right'
<ytti>
because golang is kinda like c done right, and similarlyt like you can't do cvs right, you can't do c right
<ytti>
and simialrly like c, golang is full of bad NIH code, because the langauge itself offers so little out-of-the-box
<ytti>
by design
<CommunistWolf>
nah, go doesn't compete with C
<ytti>
legit design philosophy, but one i don't subscribe to
<ytti>
i don't mean it competes against c, of course it doesn't in all apllications due to GC
<CommunistWolf>
that's zig's job
<ytti>
and runtime
<ytti>
but it is similar language and takes lot from c
<ytti>
and the authors like c adn think c is good language
<ytti>
sand they think it's advantage that the language is simple and contains very little
<ytti>
because their argument is, then it's easier to employ developers
<CommunistWolf>
thing is, go's stdlib is very comprehensive
<ytti>
when they have simpler language to master, you can train them faster
<ytti>
i disagree
<CommunistWolf>
and in many cases better than ruby's
<ytti>
not compared to ruby, rust or kotlin
<CommunistWolf>
dunno about kotlin, but otherwise yes
<ytti>
types have much fewer functions/methods than any of them
<CommunistWolf>
wasn't really intending to get into a language war though
<ytti>
i maen you can count this
<ytti>
it's not like it's debate
cliluw has quit [Read error: Connection reset by peer]
cliluw has joined #ruby
* ewanchic
watches two snow creatures: a yetti and a cold wolf, discuss the unique elegance of different languages.
zacts has joined #ruby
cd has quit [Quit: cd]
hoijui has quit [Ping timeout: 246 seconds]
drincruz_ is now known as drinceruz
drinceruz is now known as drincruz
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
coffeex3 has joined #ruby
tdy has quit [Ping timeout: 240 seconds]
lxsameer has joined #ruby
<ewanchic>
I hate to ask and run, but I installed Gemirro last night (Gem Server Mirror), and I wont download gems to my local system. I get: WARNING: Unable to pull data from 'http : //gems.wanchic.com/' : bad response Bad Gateway 502 (http : //gems.wanchic.com/specs.4.8.gz)
<ewanchic>
What I did is I linked it up with Nginx. The webserver works, I get websites and the list from the website (local website, gems.wanchic.com, sorry it's not public). I test it on my local machine with ping and curl. It all works. I modified config.rb and loaded (and download) lost of gems. Finally I added the line that gemirro gave on the local website, 'gem sources -a http://gems.wanchic.com/', So I know that is in there.
<ewanchic>
Any ideas I can try? Everything is in a local network environment. I figure that has to be one more thing I'm missing to make this all click and work. Thank for the help!
Mallot1 has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<Mallot1>
Please help. I'm using sinatra and ALL I want to do is get my ApplicationController class actually running. I have a get route for /, but for some reason when I visit it in browser it does not work.
<Mallot1>
This should be insanely easy, but i cannot find the answer on the internet. This is my last resory
<ewanchic>
Mallot1: out of curiosity, http://127.0.0.1:8080 ? maybe it's finiky although local host should be the same.
<ewanchic>
Mallot1: Mac, Windows, or Linux?
<Mallot1>
Thanks but same error
<Mallot1>
Windows
<Mallot1>
Windows 10
<ewanchic>
Mallot1: Do you know if your virus scanner/windows firewall are blocking ports?
<Mallot1>
It was working in the pas
<Mallot1>
t
<Mallot1>
Just not this code
duderonomy has joined #ruby
burningserenity has quit [Quit: Leaving.]
<ewanchic>
Mallot1: I haven't done anything in sinatra before, sorry. I'm more of a Rails. I actually have to run, I teach class on the hour, and I have to finish this up. Perhaps I can try it on my own machine in 3 hours or so.
<Mallot1>
Thanks
duderonomy has quit [Client Quit]
<ewanchic>
Mallot1: No problem. If your still around I'll get back with you.
<Mallot1>
Alright :)
akemrir has quit [Quit: WeeChat 2.7]
fercell has joined #ruby
duderonomy has joined #ruby
citizentwo has quit [Ping timeout: 240 seconds]
citizentwo has joined #ruby
duderonomy has quit [Client Quit]
xco has joined #ruby
tdy has joined #ruby
bsdbandit-01 has quit [Ping timeout: 272 seconds]
duderonomy has joined #ruby
AnomalyXII has joined #ruby
<simonfromspace>
havenwood, apotheon I'm making changes and am implementing the advice you've given
SanguineAnomaly has quit [Ping timeout: 240 seconds]
hoijui has joined #ruby
coffeex3 has quit [Ping timeout: 272 seconds]
AnomalyXII is now known as SanguineAnomaly
bsdbandit-01 has joined #ruby
<Mallot1>
hello
<Mallot1>
How can I tell ruby where to look for config.ru when I rackup?
<leah2>
las last argument?
<leah2>
*as
<havenwood>
Mallot1: rackup /path/to/config.ru
<havenwood>
leah2: I just realized you beat me to the answer. That took me a sec.
<leah2>
well i wrote it :P
<leah2>
just had to verify it's still true
<Mallot1>
Oh :D
<havenwood>
leah2: --dir DIR is another option
<Mallot1>
I was running it in the app/controllers directory. Thanks! guys
<havenwood>
Mallot1: Or: --dir /path/
<havenwood>
Mallot1: rackup --dir /path/to/dir/
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
Mallot1: "Change to DIR before starting"
<havenwood>
Mallot1: See: rackup --help
<Mallot1>
So it should be rackup --dir, not rackup?
Arahael has joined #ruby
<havenwood>
Mallot1: You have options. Run just `rackup` in the right dir. Run `rackup --dir /right/dir`. Or run. `rackup /right/dir/config.ru`.
<Mallot1>
Alright, thanks
<Mallot1>
Now I get C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- app/controllers/application_controller.rb (LoadError)
<havenwood>
Mallot1: Same result with `--dir DIR`?
<havenwood>
Mallot1: Have you run `bundle` in the project? Are you using the right Ruby from the directory you're running `rackup` in? Are you running `bundle exec rackup`? Have you run `bundle` already?
<Mallot1>
Could not find gem 'em/pure_ruby x64-mingw32' in any of the gem sources listed in your Gemfile.
akemhp has joined #ruby
<Mallot1>
Alright, I removed that gem.
<Mallot1>
Main issue is "C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- app/controllers/application_controller.rb (LoadError)"
bsdbandit-01 has quit [Ping timeout: 245 seconds]
<Mallot1>
Got it!
<Mallot1>
I had to use require_relative on require 'app/controllers/application_controller.rb'
<Mallot1>
in my config.ru
<Mallot1>
Now what is weird though is that I set my port to 1111, but it's listening on 4567
bsdband70 has joined #ruby
bsdband70 has quit [Max SendQ exceeded]
bsdbandit-01 has joined #ruby
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo2 has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
Bounga has joined #ruby
Bounga` has joined #ruby
Bounga has quit [Ping timeout: 245 seconds]
akemhp has quit [Quit: Leaving]
Bounga` is now known as Bounga
Bounga has quit [Remote host closed the connection]
Bounga has joined #ruby
<Mallot1>
Hey, what does require_all 'app' do? It requires all the files in a directory right?