Class: Publisher::Helpers::Spinner

Inherits:
Object
  • Object
show all
Includes:
Publisher::Helpers
Defined in:
lib/allure_report_publisher/lib/helpers/spinner.rb

Overview

Spinner helper class

Defined Under Namespace

Classes: Failure

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Publisher::Helpers

allure_cli?, colorize, debug_io, #env, error, execute_shell, log, log_debug, logger, pastel, path, reset_debug_io!

Constructor Details

#initialize(spinner_message, exit_on_error: true, debug: false) ⇒ Spinner

Returns a new instance of Spinner.



14
15
16
17
18
# File 'lib/allure_report_publisher/lib/helpers/spinner.rb', line 14

def initialize(spinner_message, exit_on_error: true, debug: false)
  @spinner_message = spinner_message
  @exit_on_error = exit_on_error
  @debug = debug
end

Class Method Details

.spin(spinner_message, done_message: "done", exit_on_error: true, debug: false, &block) ⇒ void

This method returns an undefined value.

Run code block inside spinner

Parameters:

  • spinner_message (String)
  • done_message (String) (defaults to: "done")
  • exit_on_error (Boolean) (defaults to: true)
  • &block (Proc)


27
28
29
# File 'lib/allure_report_publisher/lib/helpers/spinner.rb', line 27

def self.spin(spinner_message, done_message: "done", exit_on_error: true, debug: false, &block)
  new(spinner_message, exit_on_error: exit_on_error, debug: debug).spin(done_message, &block)
end

Instance Method Details

#spin(done_message = "done") ⇒ Boolean

Run code block inside spinner

Parameters:

  • done_message (String) (defaults to: "done")

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/allure_report_publisher/lib/helpers/spinner.rb', line 35

def spin(done_message = "done")
  spinner.auto_spin
  yield
  spinner_success(done_message)
rescue StandardError => e
  spinner_error(e)
  raise(Failure, e.message) if exit_on_error
ensure
  print_debug
  Helpers.reset_debug_io!
end