Class: Flydata::CompatibilityCheck

Inherits:
Object
  • Object
show all
Includes:
CommandLoggable
Defined in:
lib/flydata/compatibility_check.rb

Defined Under Namespace

Classes: CompatibilityError

Instance Method Summary collapse

Methods included from CommandLoggable

#before_logging, #log_error_stderr, #log_info_stdout, #log_warn_stderr

Constructor Details

#initialize(dp_hash, de_hash = nil, options = {}) ⇒ CompatibilityCheck

Returns a new instance of CompatibilityCheck.



11
12
13
14
# File 'lib/flydata/compatibility_check.rb', line 11

def initialize(dp_hash, de_hash=nil, options={})
  @dp = dp_hash
  @errors=[]
end

Instance Method Details

#checkObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flydata/compatibility_check.rb', line 16

def check
  self.methods.grep(/^check_/).each do |m|
    begin
      send(m)
    rescue ArgumentError => e
      # ignore
    rescue CompatibilityError => e
      @errors << e
    end
  end
  print_errors
end


29
30
31
32
33
34
35
36
# File 'lib/flydata/compatibility_check.rb', line 29

def print_errors
  return if @errors.empty?
  log_error_stderr "There may be some compatibility issues with this current server : "
  @errors.each do |error|
    log_error_stderr "  * #{error.message}"
  end
  raise "Please correct these errors if you wish to run FlyData Agent"
end