Sha256: 614fcceb541ce2b049428e7cdb01bc748ced4745aa73cd7d4de26585007350c8

Contents?: true

Size: 1.54 KB

Versions: 28

Compression:

Stored size: 1.54 KB

Contents

module MiniAutobot
  module Utils

    # Page object-related helper methods.
    module EndecaHelper

      # Helper method to instantiate a new page object. This method should only
      # be used when first loading; subsequent page objects are automatically
      # instantiated by calling #cast on the page object.
      #
      # @param name [String, Symbol]
      # @return [PageObject::Base]
      def endeca(name)
        # Get the fully-qualified class name
        klass_name = "mini_autobot/database/endeca".camelize
        klass = begin
          klass_name.constantize
        rescue => exc
          msg = ""
          msg << "Cannot find page object '#{name}', "
          msg << "because could not load class '#{klass_name}' "
          msg << "with underlying error:\n  #{exc.class}: #{exc.message}\n"
          msg << exc.backtrace.map { |str| "    #{str}" }.join("\n")
          raise NameError, msg
          
        driver = MiniAutobot::Connector.get_default
        instance = klass.new(driver)
        
        Drawbridge.setup do |config|
          config.bridge_url = driver.env[:endeca][:url]
          config.bridge_path = driver.env[:endeca][:bridge]
          # e.g. ENDECA_DEBUG=true rackup
          config.endeca_debug = ENV.fetch('ENDECA_DEBUG') { false }
          # optional, default is 5
          config.timeout = 5
          # optional, default is to change ' into &#39; before JSON is parsed
          config.skip_single_quote_encoding = true
        end
        
        return instance
       end        
      end
     end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
mini_autobot-1.1.7 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.6 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.5 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.4 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.3 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.2 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.1 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.1.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-1.0.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.8.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.7.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.6.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.5.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.4.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.3.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.2.2 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.2.1 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.2.0 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.1.1 lib/mini_autobot/utils/endeca_helper.rb
mini_autobot-0.1.0 lib/mini_autobot/utils/endeca_helper.rb