Class: PolishGeeks::DevTools::Commands::ExamplesComparator

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

Overview

Command wrapper for ExamplesComparator rake task It informs us if our .example files structure is the same as non-example once

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!, #error_message

Instance Method Details

#executeString

Executes this command

Returns:

  • (String)

    command output



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

def execute
  @output = "Comparing yaml structure of example files\n\n"

  Dir[config_path].each do |example_file|
    dedicated_file = example_file.gsub('.example', '')
    if File.exist?(dedicated_file)
      header = compare_header(example_file, dedicated_file)
      @output << compare_output(header, example_file, dedicated_file)
    else
      @output << missing_file(dedicated_file)
    end
  end
end

#valid?Boolean

Returns true if all the example files have the same structure as non-example once, false otherwise.

Returns:

  • (Boolean)

    true if all the example files have the same structure as non-example once, false otherwise



27
28
29
# File 'lib/polish_geeks/dev_tools/commands/examples_comparator.rb', line 27

def valid?
  !output.include?('failed')
end