Class: Splash::Config::ConfigLinter

Inherits:
Object
  • Object
show all
Defined in:
lib/splash/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfigLinter



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(options ={})
  status = :success
  missings = []
  type_errors = []
  useless = []
  options[:record].each do |key,value|
    useless.push key unless @lints_present[options[:type]].include? key or @lints_types[options[:type]].keys.include? key
    type_errors.push key if @lints_types[options[:type]][key] != value.class and (@lints_present[options[:type]].include? key or @lints_types[options[:type]].keys.include? key)
  end
  @lints_present[options[:type]].each do |item|
    missings.push item unless options[: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