Class: Taza::Settings
Class Method Summary collapse
-
.config(site_name) ⇒ Object
The config settings for a site.yml file.
-
.config_file ⇒ Object
Loads the config file for the entire project and returns the hash.
-
.config_file_path ⇒ Object
:nodoc:.
-
.config_folder ⇒ Object
:nodoc:.
-
.path ⇒ Object
:nodoc:.
-
.site_file(site_name) ⇒ Object
:nodoc:.
Class Method Details
.config(site_name) ⇒ Object
The config settings for a site.yml file. ENV variables will override the settings:
Can override the browser in config via ENV['BROWSER']
Can override the driver in config via ENV['DRIVER']
Can override the timeout in config via ENV['TIMEOUT']
Can override the server_ip in config via ENV['SERVER_IP']
Can override the server_port in config via ENV['SERVER_PORT']
Example:
Taza::Settings.Config('google')
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/taza/settings.rb', line 14 def self.config(site_name) env_settings = {} env_settings[:browser] = ENV['BROWSER'].to_sym if ENV['BROWSER'] env_settings[:driver] = ENV['DRIVER'].to_sym if ENV['DRIVER'] env_settings[:timeout] = ENV['TIMEOUT'] if ENV['TIMEOUT'] env_settings[:server_ip] = ENV['SERVER_IP'] if ENV['SERVER_IP'] env_settings[:server_port] = ENV['SERVER_PORT'] if ENV['SERVER_PORT'] env_settings = {:browser=>:firefox,:driver=>:selenium}.merge(config_file.merge(env_settings)) site_file(site_name).merge(env_settings) end |
.config_file ⇒ Object
Loads the config file for the entire project and returns the hash. Does not override settings from the ENV variables.
27 28 29 |
# File 'lib/taza/settings.rb', line 27 def self.config_file YAML.load_file(config_file_path) end |
.config_file_path ⇒ Object
:nodoc:
31 32 33 |
# File 'lib/taza/settings.rb', line 31 def self.config_file_path # :nodoc: File.join(config_folder,'config.yml') end |
.config_folder ⇒ Object
:nodoc:
35 36 37 |
# File 'lib/taza/settings.rb', line 35 def self.config_folder # :nodoc: File.join(path,'config') end |
.path ⇒ Object
:nodoc:
43 44 45 |
# File 'lib/taza/settings.rb', line 43 def self.path # :nodoc: '.' end |
.site_file(site_name) ⇒ Object
:nodoc:
39 40 41 |
# File 'lib/taza/settings.rb', line 39 def self.site_file(site_name) # :nodoc: YAML.load_file(File.join(config_folder,"#{site_name.underscore}.yml"))[ENV['TAZA_ENV']] end |