class Cucumber::Cli::Configuration

Attributes

out_stream[R]

Public Class Methods

new(out_stream = STDOUT, error_stream = STDERR) click to toggle source
# File lib/cucumber/cli/configuration.rb, line 19
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

Public Instance Methods

dry_run?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 57
def dry_run?
  @options[:dry_run]
end
expand?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 61
def expand?
  @options[:expand]
end
fail_fast?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 65
def fail_fast?
  @options[:fail_fast]
end
filters() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 97
def filters
  @options.filters
end
formats() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 101
def formats
  @options[:formats]
end
guess?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 53
def guess?
  @options[:guess]
end
log() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 77
def log
  logger = Logger.new(@out_stream)
  logger.formatter = LogFormatter.new
  logger.level = Logger::INFO
  logger.level = Logger::DEBUG if verbose?
  logger
end
name_regexps() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 93
def name_regexps
  @options[:name_regexps]
end
parse!(args) click to toggle source
# File lib/cucumber/cli/configuration.rb, line 25
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
paths() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 105
def paths
  @options[:paths]
end
randomize?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 37
def randomize?
  @options[:order] == 'random'
end
retry_attempts() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 69
def retry_attempts
  @options[:retry]
end
seed() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 41
def seed
  Integer(@options[:seed] || rand(0xFFFF))
end
snippet_type() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 73
def snippet_type
  @options[:snippet_type] || :cucumber_expression
end
strict() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 45
def strict
  @options[:strict]
end
tag_expressions() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 89
def tag_expressions
  @options[:tag_expressions]
end
tag_limits() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 85
def tag_limits
  @options[:tag_limits]
end
to_hash() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 109
def to_hash
  Hash(@options).merge(out_stream: @out_stream, error_stream: @error_stream, seed: seed)
end
verbose?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 33
def verbose?
  @options[:verbose]
end
wip?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 49
def wip?
  @options[:wip]
end

Private Instance Methods

add_default_formatter() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 137
def add_default_formatter
  @options[:formats] << ['pretty', {}, @out_stream]
end
arrange_formats() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 127
def arrange_formats
  add_default_formatter if needs_default_formatter?

  @options[:formats] = @options[:formats].sort_by do |f|
    f[2] == @out_stream ? -1 : 1
  end
  @options[:formats].uniq!
  @options.check_formatter_stream_conflicts
end
formatter_missing?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 145
def formatter_missing?
  @options[:formats].empty?
end
needs_default_formatter?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 141
def needs_default_formatter?
  formatter_missing? || publish_only?
end
publish_only?() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 149
def publish_only?
  @options[:formats]
    .uniq
    .map { |formatter, _, stream| [formatter, stream] }
    .uniq
    .reject { |formatter, stream| formatter == 'message' && stream != @out_stream }
    .empty?
end
set_environment_variables() click to toggle source
# File lib/cucumber/cli/configuration.rb, line 121
def set_environment_variables
  @options[:env_vars].each do |var, value|
    ENV[var] = value
  end
end