Module: InputLoader
- Defined in:
- lib/teuton-client/input_loader.rb
Overview
Methods that read config params
Class Method Summary collapse
-
.read_configuration(input) ⇒ String, Integer
Read input arguments and return config params.
-
.read_yaml(filepath) ⇒ Hash
Read YAML configuration file.
Class Method Details
.read_configuration(input) ⇒ String, Integer
Read input arguments and return config params. Arguments:
-
YAML file => Read file.yaml as config file
-
Empty
* Exist default config file => Read config file * Dosn't exist config file => Set defaults IP, PORT values
16 17 18 19 20 21 22 23 24 |
# File 'lib/teuton-client/input_loader.rb', line 16 def self.read_configuration(input) if input.size.zero? && File.exists?(Application::CONFIGFILE) param = read_yaml(Application::CONFIGFILE) return param[:server][:ip], param[:server][:port] end ip = (input[0] ? input[0] : 'localhost') port = (input[1] ? input[1] : 16001) return ip, port end |
.read_yaml(filepath) ⇒ Hash
Read YAML configuration file.
30 31 32 33 34 35 36 37 |
# File 'lib/teuton-client/input_loader.rb', line 30 def self.read_yaml(filepath) unless File.exists? filepath puts "teuton-client => " + Rainbow("[ERROR] Config file \'#{filepath}\' not found!").red exit 1 end return YAML.load_file(filepath) end |