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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/dragnet/cli/master.rb', line 60

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



36
37
38
39
40
41
42
43
# File 'lib/dragnet/cli/master.rb', line 36

def version
  if options[:'number-only']
    say Dragnet::VERSION
  else
    say "Dragnet #{Dragnet::VERSION}"
    say "Copyright (c) #{Time.now.year} ESR Labs GmbH esrlabs.com"
  end
end