Class: Rack::LiveReload::ProcessingSkipAnalyzer
- Inherits:
-
Object
- Object
- Rack::LiveReload::ProcessingSkipAnalyzer
- Defined in:
- lib/rack/livereload/processing_skip_analyzer.rb
Constant Summary collapse
- BAD_USER_AGENTS =
[ %r{MSIE} ]
Class Method Summary collapse
Instance Method Summary collapse
- #bad_browser? ⇒ Boolean
- #chunked? ⇒ Boolean
- #get? ⇒ Boolean
- #html? ⇒ Boolean
- #ignored? ⇒ Boolean
-
#initialize(result, env, options) ⇒ ProcessingSkipAnalyzer
constructor
A new instance of ProcessingSkipAnalyzer.
- #inline? ⇒ Boolean
- #skip_processing? ⇒ Boolean
Constructor Details
#initialize(result, env, options) ⇒ ProcessingSkipAnalyzer
Returns a new instance of ProcessingSkipAnalyzer.
12 13 14 15 16 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 12 def initialize(result, env, ) @env, @options = env, @status, @headers, @body = result end |
Class Method Details
.skip_processing?(result, env, options) ⇒ Boolean
8 9 10 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 8 def self.skip_processing?(result, env, ) new(result, env, ).skip_processing? end |
Instance Method Details
#bad_browser? ⇒ Boolean
35 36 37 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 35 def bad_browser? BAD_USER_AGENTS.any? { |pattern| @env['HTTP_USER_AGENT'] =~ pattern } end |
#chunked? ⇒ Boolean
22 23 24 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 22 def chunked? @headers['Transfer-Encoding'] == 'chunked' end |
#get? ⇒ Boolean
43 44 45 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 43 def get? @env['REQUEST_METHOD'] == 'GET' end |
#html? ⇒ Boolean
39 40 41 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 39 def html? @headers['Content-Type'] =~ %r{text/html} end |
#ignored? ⇒ Boolean
30 31 32 33 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 30 def ignored? path = @env['QUERY_STRING'].empty? ? @env['PATH_INFO'] : "#{@env['PATH_INFO']}?#{@env['QUERY_STRING']}" @options[:ignore] and @options[:ignore].any? { |filter| path[filter] } end |
#inline? ⇒ Boolean
26 27 28 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 26 def inline? @headers['Content-Disposition'] =~ %r{^inline} end |
#skip_processing? ⇒ Boolean
18 19 20 |
# File 'lib/rack/livereload/processing_skip_analyzer.rb', line 18 def skip_processing? !html? || chunked? || inline? || ignored? || bad_browser? || !get? end |