From 7eff359424cac0ecfad214bac61e3e9e3233057a Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Fri, 3 Jul 2020 11:35:49 +0200 Subject: [PATCH] Fix build for Ruby 2.3 and 2.4 --- lib/validate_website/crawl.rb | 6 ++++-- lib/validate_website/static.rb | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/validate_website/crawl.rb b/lib/validate_website/crawl.rb index 5a5317a..82db508 100644 --- a/lib/validate_website/crawl.rb +++ b/lib/validate_website/crawl.rb @@ -80,8 +80,10 @@ def on_every_html_page(crawler) end if validate?(page) - validate(page.doc, page.body, page.url, - options.slice(:ignore, :html5_validator)) + keys = %i[ignore html5_validator] + # slice does not exists on Ruby <= 2.4 + slice = Hash[[keys, options.values_at(*keys)].transpose] + validate(page.doc, page.body, page.url, slice) end end end diff --git a/lib/validate_website/static.rb b/lib/validate_website/static.rb index 99f473b..119a33f 100644 --- a/lib/validate_website/static.rb +++ b/lib/validate_website/static.rb @@ -60,8 +60,10 @@ def check_static_file(file) def check_page(file, page) if page.html? && options[:markup] - validate(page.doc, page.body, file, - options.slice(:ignore, :html5_validator)) + keys = %i[ignore html5_validator] + # slice does not exists on Ruby <= 2.4 + slice = Hash[[keys, options.values_at(*keys)].transpose] + validate(page.doc, page.body, file, slice) end check_static_not_found(page.links) if options[:not_found] end