Sha256: 35cf33512a7e50cc0de887e60302ea9d80ec3e45c4aa24daacaa555d03ca18ad
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
# frozen_string_literal: true require "pastel" require "tty-spinner" module CobraCommander module Executor class Spinners pastel = ::Pastel.new SPINNER_OPTIONS = { format: :bouncing, success_mark: pastel.green("[DONE]"), error_mark: pastel.red("[ERROR]"), }.freeze def self.start(execution, output:) new(execution, output: output).start end def initialize(execution, output:) @multi = TTY::Spinner::Multi.new(":spinner :task", output: output) @multi.top_spinner.update(task: "Running") execution.each { |job, result| register_spinner(job, result) } end def start @multi.auto_spin end private def register_spinner(job, result) @multi.register(":spinner #{job}", **SPINNER_OPTIONS) do |spinner| result.on_fulfillment!(spinner) { |_, spin| spin.success } .on_rejection!(spinner) { |_, spin| spin.error } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cobra_commander-1.0.1 | lib/cobra_commander/executor/spinners.rb |
cobra_commander-1.0.0 | lib/cobra_commander/executor/spinners.rb |