lib/coverband/reporters/web.rb in coverband-4.0.1 vs lib/coverband/reporters/web.rb in coverband-4.1.0.alpha
- old
+ new
@@ -1,8 +1,11 @@
# frozen_string_literal: true
-require 'rack'
+begin
+ require 'rack'
+rescue LoadError
+end
module Coverband
module Reporters
class Web
attr_reader :request
@@ -30,11 +33,11 @@
end
else
case request.path_info
when /.*\.(css|js|gif|png)/
@static.call(env)
- when %r{\/}
+ when %r{\/$}
[200, { 'Content-Type' => 'text/html' }, [index]]
else
[404, { 'Content-Type' => 'text/html' }, ['404 error!']]
end
end
@@ -55,11 +58,15 @@
notice = 'coverband coverage collected'
[301, { 'Location' => "#{base_path}?notice=#{notice}" }, []]
end
def clear
- Coverband.configuration.store.clear!
- notice = 'coverband coverage cleared'
+ if Coverband.configuration.web_enable_clear
+ Coverband.configuration.store.clear!
+ notice = 'coverband coverage cleared'
+ else
+ notice = 'web_enable_clear isnt enabled in your configuration'
+ end
[301, { 'Location' => "#{base_path}?notice=#{notice}" }, []]
end
def reload_files
Coverband.configuration&.safe_reload_files&.each do |safe_file|