conta1 has quit [Remote host closed the connection]
phaul has joined #ruby
miskatonic has joined #ruby
_phaul has quit [Ping timeout: 256 seconds]
caterfxo has joined #ruby
phaul has quit [Ping timeout: 250 seconds]
phaul has joined #ruby
ur5us has joined #ruby
<leitz>
geospeck, likely a good group. :)
Technodrome has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
miskatonic has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
hutch has joined #ruby
<leitz>
If I create a class to specify an error, and call the new class in a rescue block, how do I make the error be in the new class?
<leitz>
So far I have: class FileNotFound < Errno::ENOENT; end
<leitz>
and then: rescue FileNotFound => error
<leitz>
But this gives "Errno::ENOENT": p error.class
NODE has quit [Quit: changing servers]
xNetX0 has joined #ruby
<phaul>
the code that raises the error decides what it raises. File.open raises Errno::ENOENT. You would have to wrap the built in methods in your own, rescue and re-raise your own error in the wrapper.
stooj has quit [Remote host closed the connection]
stooj has joined #ruby
<leitz>
phaul, thanks. I'm trying to learn more about exceptions.
jingjinghack has quit [Ping timeout: 260 seconds]
jingjinghack has joined #ruby
phaul has quit [Quit: :wq]
oneeggea_ has joined #ruby
oneeggeach has quit [Ping timeout: 260 seconds]
oneeggea_ has quit [Client Quit]
bvdw has quit [Read error: Connection reset by peer]
brool has joined #ruby
bvdw has joined #ruby
jingjinghack has quit [Ping timeout: 265 seconds]
schne1der has joined #ruby
buckworst has joined #ruby
jingjinghack has joined #ruby
buckworst has quit [Client Quit]
buckworst has joined #ruby
buckworst has quit [Client Quit]
buckworst has joined #ruby
pandakekok9 has quit [Quit: good night]
buckworst has quit [Quit: WeeChat 2.8]
arcaos has quit [Ping timeout: 256 seconds]
buckworst has joined #ruby
arcaos has joined #ruby
gix has joined #ruby
buckworst has quit [Quit: WeeChat 2.8]
ChmEarl has joined #ruby
jingjinghack has quit [Read error: Connection reset by peer]
jingjing1 has joined #ruby
phaul has joined #ruby
dviola has quit [Ping timeout: 256 seconds]
dviola has joined #ruby
rainer_tm has quit [Quit: WeeChat 1.6]
jingjing1 has quit [Quit: WeeChat 2.1]
d3bug has joined #ruby
esrse has joined #ruby
KamLy has quit [Remote host closed the connection]
dasher00 has joined #ruby
KamLy has joined #ruby
KamLy has quit [Ping timeout: 272 seconds]
Esa_ has quit []
nofxx__ has joined #ruby
titanbiscuit has quit [Ping timeout: 265 seconds]
nofxx_ has quit [Ping timeout: 264 seconds]
buckworst has joined #ruby
Esa_ has joined #ruby
buckworst has quit [Quit: WeeChat 2.8]
sergioro has joined #ruby
esrse has quit [Remote host closed the connection]
jordanm has quit [Ping timeout: 256 seconds]
jintseng has joined #ruby
cd has joined #ruby
jordanm has joined #ruby
sergioro has quit [Quit: leaving]
chalkmonster has quit [Quit: WeeChat 2.8]
sergioro has joined #ruby
chalkmonster has joined #ruby
johnny56_ has joined #ruby
johnny56 has quit [Ping timeout: 250 seconds]
darkstardev13 has quit [Remote host closed the connection]
darkstardev13 has joined #ruby
beaorn has joined #ruby
beaorn has left #ruby [#ruby]
conta1 has joined #ruby
conta1 has quit [Quit: conta1]
xNetX0 has quit [Quit: changing servers]
rainer_tm has joined #ruby
xNetX0 has joined #ruby
rainer_tm has quit [Client Quit]
lalitmee has joined #ruby
lalitmee has quit [Max SendQ exceeded]
lalitmee has joined #ruby
GodFather has quit [Ping timeout: 265 seconds]
m27frogy has quit [Ping timeout: 256 seconds]
buckworst has joined #ruby
GodFather has joined #ruby
apteryx has quit [Read error: Connection reset by peer]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
hassox has joined #ruby
jintseng has quit [Quit: Leaving]
m27frogy has joined #ruby
lineus_ has joined #ruby
SuperLag has quit [Remote host closed the connection]
lineus has quit [Ping timeout: 240 seconds]
buckworst has quit [Quit: WeeChat 2.8]
rainer_tm has joined #ruby
apteryx has joined #ruby
stoffus has joined #ruby
stoffus has quit [Client Quit]
stoffus has joined #ruby
stoffus has quit [Client Quit]
titanbiscuit has joined #ruby
stoffus has joined #ruby
titanbiscuit has quit [Read error: Connection reset by peer]
<havenwood>
leitz: Generally in Ruby, exceptions should be exceptional and shouldn't be used for flow control. There are exceptions to that rule.
<havenwood>
leitz: File.file?(file)
<havenwood>
File. File? File!
<apotheon>
file it down to a sharp point
<leitz>
havenwood, the idea is to wrap the exception into something that communicates to a non-Ruby user. Most won't know what Psych is, for example.
<leitz>
havenwood, in theory, the config file might not be there, and the defaults will be taken. I was more playing with exceptional ideas that didn't quite make it to a reasonable point.
<havenwood>
leitz: Instead of using the exception for flow control, how about?: abort "Fatal: The `#{file}' file must exist. See the docs at https://. Aborting.' unless File.file?(file)
<havenwood>
leitz: If an exception happens, it should mean something exceptional happened. Avoid exceptions in run-of-the-mill circumstances.
conta has quit [Quit: conta]
<havenwood>
leitz: Here, File.file? can be used if there's a question of whether the file exists.
<apotheon>
hmm
<apotheon>
I've always used File#exist? instead of File#file? . . .
<havenwood>
leitz: If you find yourself using exceptions for flow control, consider whether there's a better way to do it without using exceptions.
<leitz>
havenwood, understood. What would likely actually make it into the code would be File.readable?(file), and then a custom exception if the yaml is malformed. If the file isn't there, then the defaults would be taken.
<havenwood>
apotheon: That's count directories to, which I discounted since leitz is using File.open.
<havenwood>
That'd*
<apotheon>
right
<apotheon>
makes sense
<apotheon>
err, not #, sorry
<apotheon>
not instance methods
<havenwood>
leitz: Good, that sounds like reasonable logic for flow control.
<apotheon>
It seems like there should be a Dir.dir? as well.
<apotheon>
. . . but there is a File.directory? so I guess that's covered.
<apotheon>
It just feels asymmetric.
<havenwood>
apotheon: File.directory?
<havenwood>
apotheon: "Everything is a file," I guess.
<apotheon>
yeah
<leitz>
To be filed away for later.
<apotheon>
perhaps
<apotheon>
That just leaves Dir feeling like syntactic sugar on top of File, in a way.
<havenwood>
apotheon: It does seem reasonable to have a Dir.dir?
Deesl has joined #ruby
<havenwood>
apotheon: There's Dir.exist? after all.
<havenwood>
apotheon: So redundancy already exists.
<apotheon>
Weirdly, though Dir.exist? is basically Dir.dir?, instead of being a Dir analog to File.exist? . . .
<apotheon>
s/though/thought,/
<apotheon>
s/thought/though/
<apotheon>
damn it
<apotheon>
correcting my regex with a regex
<havenwood>
apotheon: Yeah. You might have luck proposing Dir.dir? as an alias to Dir.exist? but then that might confuse DIr.exist? further.
<apotheon>
yo dawg
<apotheon>
I still kinda feel a mite annoyed that File.exists? has been removed.
<apotheon>
or deprecated, anyway
<apotheon>
I don't know that such an alias is a great proposal, given that.
<havenwood>
apotheon: That was a matter of not wanting two forms of address, rather than an indictment on other aliases.
<apotheon>
"if File.exist? 'foo.txt'" just doesn't roll off the tongue as well as "if File.exists? 'foo.txt'"
<havenwood>
apotheon: Matz feels like #exists? is bad grammar, when addressing an object.
<apotheon>
err
<leitz>
havenwood, but there are already so many forms of address.
<apotheon>
hmm
<apotheon>
How is it bad grammar? I missed that reasoning.
<havenwood>
leitz: IIR, Matz felt like it was the wrong way to address an object, gramatically.
<havenwood>
apotheon: Do you exists?
<apotheon>
. . . so we're using some kind of implicit, unspoken/unwritten sentence that doesn't actually appear in the code at all as your standard of grammar, I guess.
<apotheon>
That's kind of odd.
tainer32 has joined #ruby
<havenwood>
apotheon: Yeah, I thought it was interesting.
<havenwood>
I feel like it's of Smalltalk origin, but unsure why.
<leitz>
Yeah, and if you're going to use English grammar, well, good luck with that. We only make more rules so we can break more rules.
<havenwood>
leitz: A Japanese aesthetic of English grammar. :P
<apotheon>
I kinda feel like a more appropriate approach, in some respects, would be to make it something like String#file? rather than File.exist? filename, in any case.
<apotheon>
The File.exist? approach makes File more of a God-object.
<havenwood>
'matz explained that the question that should be asked is "object, do you exist" (singular, specific to the object at hand) rather than the english sentence question "does this object exist / if object exists?"'
lalit has joined #ruby
<havenwood>
shevy's explanation. :) where is shevy??
<havenwood>
not on IRC these days, it seems
<apotheon>
I mean, I kinda understand why Matz would reason that way, superficially, because typing "File.exist?" isn't "executing a method"; it's sending a message to the File object. It's just that getting picky about the grammar for message-sending when the receiver is acting as a God-object by virtue of that method existing in File at all, with the argument as the actual target of the message in a way,
<apotheon>
is kinda getting the cart before the horse.
<havenwood>
We just need to personify objects more.
<leitz>
havenwood, so, it's talking to something (2nd person) vs about something (3rd person).
<havenwood>
leitz: Yup.
<havenwood>
leitz: You're messaging an object, which is the receiver of the method call.
<apotheon>
Let's do away with "if" as a keyword and use methods instead.
<havenwood>
"I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages..." -Alan Kay
<apotheon>
Yeah, Alan Kay is pretty awesome.
<leitz>
It sounds Smalltalk-y, but i'm still learning.
<apotheon>
Reading some of his commentary about OOP helped inform my approach to writing Ruby.
<apotheon>
leitz: Ruby's design was partly inspired by Smalltalk, so that makes sense.
<apotheon>
I think I recall Alan Kay at one point saying that he always knew Smalltalk would take off, but didn't realize it would be called Ruby when it happened.
<leitz>
Yeah, now we just have to get Ruby to have some good market share outside of Rails.
<havenwood>
It's a shame that the MagLev implementation of Ruby on Stoned never took off. That live Object DB was amazing. The team was acquired by VMWare.
<havenwood>
IIR correctly, zenspider was an advocate of MagLev.
<havenwood>
leitz: I think Ruby does have good market share outside of Rails. ¯\_(ツ)_/¯
<havenwood>
leitz: I guess it depends on what you mean by "good."
<havenwood>
#ruby channel has more folk than #rails channel. I rest my case. :P
<havenwood>
#methodologyatleastbetterthantiobe
<leitz>
havenwood, that's because everyone is going to some JS thing if they want it easy, or Go thing if they want to call themselves data scientists.
<havenwood>
leitz: I'd think Python for data science.
<leitz>
Python has market, based on educational facilities moving to it, from Java.
<CommunistWolf>
bioinformations uses a lot of python where previously it was perl
<havenwood>
leitz: Our data science folk seem to be primarily Python. Pycon has a ton of data science.
<leitz>
But I'm not sure it's as performant as Go, especially when you start talking scads of cores. That said, I really don't know.
<havenwood>
leitz: The Python stuff is all backed by multicore utilizing C code.
<havenwood>
leitz: Great pains have gone into optimization.
<leitz>
havenwood, ah, that'd do it.
<leitz>
My definition of "good market share" is looking at jobs and seeing if they actually reference using Ruby, without Rails.
<apotheon>
I don't think I've seen a single job listing that wanted Ruby but not Rails.
<leitz>
An imperfect metric, to be sure.
<apotheon>
Some used Ruby for stuff other than Rails, but also used Rails.
<akem>
Hi, i'm trying to build ruby right now, do i need to build something separate to support gems?
<leitz>
I've seen some, but not a lot.
<apotheon>
leitz: I want those jobs.
<apotheon>
Well . . . not if they're JRuby. I'd rather not have to touch the JVM.
<leitz>
akem, do you need to build ruby, or can you install a pre-built version.
<akem>
leitz, Well, i just wanna build it, it's compiled already. Ruby is not hard to build but i'm not sure about gems.
<havenwood>
leitz: apotheon: I've seen plenty of job listings for Chef, security (Metasploit or other), and just general Ruby jobs. Granted, I've looked, but they weren't hard to find.
<akem>
I wanted to install the hornetseye gems for webcam on my precompiled ruby from Ubuntu but it didn't work.
<havenwood>
(I didn't Rails for years.)
<leitz>
havenwood, one of my (true or not) challenges is that I've only done small code stuff. In 2001 I wrote, documented, and trained on some infrastructure code that supported the production of the (at the time) world's largest paid subscriber website.
<akem>
That issue: /usr/bin/ruby2.5: No such file or directory -- /usr/share/rubygems-integration/all/gems/rake-12.3.1/exe/rake (LoadError)
<apotheon>
havenwood: Ah, I guess Chef and Metasploit involve some Ruby, but . . . they also don't really seem like Ruby jobs per se the way a Rails job is a Ruby job.
<havenwood>
akem: That's ^ a nice guide for installing a few simple tools that build Ruby for you.
<havenwood>
apotheon: You write Ruby code for a living. ¯\_(ツ)_/¯
<apotheon>
havenwood: Chef would just be one of the tools used by a DevOps job, and Metasploit by a pentesting job, I guess.
<leitz>
apotheon, Puppet was originally in Ruby, as well.
<havenwood>
apotheon: There are a fair number of security shops that write all their tools in Ruby.
<leitz>
havenwood, do tell?
<leitz>
havenwood, most of my work has been in securing servers.
<apotheon>
Sure, but I don't want a "security" or "sysadmin" or "DevOps" job. I explicitly got out of those fields and into dev.
<akem>
havenwood, Hm ok, but not exactly what i'm looking for i think. Thanks anyway.
<apotheon>
I guess if I want to write non-Rails Ruby code professionally, I need to be something other than a software dev.
<leitz>
akem, the simplest would be to use the system ruby, if it works, and then "gem install <whatever>".
<havenwood>
akem: To install the full Ruby package: sudo apt-get install ruby-full
<havenwood>
akem: If you get frustrated with the apt-packaged Ruby, there are other packages for Ubuntu or just building Ruby yourself often sidesteps all these issues.
<akem>
Ok. Well i compiled/installed it there, looks like gems is included, it should work. Trying it.
r3m has quit [Quit: WeeChat 2.9-dev]
<leitz>
I think you could make a business out of rapid prototyping stuff in Ruby.
r3m has joined #ruby
<leitz>
Not sure *I* could, but a business model where you build a simple mock up to discover the unknown unknowns.
<apotheon>
Yeah, I think I'm pretty good at developing interesting approaches to businesses, but not at actually making them happen because a business (and a business model) is nothing without customers/clients, and I suck at actually going out and getting them.
<leitz>
Join the club.
<apotheon>
I'm a founder!
<apotheon>
(of the club)
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
troulouliou_dev has joined #ruby
caterfxo is now known as mrwisdom
miskatonic has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
mjsir911 has quit [Quit: Goodbye, World!]
<havenwood>
&>> a = ->(n) { return n if n < 2; return 2 * a.(n / 2) if n.even?; a.(n.pred / 2) ^ a.(n.succ / 2) }; 82.upto(85).reduce('') { "#{_1}#{(a.(_2) + 97).chr}" }