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.



22
23
24
25
26
# File 'lib/cucumber/cli/configuration.rb', line 22

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.



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

def out_stream
  @out_stream
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/cucumber/cli/configuration.rb', line 61

def dry_run?
  @options[:dry_run]
end

#expand?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/cucumber/cli/configuration.rb', line 65

def expand?
  @options[:expand]
end

#fail_fast?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/cucumber/cli/configuration.rb', line 69

def fail_fast?
  @options[:fail_fast]
end

#filtersObject



101
102
103
# File 'lib/cucumber/cli/configuration.rb', line 101

def filters
  @options.filters
end

#formatsObject



105
106
107
# File 'lib/cucumber/cli/configuration.rb', line 105

def formats
  @options[:formats]
end

#guess?Boolean

Returns:

  • (Boolean)


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

def guess?
  @options[:guess]
end

#logObject



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

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



97
98
99
# File 'lib/cucumber/cli/configuration.rb', line 97

def name_regexps
  @options[:name_regexps]
end

#parse!(args) ⇒ Object



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

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



109
110
111
# File 'lib/cucumber/cli/configuration.rb', line 109

def paths
  @options[:paths]
end

#randomize?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/cucumber/cli/configuration.rb', line 41

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

#retry_attemptsObject



73
74
75
# File 'lib/cucumber/cli/configuration.rb', line 73

def retry_attempts
  @options[:retry]
end

#seedObject



45
46
47
# File 'lib/cucumber/cli/configuration.rb', line 45

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

#snippet_typeObject



77
78
79
# File 'lib/cucumber/cli/configuration.rb', line 77

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

#strictObject



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

def strict
  @options[:strict]
end

#tag_expressionsObject



93
94
95
# File 'lib/cucumber/cli/configuration.rb', line 93

def tag_expressions
  @options[:tag_expressions]
end

#tag_limitsObject



89
90
91
# File 'lib/cucumber/cli/configuration.rb', line 89

def tag_limits
  @options[:tag_limits]
end

#to_hashObject



113
114
115
# File 'lib/cucumber/cli/configuration.rb', line 113

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

#verbose?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/cucumber/cli/configuration.rb', line 37

def verbose?
  @options[:verbose]
end

#wip?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/cucumber/cli/configuration.rb', line 53

def wip?
  @options[:wip]
end