Class: Mutant::CLI

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/cli.rb

Overview

Comandline parser

Constant Summary collapse

Error =

Error raised when CLI argv is inalid

Class.new(RuntimeError)
EXIT_FAILURE =
1
EXIT_SUCCESS =
0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(*arguments) ⇒ Fixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run cli with arguments

Parameters:

  • arguments (Array<String>)

Returns:

  • (Fixnum)

    returns exit status



21
22
23
24
25
26
27
# File 'lib/mutant/cli.rb', line 21

def self.run(*arguments)
  error = Runner.run(new(*arguments)).fail?
  error ? EXIT_FAILURE : EXIT_SUCCESS
rescue Error => exception
  $stderr.puts(exception.message)
  EXIT_FAILURE
end

Instance Method Details

#debug?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for running in debug mode

Returns:

  • (true)

    if debug mode is active

  • (false)

    otherwise



57
58
59
# File 'lib/mutant/cli.rb', line 57

def debug?
  !!@debug
end

#filterMutant::Matcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mutation filter

Returns:



67
68
69
70
71
72
73
# File 'lib/mutant/cli.rb', line 67

def filter
  if @filters.empty?
    Mutation::Filter::ALL
  else
    Mutation::Filter::Whitelist.new(@filters)
  end
end

#matcherMutant::Matcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return matcher

Returns:

Raises:

  • (CLI::Error)

    raises error when matcher is not given



38
39
40
41
42
43
44
# File 'lib/mutant/cli.rb', line 38

def matcher
  if @matchers.empty?
    raise Error, 'No matchers given'
  end

  Mutant::Matcher::Chain.build(@matchers)
end

#reporterMutant::Reporter::CLI

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return reporter



94
95
96
# File 'lib/mutant/cli.rb', line 94

def reporter
  Mutant::Reporter::CLI.new(self)
end

#strategyStrategy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return stratety

Returns:



82
83
84
85
# File 'lib/mutant/cli.rb', line 82

def strategy
  @strategy || raise(Error, 'no strategy was set!')
  @strategy.new(self)
end