tpanarch1st has quit [Quit: Thanks for your help, nice to see you, take care.]
m27frogy has joined #ruby
hays has joined #ruby
wildtrees has quit [Quit: Leaving]
hays has quit [Ping timeout: 240 seconds]
simonfromspace has joined #ruby
<simonfromspace>
Hey guys!
<simonfromspace>
Looking for a bit of help with Nokogiri
<simonfromspace>
Is there a way to trigger events on the web page, to access content that doesn't load until an user does something?
<ewanchic>
simonfromspace: I would just use jQuery to trigger an event, and then AJAX to call back to the Rails server
<simonfromspace>
I'm not using Rails. I'm making a scraper and it's gotta be built entirely in plain Ruby.
<apotheon>
simonfromspace: Deferred client-side loading is a JavaScript thing.
ropeney has joined #ruby
<apotheon>
simonfromspace: . . . unless you're not talking about the browser as a client.
<apotheon>
simonfromspace: If you're writing the client (for the desktop or command line or something like that) yourself, that's a different story.
<simonfromspace>
It's just CLI
regedit has joined #ruby
<apotheon>
How does "web page" fit into this, then?
<simonfromspace>
I'll use 'httparty' to access the page and use 'nokogiri' to capture bits of data I want from that page. So far, It's been quite easy with pages that simply load more data on a different url
<ewanchic>
HMM, sounds like your making a robot :D
<simonfromspace>
But there's this webpage that loads more data using JS. And the url is just exampledoturl/#
hays has joined #ruby
<adam12>
simonfromspace: You're likely looking for something that can drive a web browser like Capybara + cuprite.
<adam12>
simonfromspace: From there, if you absolutely have to, you can probably pull the finished DOM from Capyara and send it to Nokogiri.
<simonfromspace>
adam12 That sounds like what I'm looking for.
<simonfromspace>
ewanchic I was hoping my Ruby capstone would be a bot, but I got a scraper.
<ewanchic>
simonfromspace: Yeah, you're gonna have to do what adam12 suggested. You basically need a 'middleman' to robot your content as a browser, and then respond to it. Another idea (more static in a way) is to hack it yourself and discover what those URLs might be. but adam12's way can be more dynamic.
<adam12>
Be cool if Mechanize could drive Chrome.
<adam12>
Since Capybara really is for "Acceptance" tests...
<simonfromspace>
I'll explore the tools you've provided. BRB :) <3
hays has quit [Ping timeout: 265 seconds]
<apotheon>
It would be nice if more webdevs still knew what "noscript" tags do, and how to use them, so this stuff would be easier and lower-resource.
<apotheon>
. . . and if web frameworks were designed with the possibility of some people not having JavaScript turned on.
hays has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hays has quit [Ping timeout: 240 seconds]
TCZ has joined #ruby
hays has joined #ruby
hays has quit [Ping timeout: 260 seconds]
cow[moo] has joined #ruby
ur5us has joined #ruby
ur5us has quit [Remote host closed the connection]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
SCHAPiE has joined #ruby
dviola has joined #ruby
markopasha has quit [Quit: Leaving]
<KrzaQ>
Is there a function to escape paths in Ruby standard library?
markopasha has joined #ruby
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fphilipe has joined #ruby
fphilipe has quit [Ping timeout: 245 seconds]
kristian_on_linu has quit [Remote host closed the connection]
troulouliou_dev has quit [Quit: Leaving]
markopasha has quit [Remote host closed the connection]
ur5us has joined #ruby
jenrzzz has joined #ruby
knueppelspass has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 265 seconds]
<simonfromspace>
adam12 ewanchic Thanks for the help. Found some great resources that suggest I can scrape sites using Capybara, and some gems on the side.
<simonfromspace>
Had another question. Does anyone know a cool gem to build cool UIs on the command line? Primarily to make lists from which I can choose an option.
<ewanchic>
KrzaQ: Are you able to type in the language you want? Typically Ruby justs accepts the chars as unicode. Are you using windows?
<simonfromspace>
KrzaQ that appsignal blog ewan posted helped me a lot too. I would recommend that too.
<KrzaQ>
ewanchic: I'm mass-converting my flac collection to mp3, so I need to pass paths to ffmpeg. Can't type most of them with special chars. I think I did get it to work, though
<KrzaQ>
Darn phone space
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
<ewanchic>
ruby should have no problem reading the files as is, and pasting them out in unicode. I have similar songs ;)
<KrzaQ>
Ruby doesn't, but I had to pass the paths to system/spawn
<KrzaQ>
anyway, problem solved, and I learned of Shellwords :)
howdoi has joined #ruby
<simonfromspace>
Reposting for visibility. Does anyone know a gem to build cool UIs on the command line? Primarily to make lists from which I can choose an option.
<simonfromspace>
To be more specific.What's the best way to make menus?
<ewanchic>
simonfromspace: Uls?
<ewanchic>
oh, User Interfaces
<simonfromspace>
Yes sir!
<ewanchic>
I was using Foundation for a long time. I'm having issues trying to get this to work in Rails 6. So I'm thinking of giving bootstrap a try. But techniquly I'd use the jQuery UI. ...hold on...
<simonfromspace>
.....
<simonfromspace>
in the command line
<ewanchic>
LOL, I cannot pull up my project, hold on...
<simonfromspace>
sure :) good luck with that
<ewanchic>
oh, in the command line?
<ewanchic>
cmdline menu?
<simonfromspace>
Yeah, so when the program runs, I want to give the user options to select from when they run a search query or whatever.
kristian_on_linu has quit [Remote host closed the connection]
<ewanchic>
simonfromspace: That's very cool. Sorry I don't know of any.
ur5us has joined #ruby
ur5us has quit [Client Quit]
<simonfromspace>
https://ttytoolkit.org/ ewanchic Look what I found. An entire suite of tools to make beautiful CLI apps, everything from loaders, to spinners, charts, menus, whatever. That is amazing.
Swyper has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
<ewanchic>
simonfromspace: WOW, that really is cool! Thanks for the info! Bookmarked
kristian_on_linu has joined #ruby
fphilipe has joined #ruby
fphilipe has quit [Ping timeout: 246 seconds]
hays has quit [Ping timeout: 268 seconds]
pama has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gavlee has quit []
<ewanchic>
So, I have a compiled gem, and I'm trying to load a file from my opts. the problem is that myfile or ./myfile is not giving me the path from my current directory. Instead it's coming from /home/ewanchic/.rvm/rubies/ruby-2.5.5/lib/ruby/gems/2.5.0/gems/freight-0.10.0/lib/freight/myfile
tau has joined #ruby
<ewanchic>
How do I get it from my current, executing directory. Using CLI Thor commands.
goepsilongo has quit [Quit: Konversation terminated!]
braincrash has quit [Quit: bye bye]
Leopere has joined #ruby
braincrash has joined #ruby
kristian_on_linu has quit [Remote host closed the connection]
jenrzzz has joined #ruby
snuz has quit [Read error: Connection reset by peer]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
ratah has joined #ruby
alfiemax has quit [Remote host closed the connection]
al2o3-cr has quit [Quit: WeeChat 2.7]
al2o3-cr has joined #ruby
nofxx has quit [Quit: Leaving]
nofxx has joined #ruby
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
_phaul has joined #ruby
alfiemax has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
royal_screwup21 has joined #ruby
<ratah>
Spring, Bootsnap and Turbolinks. Is it just me or should these be disabled by default?
<ratah>
Also, is Rails in the future likely to come bundled with its own auth solution?
alfiemax has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
simonfromspace has joined #ruby
DaRock has quit [Ping timeout: 260 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
postmodern has quit [Quit: Leaving]
royal_screwup21 has quit [Remote host closed the connection]
GodFather has joined #ruby
ellcs1 has quit [Ping timeout: 240 seconds]
Rudd0 has quit [Read error: Connection reset by peer]
Rudd0 has joined #ruby
cow[moo] has joined #ruby
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
regedit has quit [Quit: Connection closed for inactivity]
TCZ has joined #ruby
alfiemax has joined #ruby
TCZ has quit [Client Quit]
alfiemax has quit [Ping timeout: 268 seconds]
siery has joined #ruby
MrCrackPot has quit [Quit: Leaving]
<siery>
Hey, I try to overwrite require statement to help me generate a tree of connections between files, so I thought this will do the job:
<siery>
def require arg
<siery>
super arg
<siery>
p "including #{arg} in #{__FILE__}"
<siery>
end
<siery>
But the __FILE__ is only a constant, yes I know.. can you help me to figure out how to check the current runing file dinamiclly?
schne1der has quit [Ping timeout: 265 seconds]
TCZ has joined #ruby
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
alfiemax has joined #ruby
s3nd1v0g1us has joined #ruby
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
Mrbuck has joined #ruby
<adam12>
siery: Maybe you can get it through `caller_locations`
alfiemax has quit [Remote host closed the connection]
greengriminal has joined #ruby
<siery>
adam12: That's what I'm reading about now c:
v1sage has joined #ruby
markopasha has quit [Remote host closed the connection]
lxsameer has quit [Ping timeout: 240 seconds]
<siery>
Wanderful c:, all I needet to do was to replace the __FILE__ constant with a Kernel module `caller_locations(1).first.path`
sagax has quit [Remote host closed the connection]
<siery>
I meant to say method not a module*
Moeh has joined #ruby
<havenwood>
ratah: Rails isn't a disabled by default framework. It comes with all the bells and whistles.
alfiemax has joined #ruby
<havenwood>
ratah: Spring is only in development. Turbolinks is fancy. Both have bitten me in development but it's just Rails style to enabled by default whatever Basecamp is using. :)
<havenwood>
ratah: We should add the compiled IR and load path improvements from Bootsnap into Ruby itself, like Elixir does.
Xiti` has quit [Quit: Xiti`]
<havenwood>
siery: How about?: method(__callee__).source_location.first
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cow[moo] has joined #ruby
s3nd1v0g1us has quit [Ping timeout: 260 seconds]
s3nd1v0g1us has joined #ruby
lxsameer has joined #ruby
m_antis[away] is now known as m_antis
m_antis is now known as m_antis[away]
alfiemax has quit [Remote host closed the connection]
dviola has joined #ruby
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sergioro has joined #ruby
cow[moo] has joined #ruby
Emmanuel_Chanel has quit [Quit: Leaving]
<ratah>
havenwood: For sure! Spring forks tons of background processes that tend to live their own life. Most of the time I have to manually kill them so Rails will run normally again.
<havenwood>
ratah: spring stop
ewanchic has joined #ruby
<havenwood>
ratah: I like a super fast computer so I can disable Spring. Heh.
<ratah>
:)
rippa has joined #ruby
<havenwood>
ratah: At least it's easy enough to: export DISABLE_SPRING=1
<havenwood>
ratah: Bootsnap gives me trouble less often. A `rails tmp:cache:clear` does the trick when it hiccups.
<havenwood>
I would like yomikomu style caching of IR when gems are installed. Bootsnap has that right.
<havenwood>
Especially now that the bytecode is smaller in 2.7 and faster in 3.0.
<havenwood>
ratah: Intermediary Representation (IR)—so in CRuby's case, currently an AST.
* ratah
ponders whether to rebase back to the initial commit and rerun "rails new" with "--disable-spring" and "--disable-bootsnap". Already got "--disable-turbolinks" so...
<havenwood>
ratah: I'd leave Bootsnap enabled.
<ratah>
Will do. Never had a problem with that except for the tmp cache as you mentioned, whenever I wanna tar up a backup.
<havenwood>
ratah: Turbolinks is a very nice magic, but I could see disabling it until you're ready to add it and solve the related bugs all at once.
<rubydoc>
# => [1, :RUBY_EVENT_LINE, [:putobject_INT2FIX_1_], [:putobject_INT2FIX_1_], [:opt_plus, {:mid=>:+, :flag=>16,... check link for more (https://carc.in/#/r/8kkq)
sagax has joined #ruby
<havenwood>
ratah: You can then evaluate the IR: RubyVM::InstructionSequence.load_from_binary(binary_here).eval
<havenwood>
ratah: About a third of a Ruby program's runtime can be in parsing the grammar to create that IR binary.
<havenwood>
ratah: So that's just time saved the next time you run it.
<havenwood>
ratah: Elixir does it out of the box, for every script. It just compiles the IR and uses it next time the script is run if unchanged. Ruby can do the same, but currently doesn't.
phaul has joined #ruby
<havenwood>
Now that CRuby can create and run the IR binary easily, it's low hanging fruit to wire it up.
<ratah>
havenwood: Cool. What's stopping Ruby from doing it though?
<havenwood>
Someone doing it. :)
<ratah>
hehe
<havenwood>
ratah: The author of the VM has exposed the tooling needed in Ruby even.
<havenwood>
k01
<havenwood>
ko1
TCZ has quit [Quit: Bye Bye]
<havenwood>
ratah: I took a stab at compiling every gem on my system. It raised a few interesting errors, but mostly worked.
<havenwood>
I think the lowest hanging win would be to compile gems to IR binary on install and then hook #require, #require_relative, etc.
<havenwood>
Then again, maybe worth integrating into `ruby`, `irb`, `gem`, everything. That's just harder to figure out.
<havenwood>
It's certainly possible.
<havenwood>
I guess Bootsnap was the lowest hanging fruit. Integrate it into `rails` but not `gem` or `ruby`.
_phaul has quit [Ping timeout: 265 seconds]
<havenwood>
It would be nice to do something along those lines this year for Ruby 3.
citizentwo has quit [Remote host closed the connection]
<ratah>
Ouch :D
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ratah>
Ruby for shell scripting sure ain't pretty :)
<havenwood>
The yomikomu gem is basically an exploratory spike on different ways to store the IR binary.
<havenwood>
Hooking it into RubyGems is a challenge.
<ytti>
ratah, unsure what is shell scripting in this context, considering it's not shell
<ytti>
ratah, but perhaps you meant like 'ruby for file system manipulation isn't pretty' or some such
<ytti>
in which case, i suppose matter of taste, but writing same in bash, imho, would be much worse
fphilipe_ has joined #ruby
<ytti>
anything but simple wrapper in sh, imho, is antipattern
<ratah>
havenwood: Interesting stuff man
m_antis[away] is now known as m_antis
<ytti>
like if you need functions, you probably should already switch up from shell
m_antis is now known as m_antis[away]
<ytti>
it would be cool, if linux could have shell revolution like microsoft did with powershell, but it's hard to figure we can ever move forward from sh
<ratah>
ytti: Yep, that's what I meant pretty much. Looked into redoing my Zsh scripts in Ruby a while back, luckily I gave up the idea before it became too late :)
<ratah>
llua is a Zsh developer, he knows what I'm talking about :)
Emmanuel_Chanel has joined #ruby
fphilipe has quit [Ping timeout: 246 seconds]
<ewanchic>
Sorry to interrupt (off topic). In my compiled gem, using it as a executable with thor i pass it an option of a yaml file. when I pass it --opt=file.yaml or --opt=./file.yaml, it grabs the path of the gem location: /home/ewanchic/.rvm/rubies/ruby-2.5.5/lib/ruby/gems/2.5.0/gems/freight-0.10.0/lib/freight/file.yml instead of the current location I'm executing the file from. How can I grab my current location?
<ewanchic>
...my executing location path?
<ewanchic>
File.expand_path( yaml_filepath, __dir__ ) is what I'm using
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
nowhere_man has quit [Ping timeout: 272 seconds]
<siery>
havenwood: How is that better then using `caller_locations`?
simonfromspace has left #ruby [#ruby]
hiroaki has quit [Ping timeout: 268 seconds]
Xiti has joined #ruby
dinfuehr_ has quit [Ping timeout: 268 seconds]
dinfuehr has joined #ruby
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
dviola has quit [Quit: WeeChat 2.7]
Xiti has quit [Quit: Xiti]
Xiti has joined #ruby
code_zombie has joined #ruby
cow[moo] has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
raven__ has joined #ruby
royal_screwup21 has joined #ruby
darkstardev13 has quit [Ping timeout: 265 seconds]
cow[moo] has quit [Ping timeout: 268 seconds]
hays has joined #ruby
ellcs1 has joined #ruby
rapha has left #ruby ["WeeChat 2.3"]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
xco has joined #ruby
jenrzzz has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 240 seconds]
Moeh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has joined #ruby
Mia has quit [Read error: Connection reset by peer]