Module: HTTP::Validator
- Defined in:
- lib/http_validator.rb
Class Method Summary collapse
Class Method Details
.display_report(element_info, format = 'plain') ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/http_validator.rb', line 133 def self.display_report(element_info, format='plain') if format == 'plain' printf "%-90s%15s%15s\n\n", "Element", "Expected Size", "Actual Size" element_info.each_pair { |resource, values| values.each { |item| printf "%-90s%15s%15s\n", resource, item[:expected_size], item[:actual_size] } } elsif format == 'cucumber_example' element_info.each_pair { |resource, values| values.each { |item| printf "%-100s%15s%15s\n", "#{resource}|", "#{item[:expected_size]}|", "#{item[:actual_size]}|" } } end end |
.run(url = '', params = {}) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/http_validator.rb', line 151 def self.run(url='', params={}) raise ArgumentError unless url =~ /^http:\/\/|https:\/\// params[:random_user_agent] ||= 'false' URI.parse(url) # see if parsable, blow up if not @browser.base_url = url if params.has_key?(:proxy) @browser.browser.proxy_url = params[:proxy] end if params[:random_user_agent].to_bool @browser.random_user_agent=true end @browser.clear @browser.get_elements @browser.elements.each { |e| @browser.element_details(e) } if params.has_key?(:display_report) params[:display_report][:format] ||= 'plain' display_report(@browser.element_info, params[:display_report][:format]) end @browser.element_info end |