class Nokogiri::VersionInfo
def to_hash
def to_hash header_directory = File.expand_path(File.join(File.dirname(__FILE__), "../../../ext/nokogiri")) {}.tap do |vi| vi["warnings"] = [] vi["nokogiri"] = {}.tap do |nokogiri| nokogiri["version"] = Nokogiri::VERSION unless jruby? # enable gems to build against Nokogiri with the following in their extconf.rb: # # append_cflags(Nokogiri::VERSION_INFO["nokogiri"]["cppflags"]) # append_ldflags(Nokogiri::VERSION_INFO["nokogiri"]["ldflags"]) # # though, this won't work on all platform and versions of Ruby, and won't be supported # forever, see https://github.com/sparklemotion/nokogiri/discussions/2746 for context. # cppflags = ["-I#{header_directory.shellescape}"] ldflags = [] if libxml2_using_packaged? cppflags << "-I#{File.join(header_directory, "include").shellescape}" cppflags << "-I#{File.join(header_directory, "include/libxml2").shellescape}" end if windows? # on windows, third party libraries that wish to link against nokogiri # should link against nokogiri.so to resolve symbols. see #2167 lib_directory = File.expand_path(File.join(File.dirname(__FILE__), "../#{ruby_minor}")) unless File.exist?(lib_directory) lib_directory = File.expand_path(File.join(File.dirname(__FILE__), "..")) end ldflags << "-L#{lib_directory.shellescape}" ldflags << "-l:nokogiri.so" end nokogiri["cppflags"] = cppflags nokogiri["ldflags"] = ldflags end end vi["ruby"] = {}.tap do |ruby| ruby["version"] = ::RUBY_VERSION ruby["platform"] = ::RUBY_PLATFORM ruby["gem_platform"] = ::Gem::Platform.local.to_s ruby["description"] = ::RUBY_DESCRIPTION ruby["engine"] = engine ruby["jruby"] = jruby? if jruby? end if libxml2? vi["libxml"] = {}.tap do |libxml| if libxml2_using_packaged? libxml["source"] = "packaged" libxml["precompiled"] = libxml2_precompiled? libxml["patches"] = Nokogiri::LIBXML2_PATCHES else libxml["source"] = "system" end libxml["memory_management"] = Nokogiri::LIBXML_MEMORY_MANAGEMENT libxml["iconv_enabled"] = libxml2_has_iconv? libxml["compiled"] = compiled_libxml_version.to_s libxml["loaded"] = loaded_libxml_version.to_s end vi["libxslt"] = {}.tap do |libxslt| if libxml2_using_packaged? libxslt["source"] = "packaged" libxslt["precompiled"] = libxml2_precompiled? libxslt["patches"] = Nokogiri::LIBXSLT_PATCHES else libxslt["source"] = "system" end libxslt["datetime_enabled"] = libxslt_has_datetime? libxslt["compiled"] = compiled_libxslt_version.to_s libxslt["loaded"] = loaded_libxslt_version.to_s end vi["warnings"] = warnings end if defined?(Nokogiri::OTHER_LIBRARY_VERSIONS) # see extconf for how this string is assembled: "lib1name:lib1version,lib2name:lib2version" vi["other_libraries"] = Hash[*Nokogiri::OTHER_LIBRARY_VERSIONS.split(/[,:]/)] elsif jruby? vi["other_libraries"] = {}.tap do |ol| Nokogiri::JAR_DEPENDENCIES.each do |k, v| ol[k] = v end end end end end