Class: Nokogiri::VersionInfo
- Inherits:
-
Object
- Object
- Nokogiri::VersionInfo
- Includes:
- Singleton
- Defined in:
- lib/nokogiri/version/info.rb
Overview
:nodoc:
Instance Method Summary collapse
- #compiled_libxml_version ⇒ Object
- #compiled_libxslt_version ⇒ Object
- #engine ⇒ Object
- #jruby? ⇒ Boolean
- #libxml2? ⇒ Boolean
- #libxml2_has_iconv? ⇒ Boolean
- #libxml2_precompiled? ⇒ Boolean
- #libxml2_using_packaged? ⇒ Boolean
- #libxml2_using_system? ⇒ Boolean
- #loaded_libxml_version ⇒ Object
- #loaded_libxslt_version ⇒ Object
- #ruby_minor ⇒ Object
- #to_hash ⇒ Object
- #to_markdown ⇒ Object
- #warnings ⇒ Object
- #windows? ⇒ Boolean
Instance Method Details
#compiled_libxml_version ⇒ Object
32 33 34 |
# File 'lib/nokogiri/version/info.rb', line 32 def compiled_libxml_version Gem::Version.new(Nokogiri::LIBXML_COMPILED_VERSION) end |
#compiled_libxslt_version ⇒ Object
43 44 45 |
# File 'lib/nokogiri/version/info.rb', line 43 def compiled_libxslt_version Gem::Version.new(Nokogiri::LIBXSLT_COMPILED_VERSION) end |
#engine ⇒ Object
21 22 23 |
# File 'lib/nokogiri/version/info.rb', line 21 def engine defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "mri" end |
#jruby? ⇒ Boolean
9 10 11 |
# File 'lib/nokogiri/version/info.rb', line 9 def jruby? ::JRUBY_VERSION if ::RUBY_PLATFORM == "java" end |
#libxml2? ⇒ Boolean
47 48 49 |
# File 'lib/nokogiri/version/info.rb', line 47 def libxml2? defined?(Nokogiri::LIBXML_COMPILED_VERSION) end |
#libxml2_has_iconv? ⇒ Boolean
51 52 53 |
# File 'lib/nokogiri/version/info.rb', line 51 def libxml2_has_iconv? defined?(Nokogiri::LIBXML_ICONV_ENABLED) && Nokogiri::LIBXML_ICONV_ENABLED end |
#libxml2_precompiled? ⇒ Boolean
63 64 65 |
# File 'lib/nokogiri/version/info.rb', line 63 def libxml2_precompiled? libxml2_using_packaged? && Nokogiri::PRECOMPILED_LIBRARIES end |
#libxml2_using_packaged? ⇒ Boolean
55 56 57 |
# File 'lib/nokogiri/version/info.rb', line 55 def libxml2_using_packaged? libxml2? && Nokogiri::PACKAGED_LIBRARIES end |
#libxml2_using_system? ⇒ Boolean
59 60 61 |
# File 'lib/nokogiri/version/info.rb', line 59 def libxml2_using_system? libxml2? && !libxml2_using_packaged? end |
#loaded_libxml_version ⇒ Object
25 26 27 28 29 30 |
# File 'lib/nokogiri/version/info.rb', line 25 def loaded_libxml_version Gem::Version.new(Nokogiri::LIBXML_LOADED_VERSION .scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first .collect(&:to_i) .join(".")) end |
#loaded_libxslt_version ⇒ Object
36 37 38 39 40 41 |
# File 'lib/nokogiri/version/info.rb', line 36 def loaded_libxslt_version Gem::Version.new(Nokogiri::LIBXSLT_LOADED_VERSION .scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first .collect(&:to_i) .join(".")) end |
#ruby_minor ⇒ Object
17 18 19 |
# File 'lib/nokogiri/version/info.rb', line 17 def ruby_minor Gem::Version.new(::RUBY_VERSION).segments[0..1].join(".") end |
#to_hash ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/nokogiri/version/info.rb', line 83 def to_hash header_directory = File.(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 like nokogumbo to build with the following in their extconf.rb: # # append_cflags(Nokogiri::VERSION_INFO["nokogiri"]["cppflags"]) # append_ldflags(Nokogiri::VERSION_INFO["nokogiri"]["ldflags"]) # 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}" if windows? # on windows, nokogumbo needs to link against nokogiri.so to resolve symbols. see #2167 lib_directory = File.(File.join(File.dirname(__FILE__), "../#{ruby_minor}")) unless File.exist?(lib_directory) lib_directory = File.(File.join(File.dirname(__FILE__), "..")) end ldflags << "-L#{lib_directory.shellescape}" ldflags << "-l:nokogiri.so" end 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 # this is for nokogumbo and shouldn't be forever libxml["libxml2_path"] = header_directory else libxml["source"] = "system" end 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["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| ol["xerces"] = Nokogiri::XERCES_VERSION ol["nekohtml"] = Nokogiri::NEKO_VERSION end end end end |
#to_markdown ⇒ Object
172 173 174 175 176 177 178 179 180 |
# File 'lib/nokogiri/version/info.rb', line 172 def to_markdown begin require "psych" rescue LoadError end require "yaml" "# Nokogiri (#{Nokogiri::VERSION})\n" + YAML.dump(to_hash).each_line.map { |line| " #{line}" }.join end |
#warnings ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nokogiri/version/info.rb', line 67 def warnings warnings = [] if libxml2? if compiled_libxml_version != loaded_libxml_version warnings << "Nokogiri was built against libxml version #{compiled_libxml_version}, but has dynamically loaded #{loaded_libxml_version}" end if compiled_libxslt_version != loaded_libxslt_version warnings << "Nokogiri was built against libxslt version #{compiled_libxslt_version}, but has dynamically loaded #{loaded_libxslt_version}" end end warnings end |
#windows? ⇒ Boolean
13 14 15 |
# File 'lib/nokogiri/version/info.rb', line 13 def windows? ::RUBY_PLATFORM =~ /mingw|mswin/ end |