<Sanderd17>
Hello, I'm new to Ruby (coming from other scripting languages like JS and Python)
<jhass>
hey, welcome :)
<Sanderd17>
I was reading about how "require" works in ruby, and it seems to polute the global namespace to me
nofxx has joined #ruby
vondruch has quit [Ping timeout: 258 seconds]
<Sanderd17>
Python always had a way to import stuff that doesn't pollute the global namespace, and JS recently added ES modules, but had other module systems before
<jhass>
it's file based, similar to how C or PHP does it for example, so yes there's no file based namespaces
<Sanderd17>
My question is, do you ever get in trouble with that namespace pollution in practice? And are there plans to add a non-polluting require alternative?
<jhass>
local variables are file local, but constants and of course globals are not
nofxx_ has quit [Ping timeout: 246 seconds]
<jhass>
If you practice proper namespacing and naming convention it has never been any issue for me
<Sanderd17>
Ok, good to hear
<jhass>
in fact I had to fight with file based namespacing more, where things are not found or two files define the same function because, heh, we're namespaced so it's fine to do that at the toplevel!
<jhass>
where as in Ruby people are more disciplined about that because there's no such concept
<Sanderd17>
I also had to fight with file namespaces before (lately even an odd one, where I checked out a different branch, but as the -.pyc files aren't synchronised, python decided to use that instead of the py file I expected)
<Sanderd17>
But as a newbie, it seems a bit difficult to deduce where a function is coming from (is it built in, or from something that's being required). How do you handle that?
<Sanderd17>
Or do you need help from the IDE to handle that?
<jhass>
if it's a call on an object or module it's pretty obvious I think
<jhass>
for bare calls, often you can already tell from its name or context where it might come from
<jhass>
worst case just look it up in ruby core docs and if you're in a Rails context those docs
<jhass>
that should cover > 90% of the cases
<jhass>
then I have two strategies: For bigger projects I always install dependencies using bundler to a site local folder, so I can just grep through that
<jhass>
worst case I put a debugger and use introspection: method(:foo).source_location
<jhass>
?pry
<ruby[bot]>
Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
<jhass>
^ in general a great tool for exploring
Jonopoly has quit [Quit: WeeChat 2.9]
<Sanderd17>
Ok, so for everyday usage, it boils down to choosing good names. Thanks for the link to the tool (apparently I get a 404, but I can find that tool on github)
<jhass>
huh, did they change it
<jhass>
!fact edit pry Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (http://pry.github.io/): gem install pry pry-doc
<ruby[bot]>
jhass: I stand corrected that pry is Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (http://pry.github.io/)
<ruby[bot]>
: gem install pry pry-doc
<Sanderd17>
Thanks
ruurd has quit [Quit: bye folks]
dasher00 has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
dasher00 has quit [Ping timeout: 265 seconds]
Arkantos has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
siaw23 has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
Rudd0 has quit [Ping timeout: 265 seconds]
impermanence has joined #ruby
burgestrand has joined #ruby
chouhoulis has joined #ruby
chouhoulis has quit [Ping timeout: 256 seconds]
ruurd has joined #ruby
akem has quit [Ping timeout: 264 seconds]
TCZ has joined #ruby
kaivai has quit [Ping timeout: 260 seconds]
vondruch has joined #ruby
akem has joined #ruby
Jonopoly has joined #ruby
Jonopoly has quit [Client Quit]
Jonopoly has joined #ruby
akem has quit [Quit: Leaving]
impermanence90 has joined #ruby
impermanence90 has quit [Client Quit]
impermanence41 has joined #ruby
impermanence has quit [Ping timeout: 260 seconds]
impermanence41 has quit [Client Quit]
ChmEarl has joined #ruby
akem has joined #ruby
crankharder has joined #ruby
Technodrome has joined #ruby
bmurt has joined #ruby
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
vondruch has quit [Ping timeout: 260 seconds]
impermanence has joined #ruby
deadk has quit [Quit: edk]
vondruch has joined #ruby
deadk has joined #ruby
TCZ has quit [Quit: Leaving]
yxhuvud has quit [Ping timeout: 260 seconds]
Sanderd17 has quit [Ping timeout: 245 seconds]
dionysus69 has quit [Ping timeout: 264 seconds]
mikecmpbll has joined #ruby
cthulchu_ has joined #ruby
chouhoulis has joined #ruby
BH23 has quit [Read error: Connection reset by peer]
chouhoulis has quit [Ping timeout: 265 seconds]
cd has joined #ruby
burgestrand has quit [Quit: burgestrand]
BSaboia has joined #ruby
akem has quit [Ping timeout: 264 seconds]
Rudd0 has joined #ruby
Technodrome has quit [Ping timeout: 265 seconds]
yxhuvud has joined #ruby
braincrash has quit [Ping timeout: 256 seconds]
mikecmpbll has quit [Ping timeout: 258 seconds]
mikecmpbll has joined #ruby
buckworst has joined #ruby
emdev has joined #ruby
emdev has quit [Max SendQ exceeded]
CactusJuan has joined #ruby
<CactusJuan>
hello! have a question about adding elements to an array. so i have a super basic script that reads from a txt file and adds each line to my array. when i puts my array out, each element has \n appended to it. how do i get rid of the \n?
<CactusJuan>
on 2.7.2 as well if that helps
orbyt_ has joined #ruby
<adam12>
CactusJuan: How are you loading the lines from the txt file?
<CactusJuan>
i am using File.readlines(file).each do .....
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dasher00 has joined #ruby
CactusJuan has quit [Ping timeout: 265 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
mikecmpbll has joined #ruby
cnsvc has joined #ruby
<isene>
Is there any way to pass a string with ansi color codes directly into a curses window and let the terminal color the string rather than having to go via the curses color functions?
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<isene>
Of course I can output the ansi color codes to the terminal directly - but, my File manager (RTFM) needs to output the syntax highlighted files (via `bat`) to a curses window... and that's where it stops for me - since curses does its own color handling and converts the colors to ansi codes and only THEN outputs it to a terminal. So - what I am looking for is to circumvent the curses color handling
TCZ has quit [Quit: Leaving]
<isene>
and output what comes from `bat` in raw form through the curses window... is there a way?
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
I guess you need whatever `bat` is using, not a subset.
TomyWork has quit [Quit: Leaving]
orbyt_ has joined #ruby
<isene>
Seems like whatever I output to a curses window is interpreted as characters to print, and not as escape codes. So, all the escape codes get printed into the window. Of course I can do all kinds of regex gymnastics and convert the codes to what curses parses (back into ANSI codes again) - but I was hoping to avoid that roundabout way
bocaneri has quit [Remote host closed the connection]
vondruch has quit [Ping timeout: 260 seconds]
chouhoulis has joined #ruby
braincrash has joined #ruby
TCZ has joined #ruby
rippa has joined #ruby
weaksauce has joined #ruby
braincrash has quit [Ping timeout: 260 seconds]
r29v has quit [Quit: r29v]
dionysus69 has joined #ruby
notnatebtw has joined #ruby
notnatebtw has left #ruby ["WeeChat 2.9"]
impermanence has quit [Ping timeout: 256 seconds]
imode has joined #ruby
davispuh has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
crankharder has quit [Ping timeout: 265 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duderonomy has joined #ruby
braincrash has joined #ruby
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
ap4y has joined #ruby
duderonomy has quit [Client Quit]
crankharder has joined #ruby
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
ur5us has joined #ruby
riceandbeans has joined #ruby
<riceandbeans>
How old of a Ruby can you install with rbenv?
<riceandbeans>
I need to test something on 1.8.5, not excited about it, but not sure how else to get a Ruby 1.8.5
<jhass>
Hum, I would imagine it depends on your OS to a good deal
<riceandbeans>
Will it work to just rbenv install 1.8.5, gem install 'foo', irb, require 'foo' ?
<jhass>
maybe install like CentOS 4 or 5 in a VM first?
<riceandbeans>
Good idea, I'm going to vagrant this crap lol
CactusJuan has joined #ruby
gambl0re has joined #ruby
buckworst has quit [Quit: WeeChat 2.9]
gambl0re has left #ruby ["WeeChat 2.8"]
cliluw has joined #ruby
CactusJuan has left #ruby [#ruby]
BTRE has quit [Remote host closed the connection]
BTRE has joined #ruby
BTRE has quit [Remote host closed the connection]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
BTRE has joined #ruby
nofxx_ has joined #ruby
nofxx has quit [Ping timeout: 256 seconds]
TCZ has quit [Quit: Leaving]
nofxx_ has quit [Ping timeout: 260 seconds]
<dionysus69>
what on earth is using 1.8.5 hmm
<jhass>
I don't know but I think it's a safe bet it's interfacing with cobol :D
crankharder has quit [Ping timeout: 258 seconds]
mikecmpbll has quit [Ping timeout: 260 seconds]
mikecmpbll has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
crankharder has joined #ruby
crankharder has quit [Ping timeout: 260 seconds]
ellcs has joined #ruby
<riceandbeans>
Ugh, I got a CentOS vm up in Vagrant but to get rubygems on it I had to fetch it and build it, and then I had to disable SSL to get it to work right, and then I had to install other crap
<riceandbeans>
And yet, still I can't get it to install this one gem.
TCZ has joined #ruby
<riceandbeans>
I think the gcc is too old on CentOS5
TCZ has quit [Remote host closed the connection]
<riceandbeans>
If you want to have something use did_you_mean with a Ruby earlier than 2.3, is it sufficient to just have the gem install and require it?
Jonopoly has quit [Ping timeout: 246 seconds]
orbyt_ has joined #ruby
crankharder has joined #ruby
TCZ has joined #ruby
crankharder has quit [Ping timeout: 260 seconds]
dasher00 has quit [Ping timeout: 260 seconds]
regedit has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
nofxx has joined #ruby
nofxx has quit [Remote host closed the connection]
bmurt has joined #ruby
crankharder has joined #ruby
<havenwood>
riceandbeans: You can use the gem for Ruby 2.1+.
<havenwood>
riceandbeans: Don't use Ruby that old. :P
<riceandbeans>
havenwood: I know, I know, but in the absence of that option, does it suffice to simply require the gem?
<riceandbeans>
I've never actually used it before
<havenwood>
riceandbeans: Yes, for Ruby 2.1 & 2.2 only and you might need to include a specific version so it doesn't refuse since your Ruby is too old.
<havenwood>
riceandbeans: I don't recall a version that old, but maybe it just predates my recollection. Ruby 1.8 to 1.9 had the biggest breaking changes we've ever seen in Ruby.
<riceandbeans>
I know, I was there lol
<havenwood>
riceandbeans: I hesitate to ask why Ruby 1.8 and did_you_mean are crossing paths.
<riceandbeans>
I wasn't using did_you_mean then though :P