Class: RokuBuilder::ConfigValidator
- Inherits:
-
Object
- Object
- RokuBuilder::ConfigValidator
- Defined in:
- lib/roku_builder/config_validator.rb
Overview
Validate Config File
Class Method Summary collapse
-
.error_codes ⇒ Array
Error code messages for config validation.
- .process_errors(codes:, errors:) ⇒ Object
-
.validate_config(config:) ⇒ Array
Validates the roku config.
Class Method Details
.error_codes ⇒ Array
Error code messages for config validation
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/roku_builder/config_validator.rb', line 60 def self.error_codes() [ #===============FATAL ERRORS===============# "Valid Config.", "Devices config is missing.", "Devices default is missing.", "Devices default is not a hash.", "Projects config is missing.", "Projects default is missing.", #5 "Projects default is not a hash.", "A device config is missing its IP address.", "A device config is missing its username.", "A device config is missing its password.", "A project config is missing its app_name.", #10 "A project config is missing its directorty.", "A project config is missing its folders.", "A project config's folders is not an array.", "A project config is missing its files.", "A project config's files is not an array.", #15 "A project stage is missing its branch.", "A project stage is missing its script.", "A project as an invalid stage method.", #===============WARNINGS===============# "A project is missing its stage method." ] end |
.process_errors(codes:, errors:) ⇒ Object
153 154 155 156 157 |
# File 'lib/roku_builder/config_validator.rb', line 153 def self.process_errors(codes:, errors:) errors.each do |error| codes.push(error[0]) if error[1] end end |
.validate_config(config:) ⇒ Array
Validates the roku config
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/roku_builder/config_validator.rb', line 33 def self.validate_config(config:) codes = [] validate_structure(codes: codes, config: config) if config[:devices] config[:devices].each {|device, device_config| next if device == :default validate_device(codes: codes, device: device_config) } end if config[:projects] config[:projects].each {|project,project_config| next if project == :default validate_project(codes: codes, project: project_config) if project_config[:stages] project_config[:stages].each {|_stage, stage_config| validate_stage(codes: codes, stage: stage_config, project: project_config) } end } end codes.uniq! codes.push(0) if codes.empty? codes end |