Sha256: a27752ba18962a77fbb9259ca6790b3d5c36b3f77664b3f83a71c62194b509dd

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require_relative '../lib/cache'

module Percy
  class DriverMetadata
    def initialize(driver)
      @driver = driver
    end

    def session_id
      @driver.session_id
    end

    def command_executor_url
      url = Percy::Cache.get_cache(session_id, Percy::Cache::COMMAND_EXECUTOR_URL)
      if url.nil?
        url = @driver.instance_variable_get(:@bridge).instance_variable_get(:@http).instance_variable_get(:@server_url).to_s
        Percy::Cache.set_cache(session_id, Percy::Cache::COMMAND_EXECUTOR_URL, url)
      end
      url
    end

    def capabilities
      caps = Percy::Cache.get_cache(session_id, Percy::Cache::SESSION_CAPABILITIES)
      if caps.nil?
        caps = @driver.capabilities.dup # In Ruby, use dup to create a shallow copy of the hash
        Percy::Cache.set_cache(session_id, Percy::Cache::SESSION_CAPABILITIES, caps)
      end
      caps
    end

    def session_capabilities
      session_caps = Percy::Cache.get_cache(session_id, Percy::Cache::SESSION_CAPABILITIES)
      if session_caps.nil?
        session_caps = @driver.desired_capabilities.dup # Assuming there is a desired_capabilities method
        Percy::Cache.set_cache(session_id, Percy::Cache::SESSION_CAPABILITIES, session_caps)
      end
      session_caps
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
percy-appium-app-1.0.0 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.8 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.7 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.6 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.5 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.5.pre.beta.1 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.5.pre.beta.0 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.4 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.2.pre.beta.0 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.3 percy/metadata/driver_metadata.rb
percy-appium-app-0.0.2 percy/metadata/driver_metadata.rb