Class: WorkingMan::CLI::Config
- Inherits:
-
Object
- Object
- WorkingMan::CLI::Config
- Defined in:
- lib/working_man/cli/config.rb
Class Method Summary collapse
-
.check_config(config_path) ⇒ Object
Internal: Checks for a configuration file.
-
.check_config_format(config_path) ⇒ Object
Internal: Checks the format of the configuration file.
Class Method Details
.check_config(config_path) ⇒ Object
Internal: Checks for a configuration file. If one is not found, message is printed to the console and system exits with status code “1”
Examples:
check_config(config_path)
Returns true if everything passes
14 15 16 17 18 19 20 21 22 |
# File 'lib/working_man/cli/config.rb', line 14 def self.check_config(config_path) if File.exists?(config_path) check_config_format(config_path) return true else puts "No configuration found. Please configure which apps to start in #{config_path}" exit 1 end end |
.check_config_format(config_path) ⇒ Object
Internal: Checks the format of the configuration file. If the configuration is blank, exits with status “2”. If there are no apps, exits with status “3” If there are no URLs, prints a warning but continues with execution.
Examples:
check_config_format(config_path)
Returns true if everything passes
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/working_man/cli/config.rb', line 33 def self.check_config_format(config_path) $config = YAML::load(File.open(config_path)) if !$config p "Nothing in configuration. Exiting..." exit 2 elsif !$config['apps'] p "No applications in configuration. Exiting..." exit 2 elsif !$config['urls'] p "WARN: No URLs in configuration" return true end end |