Skip to content

Commit

Permalink
style(rubocop): Layout
Browse files Browse the repository at this point in the history
- Layout/FirstArrayElementLineBreak
- Layout/FirstHashElementLineBreak
- Layout/FirstMethodArgumentLineBreak
- Layout/MultilineArrayLineBreaks
- Layout/MultilineHashKeyLineBreaks
- Layout/MultilineMethodArgumentLineBreaks
  • Loading branch information
flavorjones committed Feb 6, 2023
1 parent 6fe51b2 commit 071618a
Show file tree
Hide file tree
Showing 49 changed files with 3,248 additions and 1,181 deletions.
74 changes: 56 additions & 18 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,34 @@ def needs_darwin_linker_hack

if config_system_libraries?
message "Building nokogiri using system libraries.\n"
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
headers: "zlib.h", func: "gzdopen")
ensure_package_configuration(opt: "xml2", pc: "libxml-2.0", lib: "xml2",
headers: "libxml/parser.h", func: "xmlParseDoc")
ensure_package_configuration(opt: "xslt", pc: "libxslt", lib: "xslt",
headers: "libxslt/xslt.h", func: "xsltParseStylesheetDoc")
ensure_package_configuration(opt: "exslt", pc: "libexslt", lib: "exslt",
headers: "libexslt/exslt.h", func: "exsltFuncRegister")
ensure_package_configuration(
opt: "zlib",
pc: "zlib",
lib: "z",
headers: "zlib.h",
func: "gzdopen",
)
ensure_package_configuration(
opt: "xml2",
pc: "libxml-2.0",
lib: "xml2",
headers: "libxml/parser.h",
func: "xmlParseDoc",
)
ensure_package_configuration(
opt: "xslt",
pc: "libxslt",
lib: "xslt",
headers: "libxslt/xslt.h",
func: "xsltParseStylesheetDoc",
)
ensure_package_configuration(
opt: "exslt",
pc: "libexslt",
lib: "exslt",
headers: "libexslt/exslt.h",
func: "exsltFuncRegister",
)

have_libxml_headers?(REQUIRED_LIBXML_VERSION) ||
abort("ERROR: libxml2 version #{REQUIRED_LIBXML_VERSION} or later is required!")
Expand Down Expand Up @@ -785,8 +805,12 @@ def configure
end

unless nix?
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
cross_build_p) do |recipe|
libiconv_recipe = process_recipe(
"libiconv",
dependencies["libiconv"]["version"],
static_p,
cross_build_p,
) do |recipe|
recipe.files = [{
url: "https://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
sha256: dependencies["libiconv"]["sha256"],
Expand Down Expand Up @@ -824,15 +848,25 @@ def configure
if zlib_recipe
append_cppflags("-I#{zlib_recipe.path}/include")
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
headers: "zlib.h", func: "gzdopen")
ensure_package_configuration(
opt: "zlib",
pc: "zlib",
lib: "z",
headers: "zlib.h",
func: "gzdopen",
)
end

if libiconv_recipe
append_cppflags("-I#{libiconv_recipe.path}/include")
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH
ensure_package_configuration(opt: "iconv", pc: "iconv", lib: "iconv",
headers: "iconv.h", func: "iconv_open")
ensure_package_configuration(
opt: "iconv",
pc: "iconv",
lib: "iconv",
headers: "iconv.h",
func: "iconv_open",
)
end

libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
Expand Down Expand Up @@ -1057,12 +1091,16 @@ def compile
if cross_build_p
# When precompiling native gems, copy packaged libraries' headers to ext/nokogiri/include
# These are packaged up by the cross-compiling callback in the ExtensionTask
copy_packaged_libraries_headers(to_path: File.join(PACKAGE_ROOT_DIR, "ext/nokogiri/include"),
from_recipes: [libxml2_recipe, libxslt_recipe])
copy_packaged_libraries_headers(
to_path: File.join(PACKAGE_ROOT_DIR, "ext/nokogiri/include"),
from_recipes: [libxml2_recipe, libxslt_recipe],
)
else
# When compiling during installation, install packaged libraries' header files into ext/nokogiri/include
copy_packaged_libraries_headers(to_path: "include",
from_recipes: [libxml2_recipe, libxslt_recipe])
copy_packaged_libraries_headers(
to_path: "include",
from_recipes: [libxml2_recipe, libxslt_recipe],
)
$INSTALLFILES << ["include/**/*.h", "$(rubylibdir)"]
end
end
Expand Down
16 changes: 12 additions & 4 deletions lib/nokogiri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ def parse(string, url = nil, encoding = nil, options = nil)
# Expect an HTML indicator to appear within the first 512
# characters of a document. (<?xml ?> + <?xml-stylesheet ?>
# shouldn't be that long)
Nokogiri.HTML4(string, url, encoding,
options || XML::ParseOptions::DEFAULT_HTML)
Nokogiri.HTML4(
string,
url,
encoding,
options || XML::ParseOptions::DEFAULT_HTML,
)
else
Nokogiri.XML(string, url, encoding,
options || XML::ParseOptions::DEFAULT_XML)
Nokogiri.XML(
string,
url,
encoding,
options || XML::ParseOptions::DEFAULT_XML,
)
end.tap do |doc|
yield doc if block_given?
end
Expand Down
Loading

0 comments on commit 071618a

Please sign in to comment.