Class: PolishGeeks::DevTools::Commands::YmlParser

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/yml_parser.rb

Overview

Verifying parameters in example YAML config files

Constant Summary

Constants inherited from Base

Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Method Details

#error_messageString

Returns error message.

Returns:

  • (String)

    error message



31
32
33
34
35
# File 'lib/polish_geeks/dev_tools/commands/yml_parser.rb', line 31

def error_message
  err = 'Following yml files have nil as a value:'
  @output.each { |row| err << file_error(row) }
  err << "\n"
end

#executeArray

Executes this command

Returns:

  • (Array)

    command output



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/polish_geeks/dev_tools/commands/yml_parser.rb', line 10

def execute
  @output = []
  Dir[config_path].each do |file|
    parsed_file = parse_yaml(file)
    nil_params = check_params(parsed_file)
    next if nil_params.empty?
    @output << {
      file: file,
      lines: nil_params
    }
  end

  @output
end

#labelString

Returns label with this validator description.

Returns:

  • (String)

    label with this validator description



26
27
28
# File 'lib/polish_geeks/dev_tools/commands/yml_parser.rb', line 26

def label
  'Yaml parser'
end

#valid?Boolean

have not nil value

Returns:

  • (Boolean)

    true if all parameters in YAML files



39
40
41
# File 'lib/polish_geeks/dev_tools/commands/yml_parser.rb', line 39

def valid?
  @output.empty?
end