Class: ActivePostgres::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/active_postgres/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, ssh_executor) ⇒ Validator

Returns a new instance of Validator.



5
6
7
8
9
10
# File 'lib/active_postgres/validator.rb', line 5

def initialize(config, ssh_executor)
  @config = config
  @ssh_executor = ssh_executor
  @errors = []
  @warnings = []
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/active_postgres/validator.rb', line 3

def config
  @config
end

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/active_postgres/validator.rb', line 3

def errors
  @errors
end

#ssh_executorObject (readonly)

Returns the value of attribute ssh_executor.



3
4
5
# File 'lib/active_postgres/validator.rb', line 3

def ssh_executor
  @ssh_executor
end

#warningsObject (readonly)

Returns the value of attribute warnings.



3
4
5
# File 'lib/active_postgres/validator.rb', line 3

def warnings
  @warnings
end

Instance Method Details

#validate_allObject

Run all validation checks before installation



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_postgres/validator.rb', line 13

def validate_all
  puts 'Running pre-flight validation checks...'

  validate_configuration
  validate_ssh_connectivity
  validate_network_connectivity
  validate_system_requirements

  if errors.any?
    puts "\n❌ Validation failed with #{errors.count} error(s):"
    errors.each { |error| puts "  - #{error}" }
    return false
  end

  if warnings.any?
    puts "\n⚠️  Found #{warnings.count} warning(s):"
    warnings.each { |warning| puts "  - #{warning}" }
  end

  puts "✅ All validation checks passed!\n"
  true
end