Class: HackBoxen::ConfigValidator
- Inherits:
-
Object
- Object
- HackBoxen::ConfigValidator
- Defined in:
- lib/hackboxen/utils/config_validator.rb
Class Method Summary collapse
-
.failed_requirements ⇒ Object
This makes sure the “requires” are met by the “provides” in the hackbox config.
-
.match_requirements(r, p, path = "") ⇒ Object
Recursive.
Class Method Details
.failed_requirements ⇒ Object
This makes sure the “requires” are met by the “provides” in the hackbox config. Failures are stored in fails
.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hackboxen/utils/config_validator.rb', line 7 def self.failed_requirements p = WorkingConfig['provides'] r = WorkingConfig['requires'] fails = [] if r != nil if not r.class == Hash or not p.class == Hash fails << "'requires' and 'provides' must be Hash" else fails += self.match_requirements r, p end end fails end |
.match_requirements(r, p, path = "") ⇒ Object
Recursive. r and p must be hashes.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hackboxen/utils/config_validator.rb', line 22 def self.match_requirements r,p,path="" fails = [] r.keys.each { |k| if not p.has_key? k fails << "Missing #{path}/#{k}" else if r[k].class == Hash if p[k].class != Hash fails << "'provides' #{path}/#{k} should be a hash because 'requires' is." else fails += self.match_requirements r[k],p[k],"#{path}/#{k}" end end end } fails end |