Sha256: 8b8ca98ae213a113ded5131e53e238c50415f3baa6edbd55879dd5a92dbe19eb

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

require 'symbiont/version'
require 'symbiont/platforms'
require 'symbiont/generators'

module Symbiont
  include Platforms

  # Used to make a platform object accessible. Will hold object
  # references like these:
  # <Symbiont::Platforms::WatirWebDriver::PlatformObject:0x2cbe8a0>
  # <Symbiont::Platforms::SeleniumWebDriver::PlatformObject:0x2cb9608>
  attr_reader :platform

  def self.version
    "Symbiont v#{Symbiont::VERSION}"
  end

  # The included callback is used to provide the core functionality of the
  # library to any class or module that includes the Symbiont library. The
  # calling class or module is extended with logic that the library makes
  # available as class methods. Those methods will be available only in
  # the context of the class (definition) that included Symbiont.
  def self.included(caller)
    puts("#{caller.class} #{caller} attached the Symbiont")
    caller.extend Symbiont::Generators
  end

  # The initialize method will be invoked when a page definition includes
  # Symbiont. Some key things are happening here that are critical to
  # Symbiont working correctly:
  #   (1) A browser instance is being created.
  #   (2) A platform object is created for that browser.
  #
  # @param [Object] browser a browser instance with a tool driver
  def initialize(browser)
    puts("Symbiont attached to browser: #{browser}")
    @browser = browser
    establish_platform_object_for(browser)
  end

  private

  # This method is crucial in that it sets up the platform instance that
  # will be used by just about every module that makes calls to any
  # platform-specific functionality.
  #
  # @param [Object] browser a browser instance with a tool driver
  def establish_platform_object_for(browser)
    @platform = get_platform_for(browser)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symbiont-0.0.2 lib/symbiont.rb
symbiont-0.0.1 lib/symbiont.rb