How sparklemotion/nokogiri works
Main Components
• Core API Layer – Represent the primary Nokogiri API housed in the “lib/nokogiri” directory. This layer includes the Ruby classes, modules, and DSLs (e.g., for CSS, XPath, HTML, XML, and XSLT handling).
• Java Extensions (JRuby) – Illustrate the “ext/java/nokogiri” folders that consist of Java source files and utilities. This component is essential for the JRuby implementation and integrates with dependencies like Xerces, NekoHTML, and additional JAR-based libraries.
• Test Suite – The “test/” directory contains extensive tests (for XML, HTML4, HTML5, CSS, and XPath). Represent this as an external quality gate that verifies and validates the interactions among components.
Relationships and Interactions
• The Gumbo Parser should be depicted as an external dependency that feeds into the HTML5 parsing functionality within the core APIs.
Architectural Patterns and Design Principles
• “thin wrapper” design: the Nokogiri API is a relatively thin layer that passes functionality directly through to underlying native libraries. Mark this with an annotation or note.
• The separation of concerns is clear: one component handles the Ruby-level DSLs (in “lib/”), while another handles platform-specific parsing implementations (in “ext/” for C and Java).
• The design is modular: the same high-level API endpoints function across different runtime environments (CRuby vs. JRuby).
Relevant Technologies and Frameworks
• Ruby (for the API and core logic).
• C (for native extensions on CRuby) and libxml2/libxslt (for parsing and transformation).
• Java (for JRuby implementations) along with associated XML libraries (e.g., Xerces, NekoHTML).
• Build/CI tools (Rake, GitHub Actions, Appveyor) – these should be noted as part of the development infrastructure.