Class: ForemanMaintain::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman_maintain/reporter.rb,
lib/foreman_maintain/reporter/cli_reporter.rb

Direct Known Subclasses

CLIReporter

Defined Under Namespace

Classes: CLIReporter, DummySpinner

Constant Summary collapse

DECISION_MAPPER =
{
  %w[y yes] => :yes,
  %w[n next no] => :no,
  %w[q quit] => :quit
}.freeze

Instance Method Summary collapse

Instance Method Details

#after_execution_finishes(_execution) ⇒ Object



21
# File 'lib/foreman_maintain/reporter.rb', line 21

def after_execution_finishes(_execution); end

#after_scenario_finishes(_scenario) ⇒ Object



23
# File 'lib/foreman_maintain/reporter.rb', line 23

def after_scenario_finishes(_scenario); end

#ask(_message) ⇒ Object



43
# File 'lib/foreman_maintain/reporter.rb', line 43

def ask(_message); end

#ask_decision(message, actions_msg: 'y(yes), n(no), q(quit)', assumeyes: assumeyes?, , run_strategy: :fail_fast) ⇒ Object

simple yes/no question, returns :yes, :no or :quit rubocop:disable Metrics/LineLength



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/foreman_maintain/reporter.rb', line 51

def ask_decision(message, actions_msg: 'y(yes), n(no), q(quit)', assumeyes: assumeyes?, run_strategy: :fail_fast)
  actions_msg = 'y(yes), n(no)' if run_strategy == :fail_slow
  if assumeyes
    print("#{message} (assuming yes)")
    return :yes
  end

  until_valid_decision do
    filter_decision(ask("#{message}, [#{actions_msg}]"))
  end
end

#assumeyes=(assume) ⇒ Object

rubocop:enable Metrics/LineLength



64
65
66
# File 'lib/foreman_maintain/reporter.rb', line 64

def assumeyes=(assume)
  @assumeyes = !!assume
end

#assumeyes?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/foreman_maintain/reporter.rb', line 45

def assumeyes?
  @assumeyes
end

#before_execution_starts(_execution) ⇒ Object



19
# File 'lib/foreman_maintain/reporter.rb', line 19

def before_execution_starts(_execution); end

#before_scenario_starts(_scenario, _last_scenario = nil) ⇒ Object

Each public method is a hook called by executor at the specific point



17
# File 'lib/foreman_maintain/reporter.rb', line 17

def before_scenario_starts(_scenario, _last_scenario = nil); end

#on_next_steps(steps, run_strategy = :fail_fast) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/foreman_maintain/reporter.rb', line 25

def on_next_steps(steps, run_strategy = :fail_fast)
  return if steps.empty?

  if steps.size > 1
    multiple_steps_decision(steps, run_strategy)
  else
    single_step_decision(steps.first, run_strategy)
  end
end


39
# File 'lib/foreman_maintain/reporter.rb', line 39

def print(_message); end

#puts(_message) ⇒ Object



41
# File 'lib/foreman_maintain/reporter.rb', line 41

def puts(_message); end

#with_spinner(_message) {|DummySpinner.new| ... } ⇒ Object

Yields:



35
36
37
# File 'lib/foreman_maintain/reporter.rb', line 35

def with_spinner(_message, &_block)
  yield DummySpinner.new
end