What’s the purpose of Nokogiri in Rails?
Asked Answered
T

1

7

Nokogiri is the bane of my existence. It makes my rails new command fail for a different reason every time I create a new Rails app.

There’s a ton of Nokogiri troubleshooting on StackOverflow, but, I can’t find, neither here nor elsewhere, the reason why Nokogiri is included with Rails. The Nokogiri documentation states that it’s used for parsing, searching, and modifying HTML/XML documents, but, what purpose, if any, does it serve if I’m not screen scraping?

Tubulate answered 22/1, 2017 at 20:14 Comment(2)
It's mostly used to test rails stuff, tbh. I gather you're on windows? installing isn't usually an issue on *nixNudge
even Nokogiri throws exception while assigning as a gem,. but its effective way to truncate html.tagsAmmieammine
C
6

Nokogiri is an XML/HTML/CSS parser. So if you want to programatically read or edit an XML document Nokogiri is the way to go.

Nokogiri is a dependency of rails-dom-testing which is required by Rails.

As far as I see it rails-dom-testing is used to verify certain parts of a rendered HTML/CSS page.

Cacuminal answered 22/1, 2017 at 20:30 Comment(2)
Nokogiri can be a great tool, but it's also a 800-pound gorilla. It's unpleasant that it's a Rails dependency IMHO.Hagiarchy
Considering the problems people have installing it, it should be an optional test and installation for Rails.Supervise

© 2022 - 2024 — McMap. All rights reserved.