Class: PageWeight::Parser
- Inherits:
-
Object
- Object
- PageWeight::Parser
- Defined in:
- lib/page_weight/parser.rb
Class Method Summary collapse
- .body_content_for(file_type) ⇒ Object
- .css_files_body_content_for(input) ⇒ Object
- .css_files_in(input) ⇒ Object
- .flash_objects_body_content_for(input) ⇒ Object
- .flash_objects_in(input) ⇒ Object
- .html_body_content_for(input) ⇒ Object
- .images_body_content_for(input) ⇒ Object
- .images_in(input) ⇒ Object
- .javascript_content_length_for(input) ⇒ Object
- .javascript_files_in(input) ⇒ Object
Class Method Details
.body_content_for(file_type) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/page_weight/parser.rb', line 51 def self.body_content_for(file_type) file_type.collect do |path| path.to_s.downcase.start_with?("http://", "https://") ? file_path = path : file_path = "#{PageWeight.url}#{path}" HTTP.response_for(URL.builder(file_path)).body end end |
.css_files_body_content_for(input) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/page_weight/parser.rb', line 37 def self.css_files_body_content_for(input) css_body = [] css_files = css_files_in(input) css_body = body_content_for(css_files) css_body.inject(:+) end |
.css_files_in(input) ⇒ Object
22 23 24 |
# File 'lib/page_weight/parser.rb', line 22 def self.css_files_in(input) files_for_url_with_xpath(input, "//link[@type='text/css']/@href") end |
.flash_objects_body_content_for(input) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/page_weight/parser.rb', line 30 def self.flash_objects_body_content_for(input) flash_body = [] flash_files = flash_objects_in(input) flash_body = body_content_for(flash_files) flash_body.inject(:+) end |
.flash_objects_in(input) ⇒ Object
18 19 20 |
# File 'lib/page_weight/parser.rb', line 18 def self.flash_objects_in(input) files_for_url_with_xpath(input, "//embed[contains(@type, 'flash')]/@src") end |
.html_body_content_for(input) ⇒ Object
3 4 5 |
# File 'lib/page_weight/parser.rb', line 3 def self.html_body_content_for(input) HTTP.response_for(input).body end |
.images_body_content_for(input) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/page_weight/parser.rb', line 7 def self.images_body_content_for(input) images_body = [] images = images_in(input) images_body = body_content_for(images) images_body.inject(:+) end |
.images_in(input) ⇒ Object
14 15 16 |
# File 'lib/page_weight/parser.rb', line 14 def self.images_in(input) files_for_url_with_xpath(input, "//img/@src") end |
.javascript_content_length_for(input) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/page_weight/parser.rb', line 44 def self.javascript_content_length_for(input) javascript_body = [] javascript_files = javascript_files_in(input) javascript_body = body_content_for(javascript_files) javascript_body.inject(:+) end |
.javascript_files_in(input) ⇒ Object
26 27 28 |
# File 'lib/page_weight/parser.rb', line 26 def self.javascript_files_in(input) files_for_url_with_xpath(input, "//script[@type='text/javascript']/@src") end |