Sha256: 20d38f9f69a2d8bfbc05a568297b71d2de3f70fa2475b0a21cacb3b1a933bba4

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 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::WatirOptions.new.execute
    end
  end

  class WatirOptions < 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
      builder.add_choice :zero_based_indexing,
      :type => :boolean,
      :default => true
    end
    def execute 
      @user_choices[:speed] = @user_choices[:speed].to_sym
      @user_choices
    end 
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
watir-classic-3.3.0 lib/watir-classic/options.rb
watir-classic-3.2.0 lib/watir-classic/options.rb
watir-classic-3.2.0.rc1 lib/watir-classic/options.rb
watir-classic-3.1.0 lib/watir-classic/options.rb
watir-classic-3.0.0 lib/watir-classic/options.rb
commonwatir-3.0.0.rc3 lib/watir/options.rb
commonwatir-3.0.0.rc2 lib/watir/options.rb
commonwatir-3.0.0.rc1 lib/watir/options.rb