Class: Generamba::ModuleValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/helpers/module_validator.rb

Overview

Provides methods for validating module

Constant Summary collapse

TARGET_TYPE_PROJECT =
'project'
TARGET_TYPE_TEST =
'test'

Instance Method Summary collapse

Instance Method Details

#validate(code_module) ⇒ Void

Method validates module

Parameters:

  • code_module (CodeModule)

    The instance of CodeModule

Returns:

  • (Void)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generamba/helpers/module_validator.rb', line 12

def validate(code_module)
  mandatory_fields = [COMPANY_KEY,
                      PROJECT_NAME_KEY,
                      XCODEPROJ_PATH_KEY]

  mandatory_fields.each do |field|
    unless code_module.instance_variable_get("@#{field}")
      puts "Module is broken! *#{field}* field cannot be empty, because it is mandatory.".red
      exit
    end
  end

  project_failure_fields = all_project_failure_fields(code_module)
  test_failure_fields = all_test_failure_fields(code_module)
  failure_fields = project_failure_fields + test_failure_fields

  if failure_fields.count > 0
    puts "Module is broken! *#{failure_fields}* field cannot be empty, because it is mandatory.".red
    exit
  end
end