Sha256: f9de2f0972553c6cc6b539f7e591ab27be1fc688e30e1cebc7a6c10bbaf968c7

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

#--
# watir/options
require 'rubygems'

require 'user-choices'

module Watir
  @@options_file = nil
  @@options = nil
  class << self
    # Specify the location of a yaml file containing Watir options. Must be
    # specified before the options are parsed.
    def options_file= file
      @@options_file = file
    end
    def options_file
      @@options_file
    end
    def options= x
      @@options = x
    end
    # Return the Watir options, as a hash. If they haven't been parsed yet,
    # they will be now.
    def options
      @@options ||= Watir::Options.new.execute
    end
  end

  class Options < UserChoices::Command
    include UserChoices
    def add_sources builder
      builder.add_source EnvironmentSource, :with_prefix, 'watir_'
      if Watir.options_file
        builder.add_source YamlConfigFileSource, :from_complete_path, 
          Watir.options_file
      end
    end
    def add_choices builder
      builder.add_choice :browser, 
      :type => Watir::Browser.browser_names, 
      :default => Watir::Browser.default
      builder.add_choice :speed, 
      :type => ['slow', 'fast', 'zippy'], 
      :default => 'fast'
      builder.add_choice :visible,
      :type => :boolean
    end
    def execute 
      @user_choices[:speed] = @user_choices[:speed].to_sym
      @user_choices
    end 
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
commonwatir-1.6.7.rc1 lib/watir/options.rb
commonwatir-1.6.6 lib/watir/options.rb
commonwatir-1.6.6.rc2 lib/watir/options.rb
commonwatir-1.6.6.rc1 lib/watir/options.rb