<mooff>
sickdyd: where do you see "(Object doesn't support #inspect)"?
<mooff>
you'd get that when trying to print what an object looks like, for development inspection
victori has joined #ruby
<mooff>
regular expressions can work differently between engines. for example, some expressions supported by JS are not supported by Ruby, and vice versa
<mooff>
but you're running your expression on the database as a string. you might know already that your expression should work. e.g. from running it on the DB elsewhere
<mooff>
in years messing with Ruby, i've never seen that message you got
<leftylink>
and you think huh, maybe they're not so different after all
<leftylink>
taking a gander at Kernel makes me think
<mooff>
^^ right??
<mooff>
it makes me think more like it's a mathematical function
<leftylink>
after having used Ruby for over a decade, well I hope I know things like Enumerable, Array, Hash, String pretty well. but Kernel has a bunch of stuff I haven't studied yet. there is always more to learn, no matter how much I think I already know
<mooff>
literally reading the Ruby stdlib docs for Object, Kernel, Array, Hash, Enumerable, fully, was one of the best experiences i've had programming
<leftylink>
I wonder if there will ever be a day when I actually get to use callcc
<mooff>
they open up your mind and make Ruby fit like a glove
<leftylink>
or throw/catch
<leftylink>
it's a very humbling experience
<leftylink>
ah Kernel#test is fascinating. like shell scripting
<leftylink>
oh I am considering the potential uses of trace_var for refactoring a legacy script that uses a global. now you can see where the assignments are
<leftylink>
although huh, I guess you might be equally served by static analysis there
<leftylink>
including just searching the code for the string "$global ="
<leftylink>
but that's okay
ghostl has joined #ruby
<johnjaye>
leftylink: kernel? as in, interfacing to the linux kernel?
<leftylink>
not the Linux kernel, but the Ruby kernel
<johnjaye>
i see
c10l has joined #ruby
<leftylink>
I wonder if any other programming language also calls their equivalent of Kernel kernel
<leftylink>
a search engine search for "kernel in programming language" isn't too helpful
<leftylink>
it gets results like telling what programming languages have been used to write OS kernels, or the programming language named Kernel, or other similar items
<leftylink>
I wondered if it should be considered equivalent to other languages' Preludes, but I'm not sure... in fact, in Ruby there exists a prelude as well in https://github.com/ruby/ruby/blob/master/prelude.rb, so it implies kernel is not the same as prelude
<johnjaye>
using terms incorrectly is actually a plus in my book
<johnjaye>
makes it easier to gatekeep the outsiders from coming in and ruining it
<johnjaye>
oh you want the kernel? ok. *points to prelude*
<leftylink>
I just like to understand where it fits in the grand scheme of things
<leftylink>
like if one were to describe it in language-agnostic terms, what would one do
<leftylink>
that helps transfer skills from one programing language to another
<leftylink>
or can help one understand one language in terms of concepts they already know from a different language
snoojin has joined #ruby
<mooff>
it's just a particular bag to put general "global methods" in, so that Object can stay focused
<mooff>
people see Kernel like the "global namespace", but i think it shouldn't be seen like that
dviola has quit [Changing host]
dviola has joined #ruby
<mooff>
it's a place that the interpreter puts utility functions for the language for you to have, and meanwhile, Object is the real top dog when it comes to what is "global"
<mooff>
(Kernel just happens to be included in Object by default :-P)
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
teclator has quit [Ping timeout: 246 seconds]
<isene>
I've been searching for this answer for a while to no avail; so I'm resorting to asking here. I need to run system(cmd) to let the terminal print the raw output from that cmd (as backticks or %x|cmd| both strips ansi color codes). But - I also need to capture that output to manipulate it later. So - how to capture/get to the stdout produced by that system(cmd)?
roadie has joined #ruby
roadie has quit [Ping timeout: 248 seconds]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 240 seconds]
desnudopenguino1 is now known as desnudopenguino
roshanavand has quit [Ping timeout: 246 seconds]
<weaksauce>
isene you can get that via pty
<weaksauce>
you might be able to get that via some environment variable passing to io.popen or open3.capture
infinityfye has quit [Quit: Leaving]
<weaksauce>
but i'm not sure the right incantation for that
roadie has joined #ruby
<weaksauce>
require 'pty'; PTY.spawn("ls -FG") do |stdout,stdout,stderr| puts stdout.read end
roadie has quit [Ping timeout: 248 seconds]
<isene>
Interesting - but I get: require 'pty'; PTY.spawn("ls -FG") do |stdout,stderr| puts stdout.read end => Input/output error @ io_fread - /dev/pts/15 (Errno::EIO)
<weaksauce>
if you're on linux it might be something else?
<isene>
mooff: Can't do since I need the raw output to the terminal (without stripping ansi color codes, etc.)
<mooff>
right, i see
<mooff>
so if you had ansi colors in the output of a backticks `command`, then when you print() or puts() it, it should work faithfully in the terminal that's running your Ruby program
<mooff>
but it'll be down to whether the command runs with a tty, or not
roshanavand has joined #ruby
<mooff>
^ whether you get colors in the output of most programs by default, for instance
<weaksauce>
mooff i think backticks uses a mode that will never get color info
<weaksauce>
port = pipe_open_s(str, "r", FMODE_READABLE|DEFAULT_TEXTMODE, NULL);
<weaksauce>
default_textmode seems like it would strip
<mooff>
weaksauce: unless the implementation strips ANSI escape codes explicitly, i still believe it's up to the program whether or not it includes them
<weaksauce>
sure
<weaksauce>
but most programs will autostrip on a terminal that doesn't call for it
<isene>
In the shell I am writing, I am doing system(cmd) - but in the case of fzf integration, I need the output of fzf to let the shell cd to the dir of the selected match
<weaksauce>
gotcha
roshanavand has quit [Read error: Connection reset by peer]
<mooff>
basically with POSIX, you can run a program where its stdin is a "terminal", aka a "tty", or not
<mooff>
that's designed for interactive use with a terminal emulator, vs automated use
<mooff>
you could ask ChatGPT to write a def `(cmd) function that returns the content of stdout after running the cmd with a tty
<weaksauce>
isene try the pty again but change the command to something else
<weaksauce>
ls --color=always
<isene>
So, is there a system variable the stores the latest resulting stdout from system() that I can access?
<mooff>
it will likely use Open3 from the stdlib to do it
<weaksauce>
you probably got that error because that switch was broken in linux
<isene>
weaksauce: Can't get the PTY thingy to work... same error
<weaksauce>
and thus the stdout never gets opened
<weaksauce>
try just ls
<isene>
require 'pty'; PTY.spawn("ls") do |stdout, _stdin, _pid| output = stdout.read end => Input/output error @ io_fread - /dev/pts/16 (Errno::EIO)
<weaksauce>
curious
<isene>
mooff: Tried various Open3 solutions, but it all strips the ansi color codes...
<mooff>
ChatGPT reaches for PTY
<mooff>
try calling ls with --color=always to test
<isene>
The only way I can get the ansi codes passed to the terminal is with system()
<isene>
mooff: Tried Open3 with ls --color=always
<isene>
(as that is my alias for ls in any case)
<weaksauce>
you know what you can use spawn
<weaksauce>
which i believe is basically a more optionpacked system*()
roadie has joined #ruby
lena64t2 has quit [Quit: WeeChat 4.0.0-dev]
<isene>
Yes, will explore more tomorrow. Thanks guys. Nite
FullMetalStacker has joined #ruby
<FullMetalStacker>
Is there a page builder for ruby/rails? I.e. a drag & drop frontend-editing interface to a CMS, like Elementor for Wordpress. The big CMS solutions for Ruby that I know (Refinery CMS, Comfortable Mexican Sofa, Spina, Alchemy) seem all to be traditional (=outdated) backend editors ony. (X-post, f'up in #ruby)
<joto>
Has anyone got experience with multiple databases in rails? I added them correctly under database.yml. Following various tutorials I should be able to do db:create:animals (animals being my secondary database here) however rake -T does not show this task.
<joto>
also rails generate migration CreateDogs name:string --database animals has no effect. It just places the migration under db/migrate instead of db/animals_migrate where it is supposed to land.
<joto>
I'm on the latest rails 7.0.4.3. all these tutorials seem to be written for 6 and 7 though
<FullMetalStacker>
@weaksauce found some javascript ones but no idea how to connect that to rails. but now found this: https://www.maglev.dev/
<FullMetalStacker>
Thanks for leading me to this! It might not be related to nmp, but nevertheless the search prompt (javascript pagebuilders for rails) based on your idea brougth maglev up :-)
<FullMetalStacker>
"Maglev is the only page builder for RoR application." BINGO :)
<weaksauce>
hah nice
<weaksauce>
yeah chatgpt has some usefulness
<FullMetalStacker>
sure, but in this case it was good ol' goolge