Class: Dragnet::CLI::Master

Inherits:
Base
  • Object
show all
Defined in:
lib/dragnet/cli/master.rb

Overview

Entry point class for the Dragnet CLI. Includes all the commands and sub-commands of the CLI.

The class should not contain any logic, everything should be delegated to helper classes as soon as possible. Only exceptions are error handling and message printing.

Constant Summary collapse

E_MISSING_PARAMETER_ERROR =
2
E_NO_MTR_FILES_FOUND =
3
E_GIT_ERROR =
4
E_EXPORT_ERROR =
5
E_INCOMPATIBLE_REPOSITORY =
6
E_ERRORS_DETECTED =
16
E_FAILED_TESTS =
32

Constants inherited from Base

Base::E_CONFIG_LOAD_ERROR

Instance Attribute Summary

Attributes inherited from Base

#configuration, #logger

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Dragnet::CLI::Base

Instance Method Details

#check(path = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/dragnet/cli/master.rb', line 53

def check(path = nil)
  load_configuration
  self.path = path

  files = explore
  test_records, errors = validate(files)
  verify(test_records)

  export(test_records, errors) if options[:export]

  exit_code = 0
  exit_code |= E_ERRORS_DETECTED if errors.any?
  exit_code |= E_FAILED_TESTS unless test_records.all? { |test_record| test_record.verification_result.passed? }

  exit(exit_code) if exit_code.positive? # doing exit(0) will stop RSpec execution.
end

#versionObject



33
34
35
36
# File 'lib/dragnet/cli/master.rb', line 33

def version
  say "Dragnet #{Dragnet::VERSION}"
  say "Copyright (c) #{Time.now.year} ESR Labs GmbH esrlabs.com"
end