lib/iev/relaton_db.rb in iev-0.3.4 vs lib/iev/relaton_db.rb in iev-0.3.5

- old
+ new

@@ -3,15 +3,15 @@ # (c) Copyright 2020 Ribose Inc. # require "singleton" -module IEV +module Iev # Relaton cach singleton. class RelatonDb include Singleton - include CLI::UI + include Cli::Ui def initialize info "Initializing Relaton..." @db = Relaton::Db.new "db", nil end @@ -31,33 +31,29 @@ def retrying_on_failures(attempts: 4) curr_attempt = 1 begin yield + rescue StandardError + raise unless curr_attempt <= attempts - rescue - if curr_attempt <= attempts - sleep(2 ** curr_attempt * 0.1) - curr_attempt += 1 - retry - else - raise - end + sleep(2**curr_attempt * 0.1) + curr_attempt += 1 + retry end end def capture_output_streams original_stdout = $stdout original_stderr = $stderr $stderr = $stdout = fake_out = StringIO.new begin yield - ensure $stdout = original_stdout $stderr = original_stderr - debug(:relaton, fake_out.string) if fake_out.pos > 0 + debug(:relaton, fake_out.string) if fake_out.pos.positive? end end end end