Skip to content

Commit

Permalink
Adjust nocov markers
Browse files Browse the repository at this point in the history
Coverage testing is now done on Ruby 3.3, which supports erb/escape.
  • Loading branch information
jeremyevans committed May 29, 2024
1 parent 48f09d0 commit 241daf9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/erubi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,20 @@ module Erubi

begin
require 'erb/escape'
# :nocov:
define_method(:h, ERB::Escape.instance_method(:html_escape))
# :nocov:
# :nocov:
rescue LoadError
begin
require 'cgi/escape'
# :nocov:
unless CGI.respond_to?(:escapeHTML) # work around for JRuby 9.1
CGI = Object.new
CGI.extend(defined?(::CGI::Escape) ? ::CGI::Escape : ::CGI::Util)
end
# :nocov:
# Escape characters with their HTML/XML equivalents.
def h(value)
CGI.escapeHTML(value.to_s)
end
rescue LoadError
# :nocov:
ESCAPE_TABLE = {'&' => '&amp;'.freeze, '<' => '&lt;'.freeze, '>' => '&gt;'.freeze, '"' => '&quot;'.freeze, "'" => '&#39;'.freeze}.freeze
if RUBY_VERSION >= '1.9'
def h(value)
Expand All @@ -47,9 +43,9 @@ def h(value)
value.to_s.gsub(/[&<>"']/){|s| ESCAPE_TABLE[s]}
end
end
# :nocov:
end
end
# :nocov:
module_function :h

class Engine
Expand Down

0 comments on commit 241daf9

Please sign in to comment.