Class: Spinach::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/spinach/cli.rb

Overview

The cli is a class responsible of handling all the command line interface logic.

Instance Method Summary collapse

Constructor Details

#initialize(args = ARGV) ⇒ Cli

Returns a new instance of Cli.

Parameters:

  • arguments (Array<String>)

    The command line arguments



12
13
14
# File 'lib/spinach/cli.rb', line 12

def initialize(args = ARGV)
  @args = args
end

Instance Method Details

#init_reporterObject

Inits the reporter with a default one.



35
36
37
38
39
# File 'lib/spinach/cli.rb', line 35

def init_reporter
  reporter =
    Spinach::Reporter::Stdout.new(options[:reporter])
  reporter.bind
end

#optionsHash

Returns A hash of options separated by its type.

Examples:

Cli.new.options
# => { reporter: { backtrace: true } }

Returns:

  • (Hash)

    A hash of options separated by its type.



49
50
51
# File 'lib/spinach/cli.rb', line 49

def options
  @options ||= parse_options
end

#runtrue, false

Runs all the features.

Returns:

  • (true, false)

    The exit status - true for success, false for failure.



22
23
24
25
26
27
28
29
30
# File 'lib/spinach/cli.rb', line 22

def run
  parse_options
  features = if @args.any?
    @args
  else
    Dir.glob(File.join 'features', '**', '*.feature')
  end
  Spinach::Runner.new(features).run
end