Class: Cucumber::Cli::Main

Inherits:
Object show all
Defined in:
lib/cucumber/cli/main.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, out_stream = STDOUT, error_stream = STDERR) ⇒ Main

Returns a new instance of Main.



24
25
26
27
28
29
30
# File 'lib/cucumber/cli/main.rb', line 24

def initialize(args, out_stream = STDOUT, error_stream = STDERR)
  @args         = args
  @out_stream   = out_stream

  @error_stream = error_stream
  @configuration = nil
end

Class Method Details

.execute(args) ⇒ Object



19
20
21
# File 'lib/cucumber/cli/main.rb', line 19

def execute(args)
  new(args).execute!
end

Instance Method Details

#configurationObject



50
51
52
53
54
55
56
57
# File 'lib/cucumber/cli/main.rb', line 50

def configuration
  return @configuration if @configuration

  @configuration = Configuration.new(@out_stream, @error_stream)
  @configuration.parse!(@args)
  Cucumber.logger = @configuration.log
  @configuration
end

#execute!(existing_runtime = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cucumber/cli/main.rb', line 32

def execute!(existing_runtime = nil)
  trap_interrupt
  return @drb_output if run_drb_client
  
  runtime = if existing_runtime
    existing_runtime.configure(configuration)
    existing_runtime
  else
    Runtime.new(configuration)
  end

  runtime.run!
  runtime.results.failure?
rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e
  @error_stream.puts e.message
  true
end