Sha256: 1163d9c25fb6e57531b72edee7563fc0f004bf87226126ed8496a157afd6d030

Contents?: true

Size: 615 Bytes

Versions: 9

Compression:

Stored size: 615 Bytes

Contents

require 'page_magic/driver'
module PageMagic
  class Drivers
    def all
      @all ||= []
    end

    def register(driver)
      all << driver
    end

    def find(browser)
      all.find { |driver| driver.support?(browser) }
    end

    def load(path = "#{__dir__}/drivers")
      require 'active_support/inflector'

      Dir["#{path}/*.rb"].each do |driver_file|
        require driver_file
        driver_name = File.basename(driver_file)[/(.*)\.rb$/, 1]
        register eval(driver_name.classify)
      end
    end

    def ==(other)
      other.is_a?(Drivers) && other.all == other.all
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
page_magic-1.0.0.alpha13 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha12 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha11 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha10 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha9 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha8 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha7 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha6 lib/page_magic/drivers.rb
page_magic-1.0.0.alpha5 lib/page_magic/drivers.rb