Class: Jekyll::Commands::Serve::SkipAnalyzer
- Inherits:
-
Object
- Object
- Jekyll::Commands::Serve::SkipAnalyzer
- Defined in:
- lib/jekyll/commands/serve/servlet.rb
Overview
This class is used to determine if the Servlet should modify a served file to insert the LiveReload script tags
Constant Summary collapse
- BAD_USER_AGENTS =
[%r!MSIE!].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #bad_browser? ⇒ Boolean
- #chunked? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(request, response, options) ⇒ SkipAnalyzer
constructor
A new instance of SkipAnalyzer.
- #inline? ⇒ Boolean
- #skip_processing? ⇒ Boolean
Constructor Details
#initialize(request, response, options) ⇒ SkipAnalyzer
Returns a new instance of SkipAnalyzer.
17 18 19 20 21 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 17 def initialize(request, response, ) @options = @request = request @response = response end |
Class Method Details
.skip_processing?(request, response, options) ⇒ Boolean
13 14 15 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 13 def self.skip_processing?(request, response, ) new(request, response, ).skip_processing? end |
Instance Method Details
#bad_browser? ⇒ Boolean
35 36 37 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 35 def bad_browser? BAD_USER_AGENTS.any? { |pattern| pattern.match?(@request["User-Agent"]) } end |
#chunked? ⇒ Boolean
27 28 29 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 27 def chunked? @response["Transfer-Encoding"] == "chunked" end |
#html? ⇒ Boolean
39 40 41 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 39 def html? @response["Content-Type"].to_s.include?("text/html") end |
#inline? ⇒ Boolean
31 32 33 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 31 def inline? @response["Content-Disposition"].to_s.start_with?("inline") end |
#skip_processing? ⇒ Boolean
23 24 25 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 23 def skip_processing? !html? || chunked? || inline? || bad_browser? end |