Class: Splash::Config::ConfigLinter
Instance Method Summary collapse
-
#initialize ⇒ ConfigLinter
constructor
A new instance of ConfigLinter.
- #verify(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ ConfigLinter
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/splash/config.rb', line 15 def initialize @lints_present = {:logs => [:label, :log, :pattern ], :processes => [:process, :patterns ], :commands => [:name, :desc, :command ]} @lints_types = {:logs => {:label => Symbol, :log => String, :pattern => String, :retention => Hash}, :processes => {:process => Symbol, :patterns => Array, :retention => Hash}, :commands => {:name => Symbol, :desc => String, :command => String, :schedule => Hash, :retention => Hash, :on_failure => Symbol, :on_success => Symbol, :user => String, :delegate_to => Hash}} end |
Instance Method Details
#verify(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/splash/config.rb', line 26 def verify( ={}) status = :success missings = [] type_errors = [] useless = [] [:record].each do |key,value| useless.push key unless @lints_present[[:type]].include? key or @lints_types[[:type]].keys.include? key type_errors.push key if @lints_types[[:type]][key] != value.class and (@lints_present[[:type]].include? key or @lints_types[[:type]].keys.include? key) end @lints_present[[:type]].each do |item| missings.push item unless [:record].keys.include? item end status = :failure if (missings.count > 0) or (type_errors.count > 0) return {:missings => missings, :type_errors => type_errors, :useless => useless, :status => status} end |