Sha256: e11226b6a288907c3cde6b28b136cd83bd60110b4421376482d6e18659fb3707

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

module AmazonAuth
  class Client
    include AmazonAuth::CommonExtension
    include AmazonAuth::SessionExtension

    attr_accessor :options

    def initialize(options = {})
      @options = options
      @driver = options.fetch(:driver, :selenium)
      # Check credentials
      raise('AMAZON_USERNAME_CODE is required.') unless (options[:login] || ENV['AMAZON_USERNAME_CODE']).present?
      raise('AMAZON_PASSWORD_CODE is required.') unless (options[:password] || ENV['AMAZON_PASSWORD_CODE']).present?
      Converter.salt if options[:login].blank? || options[:password].blank?

      Capybara.save_path = options.fetch(:save_path, 'tmp') if Capybara.save_path.nil?
      Capybara.app_host = initial_url if Capybara.app_host.nil?
    rescue => e
      puts "Please setup credentials of amazon_auth gem with folloing its instruction."
      raise e
    end

    def session
      @session ||= Capybara::Session.new(@driver)
    end

    # Hide instance variables of credentials on console
    def inspect
      to_s
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
amazon_auth-0.8.0 lib/amazon_auth/client.rb
amazon_auth-0.7.0 lib/amazon_auth/client.rb
amazon_auth-0.6.0 lib/amazon_auth/client.rb
amazon_auth-0.5.0 lib/amazon_auth/client.rb
amazon_auth-0.4.6 lib/amazon_auth/client.rb
amazon_auth-0.4.5 lib/amazon_auth/client.rb
amazon_auth-0.4.4 lib/amazon_auth/client.rb
amazon_auth-0.4.3 lib/amazon_auth/client.rb
amazon_auth-0.4.2 lib/amazon_auth/client.rb
amazon_auth-0.4.1 lib/amazon_auth/client.rb
amazon_auth-0.4.0 lib/amazon_auth/client.rb