Skip to content

Commit 877ab98

Browse files
committed
Remove ActiveRecord requirement
1 parent 4ad140e commit 877ab98

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

html-proofer.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
2626
gem.add_dependency 'yell', '~> 2.0'
2727
gem.add_dependency 'parallel', '~> 1.3'
2828
gem.add_dependency 'addressable', '~> 2.3'
29-
gem.add_dependency 'activesupport', '>= 4.2', '< 6.0'
29+
gem.add_dependency 'timerizer', '~> 0.3'
3030

3131
gem.add_development_dependency 'redcarpet'
3232
gem.add_development_dependency 'rubocop'

lib/html-proofer/cache.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
require_relative 'utils'
44

55
require 'json'
6-
require 'active_support/core_ext/string'
7-
require 'active_support/core_ext/date'
8-
require 'active_support/core_ext/numeric/time'
6+
require 'timerizer'
97

108
module HTMLProofer
119
class Cache
@@ -32,7 +30,7 @@ def initialize(logger, options)
3230
end
3331

3432
def within_timeframe?(time)
35-
(@parsed_timeframe..@cache_time).cover?(time)
33+
(@parsed_timeframe..@cache_time).cover?(Time.parse(time))
3634
end
3735

3836
def urls
@@ -45,7 +43,7 @@ def size
4543

4644
def parsed_timeframe(timeframe)
4745
time, date = timeframe.match(/(\d+)(\D)/).captures
48-
time = time.to_f
46+
time = time.to_i
4947
case date
5048
when 'M'
5149
time.months.ago

lib/html-proofer/check/favicon.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def run
2121

2222
def is_immediate_redirect?
2323
# allow any instant-redirect meta tag
24-
@html.xpath("//meta[@http-equiv='refresh']").attribute('content').value.starts_with? '0;' rescue false
24+
@html.xpath("//meta[@http-equiv='refresh']").attribute('content').value.start_with? '0;' rescue false
2525
end
2626

2727
end

lib/html-proofer/check/links.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run
4646
check_sri(line, content) if @link.check_sri? && node.name == 'link'
4747
# we need to skip these for now; although the domain main be valid,
4848
# curl/Typheous inaccurately return 404s for some links. cc https://git.io/vyCFx
49-
next if @link.try(:rel) == 'dns-prefetch'
49+
next if @link.respond_to?(:rel) && @link.rel == 'dns-prefetch'
5050
add_to_external_urls(@link.href)
5151
next
5252
elsif !@link.internal? && !@link.exists?

lib/html-proofer/element.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(obj, check)
3030

3131
@html = check.html
3232

33-
parent_attributes = obj.ancestors.map { |a| a.try(:attributes) }
33+
parent_attributes = obj.ancestors.map { |a| a.respond_to?(:attributes) && a.attributes }
3434
parent_attributes.pop # remove document at the end
3535
@parent_ignorable = parent_attributes.any? { |a| !a['data-proofer-ignore'].nil? }
3636

lib/html-proofer/middleware.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def call(env)
6262
rescue
6363
return result # Invalid encoding; it's not gonna be html.
6464
end
65-
if HTML_SIGNATURE.any? { |sig| html.upcase.starts_with? sig }
65+
if HTML_SIGNATURE.any? { |sig| html.upcase.start_with? sig }
6666
parsed = HTMLProofer::Runner.new(
6767
'response',
6868
Middleware.options

0 commit comments

Comments
 (0)