Class: RokuBuilder::ConfigValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/roku_builder/config_validator.rb

Constant Summary collapse

DEPRICATED_FILES_FOLDERS =
-1
VALID_CONFIG =
0
MISSING_DEVICES =
1
MISSING_DEVICES_DEFAULT =
2
DEVICE_DEFAULT_BAD =
3
MISSING_PROJECTS_DEFAULT =

4

5
PROJECTS_DEFAULT_BAD =
6
DEVICE_MISSING_IP =
7
DEVICE_MISSING_USER =
8
DEVICE_MISSING_PASSWORD =
9
PROJECT_MISSING_APP_NAME =
10
PROJECT_MISSING_DIRECTORY =
11
PROJECT_MISSING_PLUGIN =
12
PROJECT_FOLDERS_BAD =
13
PROJECT_MISSING_FILES =
14
PROJECT_FILES_BAD =
15
STAGE_MISSING_BRANCH =
16
STAGE_MISSING_SCRIPT =
17
PROJECT_STAGE_METHOD_BAD =
18
KEY_MISSING_PATH =
19
KEY_MISSING_PASSWORD =
20
INVALID_MAPPING_INFO =
21
INVALID_API_KEY =
22
MISSING_STAGE_METHOD =
23

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ ConfigValidator

Returns a new instance of ConfigValidator.



32
33
34
35
36
# File 'lib/roku_builder/config_validator.rb', line 32

def initialize(config:)
  @logger = Logger.instance
  @config = config
  validate_config
end

Instance Method Details

#is_depricated?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/roku_builder/config_validator.rb', line 53

def is_depricated?
  !@codes.select{|code| code < 0}.empty?
end

#is_fatal?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/roku_builder/config_validator.rb', line 49

def is_fatal?
  !@codes.select{|code| code > 0}.empty?
end

#is_valid?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/roku_builder/config_validator.rb', line 57

def is_valid?
  @codes.select{|code| code > 0}.empty?
end


38
39
40
41
42
43
44
45
46
47
# File 'lib/roku_builder/config_validator.rb', line 38

def print_errors
  @codes.each do |code|
    if code > 0
      @logger.fatal error_codes[code]
    end
    if code < 0
      @logger.warn error_codes[code]
    end
  end
end