Class: Applitools::Selenium::VGResource
- Inherits:
-
Object
- Object
- Applitools::Selenium::VGResource
- Includes:
- Jsonable
- Defined in:
- lib/applitools/selenium/visual_grid/vg_resource.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#handle_discovered_resources_block ⇒ Object
Returns the value of attribute handle_discovered_resources_block.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .parse_blob_from_script(blob, options = {}) ⇒ Object
- .parse_response(url, response, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(url, content_type, content, options = {}) ⇒ VGResource
constructor
A new instance of VGResource.
- #lookup_for_resources ⇒ Object
- #on_resources_fetched(block) ⇒ Object
- #stringify ⇒ Object
Constructor Details
#initialize(url, content_type, content, options = {}) ⇒ VGResource
Returns a new instance of VGResource.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 33 def initialize(url, content_type, content, = {}) self.handle_discovered_resources_block = [:on_resources_fetched] if [:on_resources_fetched].is_a? Proc self.url = URI(url) self.content_type = content_type self.content = content self.hash = Digest::SHA256.hexdigest(content) self.hashFormat = 'sha256' lookup_for_resources end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
12 13 14 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 12 def content @content end |
#handle_discovered_resources_block ⇒ Object
Returns the value of attribute handle_discovered_resources_block.
12 13 14 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 12 def handle_discovered_resources_block @handle_discovered_resources_block end |
#url ⇒ Object
Returns the value of attribute url.
12 13 14 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 12 def url @url end |
Class Method Details
.parse_blob_from_script(blob, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 17 def parse_blob_from_script(blob, = {}) return new( blob['url'], "application/X-error-response-#{blob['errorStatusCode']}", blob['value'] || '' ).tap {|r| r.error_status_code = blob['errorStatusCode']} if blob['errorStatusCode'] content = Base64.decode64(blob['value']) new(blob['url'], blob['type'], content, ) end |
.parse_response(url, response, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 27 def parse_response(url, response, = {}) return new(url, 'application/empty-response', '') unless response.status == 200 new(url, response.headers['Content-Type'], response.body, ) end |
Instance Method Details
#lookup_for_resources ⇒ Object
48 49 50 51 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 48 def lookup_for_resources lookup_for_css_resources lookup_for_svg_resources end |
#on_resources_fetched(block) ⇒ Object
44 45 46 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 44 def on_resources_fetched(block) self.handle_discovered_resources_block = block end |
#stringify ⇒ Object
70 71 72 |
# File 'lib/applitools/selenium/visual_grid/vg_resource.rb', line 70 def stringify url.to_s + content_type.to_s + hash end |