Class: Cucumber::Cli::Configuration

Inherits:
Object
  • Object
show all
Includes:
Cucumber::Constantize
Defined in:
lib/cucumber/cli/configuration.rb

Defined Under Namespace

Classes: LogFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cucumber::Constantize

#constantize, #underscore

Constructor Details

#initialize(out_stream = $stdout, error_stream = $stderr) ⇒ Configuration

Returns a new instance of Configuration.



20
21
22
23
24
# File 'lib/cucumber/cli/configuration.rb', line 20

def initialize(out_stream = $stdout, error_stream = $stderr)
  @out_stream   = out_stream
  @error_stream = error_stream
  @options = Options.new(@out_stream, @error_stream, default_profile: 'default')
end

Instance Attribute Details

#out_streamObject (readonly)

Returns the value of attribute out_stream.



18
19
20
# File 'lib/cucumber/cli/configuration.rb', line 18

def out_stream
  @out_stream
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/cucumber/cli/configuration.rb', line 59

def dry_run?
  @options[:dry_run]
end

#expand?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/cucumber/cli/configuration.rb', line 63

def expand?
  @options[:expand]
end

#fail_fast?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/cucumber/cli/configuration.rb', line 67

def fail_fast?
  @options[:fail_fast]
end

#filtersObject



99
100
101
# File 'lib/cucumber/cli/configuration.rb', line 99

def filters
  @options.filters
end

#formatsObject



103
104
105
# File 'lib/cucumber/cli/configuration.rb', line 103

def formats
  @options[:formats]
end

#guess?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/cucumber/cli/configuration.rb', line 55

def guess?
  @options[:guess]
end

#logObject



79
80
81
82
83
84
85
# File 'lib/cucumber/cli/configuration.rb', line 79

def log
  logger = Logger.new(@out_stream)
  logger.formatter = LogFormatter.new
  logger.level = Logger::INFO
  logger.level = Logger::DEBUG if verbose?
  logger
end

#name_regexpsObject



95
96
97
# File 'lib/cucumber/cli/configuration.rb', line 95

def name_regexps
  @options[:name_regexps]
end

#parse!(args) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/cucumber/cli/configuration.rb', line 26

def parse!(args)
  @args = args
  @options.parse!(args)
  arrange_formats
  raise("You can't use both --strict and --wip") if strict.strict? && wip?

  set_environment_variables
end

#pathsObject



107
108
109
# File 'lib/cucumber/cli/configuration.rb', line 107

def paths
  @options[:paths]
end

#randomize?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/cucumber/cli/configuration.rb', line 39

def randomize?
  @options[:order] == 'random'
end

#retry_attemptsObject



71
72
73
# File 'lib/cucumber/cli/configuration.rb', line 71

def retry_attempts
  @options[:retry]
end

#seedObject



43
44
45
# File 'lib/cucumber/cli/configuration.rb', line 43

def seed
  Integer(@options[:seed] || rand(0xFFFF))
end

#snippet_typeObject



75
76
77
# File 'lib/cucumber/cli/configuration.rb', line 75

def snippet_type
  @options[:snippet_type] || :cucumber_expression
end

#strictObject



47
48
49
# File 'lib/cucumber/cli/configuration.rb', line 47

def strict
  @options[:strict]
end

#tag_expressionsObject



91
92
93
# File 'lib/cucumber/cli/configuration.rb', line 91

def tag_expressions
  @options[:tag_expressions]
end

#tag_limitsObject



87
88
89
# File 'lib/cucumber/cli/configuration.rb', line 87

def tag_limits
  @options[:tag_limits]
end

#to_hashObject



111
112
113
# File 'lib/cucumber/cli/configuration.rb', line 111

def to_hash
  Hash(@options).merge(out_stream: @out_stream, error_stream: @error_stream, seed: seed)
end

#verbose?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cucumber/cli/configuration.rb', line 35

def verbose?
  @options[:verbose]
end

#wip?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/cucumber/cli/configuration.rb', line 51

def wip?
  @options[:wip]
end