crespire has quit [Remote host closed the connection]
crespire has joined #ruby
BazzaBazaa has joined #ruby
gcd has quit [Ping timeout: 265 seconds]
gcd has joined #ruby
<isene>
I am trying to avoid any external dependencies beyond pure Ruby (like writing an extension in Fortran or some such)
<isene>
I have a working Ruby shell now with tab completions, syntax highlighting and more. Trying here to speed up the highlighting - this is the reason for the question
<isene>
leah2: Is using scan with a block faster? If yes, why?
tjnhxmzhmqgytuwt has quit [Remote host closed the connection]
ur5us has joined #ruby
BazzaBazaa has quit [Remote host closed the connection]
BazzaBazaa has joined #ruby
Furai has quit [Quit: WeeChat 3.8]
Furai has joined #ruby
cek has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
shokohsc2 has joined #ruby
shokohsc has quit [Ping timeout: 240 seconds]
shokohsc2 is now known as shokohsc
<leah2>
doesnt allocate an array?
<leah2>
and only one string at a time
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 240 seconds]
desnudopenguino1 is now known as desnudopenguino
desnudopenguino has quit [Quit: desnudopenguino]
moldorcoder7 has joined #ruby
moldorcoder7 has quit [Ping timeout: 265 seconds]
<isene>
leah2: Example code?
Dooky has joined #ruby
<leah2>
"foo bar baz".scan(/\S+|\s+/) { p $& }
<leah2>
you can use { |x| p x }
<ox1eef_>
Check out strscan / StringScanner too
<leah2>
same cost
<leah2>
yeah
Terminus has joined #ruby
<Terminus>
hello. if i already have something installed in /usr/local/bundle/bundler/gems/ using :git, is there a way to prevent `bundle lock` from attempting to fetch with git and just use what's already there?
donofrio has joined #ruby
<ox1eef_>
--local, --prefer-local, and --deployment options to 'bundle install' may help.
cek has quit [Quit: Connection closed for inactivity]
<Terminus>
ox1eef_: i've tried --local and it just says it's not yet checked out. no Gemfile.lock generated.
<Terminus>
ox1eef_: oh i see what you mean! use it with `bundle install`. thanks!
dalan0382 has quit [Quit: dalan0382]
dalan0382 has joined #ruby
crespire1 has joined #ruby
crespire has quit [Killed (NickServ (GHOST command used by crespire1!~crespire@user/crespire))]
cherryramatis has joined #ruby
cherryramatis has quit [Client Quit]
cherryramatis has joined #ruby
<Terminus>
--local didn't work but --prefer-local did it.
<Terminus>
ox1eef_: whoops. i think i must have been a bit too excited. `bundle lock` still tries to use git even if the repo was previously installed with either `--local` or `--prefer-local`.
cherryramatis has quit [Quit: WeeChat 3.8]
<ox1eef_>
Terminus: Have a read through the 'bundle install -h' man page.
cherryramatis has joined #ruby
<ox1eef_>
It might be a limitation or oversight. The man page says do not contact rubygems.org but not neccessarily git.
<Terminus>
ox1eef_: yeah, i see it. thanks. i think i'll leave this alone for now. not that important anyway considering i'm not generating a Gemfile.lock every second.
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
<ox1eef_>
A nice feature of npm is git installs.
<ox1eef_>
npm i git+foobar.com/foo/bar.git#v0.1.0
<ox1eef_>
I wish Ruby had the same.
<Terminus>
i'm just a casual ruby user so i'm not familiar with pitfalls.
<Terminus>
but yeah, i get why somebody who writes ruby a lot would want that feature.
<leah2>
bundler does that no
<BazzaBazaa>
was going to say the same about bundler
sickdyd has quit [Ping timeout: 240 seconds]
<Terminus>
oh wait, now that that's mentioned, that's exactly what i'm doing with `gem "foo", git: "http://foo.com/bar/baz", tag: "v1.0"`
<Terminus>
i should sleep if i don't even really understand what people are saying anymore.
roadie has joined #ruby
<BazzaBazaa>
I never understand what anyone says
otisolsen70 has quit [Quit: Leaving]
<ox1eef_>
leah2: it has a degree of support, yeah - but I don't think as solid as NPM.
<leah2>
i guess performance is dominated by system and file.exists :p
<leah2>
you could consider gsub
dza has quit [Quit: Ping timeout (120 seconds)]
dza has joined #ruby
<isene>
leah2: I've seen gsub being slow, but I'll check
swaggboi has quit [Quit: C-x C-c]
<leah2>
it doesnt need a call for the \s case tho
sickdyd has joined #ruby
<isene>
leah2: If I don't match on \s, then double-spaces get lost on the join
<leah2>
you dont need a join with gsub either
sickdyd has quit [Ping timeout: 240 seconds]
<isene>
leah2: Simplified it (check gist url again)
<isene>
I'm not sure how I would go about gsub'ing all this, though
<leah2>
str.gsub(/\S+/) { |el| ... }
cherryramatis has quit [Quit: WeeChat 3.8]
cherryramatis has joined #ruby
BazzaBazaa has quit [Remote host closed the connection]
cherryramatis has quit [Ping timeout: 264 seconds]
sickdyd has joined #ruby
sickdyd has quit [Ping timeout: 256 seconds]
cherryramatis has joined #ruby
swaggboi has joined #ruby
cherryramatis has quit [Ping timeout: 240 seconds]
blackmetal has joined #ruby
<isene>
leah2: Now that is indeed the fastest so far - check gist url
<isene>
Thanks a plenty. Release of Ruby SHell (rsh) coming soon.
<leah2>
next, make sure @nick and @gnick are Set or Hash
<leah2>
and probably cache a list of binaries instead of calling which
<blackmetal>
rsh?!
<blackmetal>
daaaaaaaaaaaaaamn
<blackmetal>
that would be neat as openbsd's new default shell
<blackmetal>
(since im banking on openbsd.org soon running ruby)
<blackmetal>
what great times we live in
gr33n7007h has quit [Ping timeout: 246 seconds]
moldorcoder7 has joined #ruby
_ht has joined #ruby
sickdyd has joined #ruby
cherryramatis has joined #ruby
Al2O3 has quit [Remote host closed the connection]
catphish has quit [Read error: Connection reset by peer]
catphish has joined #ruby
sickdyd has quit [Ping timeout: 240 seconds]
cherryramatis has quit [Ping timeout: 240 seconds]
<isene>
leah2: @nick and @gnick are hashes. I'm not sure about the caching of binaries, though as it may impact startup time and also the fact of having to rehash manually or having a timer do that
<havenwood>
isene: It's much faster to check in Ruby if a command is in the PATH, FWIW. It's a bit faster to pipe from Ruby rather than >/dev/null as well.
<havenwood>
system 'which ruby', %i[out err] => File::NULL
<havenwood>
But an order of magnitude faster to not shell out, it looks like.
<isene>
havenwood: The shell-out is actually faster, it seems
mexen has joined #ruby
<isene>
But with your tip on piping from Ruby makes the fastest solution yet. Cool.
cherryramatis has joined #ruby
desnudopenguino has joined #ruby
cherryramatis has quit [Ping timeout: 246 seconds]
<isene>
leah2: Yeah, but if there is a change in the executables while a shell is in action, it wouldn't catch that. I want rsh to be fully trustworthy
cherryramatis has joined #ruby
gr33n7007h has joined #ruby
oboist55 has joined #ruby
srushe has quit [Remote host closed the connection]
g_sg has quit [Remote host closed the connection]
slondr has quit [Remote host closed the connection]
whereiseveryone has quit [Remote host closed the connection]
sgtapple has quit [Read error: Connection reset by peer]
caleb has quit [Remote host closed the connection]
matta has quit [Write error: Connection reset by peer]
alexisg has quit [Remote host closed the connection]
KOTP has quit [Remote host closed the connection]
Bounga has quit [Remote host closed the connection]
pjaspers has quit [Remote host closed the connection]
graemefawcett has quit [Remote host closed the connection]
tsujp has quit [Remote host closed the connection]
graemefawcett has joined #ruby
whereiseveryone has joined #ruby
caleb has joined #ruby
slondr has joined #ruby
matta has joined #ruby
pjaspers has joined #ruby
alexisg has joined #ruby
tsujp has joined #ruby
sgtapple has joined #ruby
Bounga has joined #ruby
hwrd_ has joined #ruby
g_sg has joined #ruby
sickdyd has joined #ruby
KOTP has joined #ruby
srushe has joined #ruby
sickdyd has quit [Ping timeout: 264 seconds]
hwrd_ has quit [Ping timeout: 250 seconds]
mexen has quit []
<johnjaye>
ok. am i taking crazy pills or does ruby have unique semantics around recursion?
desnudopenguino has quit [Ping timeout: 256 seconds]
desnudopenguino1 is now known as desnudopenguino
<havenwood>
johnjaye: you inverted the order in your if statement with the same condition in both.
<havenwood>
They're not the same.
<johnjaye>
ok. so i am taking crazy pills. that's a relief.
<havenwood>
johnjaye: Did you mean to have `if n >= 2` in one of them maybe?
<johnjaye>
i thought there was something wrong with ruby.
<havenwood>
Or just keep the same order.
<havenwood>
Nope, Ruby is fine in this case!
<johnjaye>
i was a bit miffed i couldn't just do puts number+string though
<johnjaye>
i guess it tries to coerce the string to a number
<havenwood>
johnjaye: sounds like you wanted weakly typed there, but Ruby is strongly typed.
<johnjaye>
what does that mean in context
<johnjaye>
you can't have strong typing and convert the number to a string?
<havenwood>
johnjaye: you can have a method that accepts many classes, but you can't just swap one class in for another implicitly. Ruby is like Python and most other modern dynamic languages in that regard, unlike PHP.
<havenwood>
Unlike JavaScript.
<havenwood>
For example, TypeScript is strongly typed and JavaScript is weakly typed.
<havenwood>
johnjaye: A `puts` automatically appends a `"\n"` and takes anything that implements #to_s.
<havenwood>
justache: Just: puts n
<havenwood>
Or if you want things other than a newline, interoplate in a String literal like: puts "Number: #{n}"
<johnjaye>
ah ok. is ruby the only langauge that does that
<johnjaye>
i cant' recall if python or perl does
<ox1eef_>
puts comes from C.
<ox1eef_>
There's also print - that omits a newline unless explicitly given, same for printf.
<johnjaye>
ok
<ox1eef_>
Another useful string function is 'format'.
<blackmetal>
ox1eef_: wern't we gonna do all sorts of chat bots and AI video generators? u left me hanging had to do it all myself :/
Linux_Kerio has joined #ruby
brw has joined #ruby
<isene>
Could anyone here offer advice on how to amend my code in rsh to accept pasting onto the command line. Issue is of course that I wrote the readline parser from scratch and it parses character-by-character, effectively killing any pasting of many characters at a time. Tried to fix it, but remains a tad stuck here...
blackmetal has quit [Quit: Lost terminal]
<weaksauc_>
buffer it?
_ht has quit [Remote host closed the connection]
<ox1eef_>
Check what IRB / Pry do to handle that.
<weaksauc_>
even they don't really handle it all that well
<ox1eef_>
Pry handles it poorly because it interpets a string prefixed with a dot as a system command, so copy & paste will run Ruby code on your shell.
<ox1eef_>
If you remove that feature, it usually works for me.
<ox1eef_>
Another thing I remember is that Pry has an input array, and every line of input is kept there afaik.
<weaksauc_>
isene what's the goal here? to be a ruby shell ala pry or to be a shell written in ruby ala something closer to zsh?
Cork has quit [Ping timeout: 240 seconds]
reset has joined #ruby
cherryramatis has quit [Read error: Connection reset by peer]
cherryramatis has joined #ruby
<johnjaye>
why does pry exist? what does it do differently to irb
cherryramatis has quit [Read error: Connection reset by peer]
goldfish has quit [Remote host closed the connection]
goldfish has joined #ruby
<llua>
someone wanted to make it
cherryramatis has quit [Read error: Connection reset by peer]
sickdyd has joined #ruby
cherryramatis has joined #ruby
<havenwood>
johnjaye: Pry was created back when IRB lacked comparable features. IRB copied Pry features to become a viable alternative.
<weaksauc_>
isn't there pry debugging? does irb have that?
tomtmym has quit [Quit: Gone.]
<havenwood>
weaksauc_: Debug now ships with Ruby, so you can `binding.irb` and type `debug` to enter rdbg.
<weaksauc_>
ah nice
sickdyd has quit [Ping timeout: 240 seconds]
<isene>
weaksauc_: I want to replace my zsh. Having tweaked zsh for more than 20 years, it's become quite complex with lots of antibody extensions etc. The dependencies are itchy. I want a shell that is one single executable file with no dependencies. That makes for easier setup or migration to new machines. And with Ruby right there on the command line.
<havenwood>
weaksauc_: Pry doesn't ship with a debugger, but byebug is popular.
<isene>
So how would I buffer the STDIN?
<havenwood>
You might take a look at Xiki from a little over a decade ago for inspiration if you're making a Ruby shell.
<havenwood>
isene: Primordial Pry is: loop { eval $stdin.readline }
cherryramatis has quit [Read error: Connection reset by peer]
cherryramatis has joined #ruby
<weaksauc_>
isene pretty neat project
<rapha>
oh cool
<isene>
I tried readline. And tty-prompt etc. But for the syntax highlighting, I needed full control of the input and opted to write the readline parser from scratch, with code taken from my rtfm-filemanager project. But unlike rtfm, I now need to accept pastes...
cherryramatis has quit [Ping timeout: 248 seconds]
cherryramatis has joined #ruby
teclator has quit [Ping timeout: 248 seconds]
Cork has joined #ruby
Cork has quit [Ping timeout: 240 seconds]
donofrio_ has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
donofrio_ has joined #ruby
donofrio_ has quit [Remote host closed the connection]
roadie has quit [Remote host closed the connection]
cherryramatis has quit [Read error: Connection reset by peer]
cherryramatis has joined #ruby
ur5us has joined #ruby
goldfish has quit [Remote host closed the connection]
goldfish has joined #ruby
goldfish has quit [Remote host closed the connection]
roadie has joined #ruby
donofrio has quit [Ping timeout: 268 seconds]
Guest82 has joined #ruby
Guest82 has quit [Client Quit]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
shokohsc0 has joined #ruby
shokohsc has quit [Ping timeout: 240 seconds]
shokohsc0 is now known as shokohsc
sickdyd has joined #ruby
sickdyd has quit [Ping timeout: 240 seconds]
<isene>
How do I check the length of the content of STDIN?
sickdyd has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
goldfish has joined #ruby
goldfish has quit [Remote host closed the connection]
goldfish has joined #ruby
goldfish has quit [Remote host closed the connection]