Module: InputLoader
- Defined in:
- lib/teuton-server/input_loader.rb
Overview
This module reads input configuration
Class Method Summary collapse
-
.read_configuration(args) ⇒ Hash
Read configuration.
-
.read_yaml(filepath) ⇒ Hash
Read configuration from YAML file.
Class Method Details
.read_configuration(args) ⇒ Hash
Read configuration
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/teuton-server/input_loader.rb', line 9 def self.read_configuration(args) input = (args.size.zero? ? [Application::CONFIGFILE] : args) param = {} param = read_yaml(input[0]) param[:server][:ip] = input[1] if input[1] param[:server][:ip] = '127.0.0.1' if param[:server][:ip].nil? param[:server][:port] = input[2] if input[2] param[:server][:port] = Application::PORT if param[:server][:port].nil? param end |
.read_yaml(filepath) ⇒ Hash
Read configuration from YAML file
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/teuton-server/input_loader.rb', line 23 def self.read_yaml(filepath) filepath = File.join(filepath, Application::CONFIGFILE) if File.directory? filepath unless File.exists? filepath puts Rainbow("[ERROR] Config file \'#{filepath}\' not found!").red exit 1 end param = YAML.load_file(filepath) param[:server][:configfile] = filepath param[:server][:configdir] = File.dirname(filepath) param end |