From 25f0aa470c6a5a8cff3a9331d3291fd49e442ee5 Mon Sep 17 00:00:00 2001 From: Mike Karlesky Date: Thu, 2 May 2024 15:22:45 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Removed=20global=20$decorate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With bootlader to application object handoff, global is no longer needed. Internal object variable @decorate in Loginator is enough. --- bin/cli_helper.rb | 8 ++++---- lib/ceedling/loginator.rb | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/bin/cli_helper.rb b/bin/cli_helper.rb index 6b41d5c7..27cffa8d 100644 --- a/bin/cli_helper.rb +++ b/bin/cli_helper.rb @@ -18,7 +18,7 @@ def setup @actions = @actions_wrapper # Automatic setting of console printing decorations - @loginator.decorate( !windows?() ) + @loginator.decorate = !windows?() end @@ -216,7 +216,7 @@ def process_decoration(env, config={}) decorate = true end - @loginator.decorate( decorate ) + @loginator.decorate = decorate end # Otherwise inspect project configuration (could be blank and gets skipped) @@ -224,9 +224,9 @@ def process_decoration(env, config={}) if (!walk[:value].nil?) case walk[:value] when :all - @loginator.decorate( true ) + @loginator.decorate = true when :none - @loginator.decorate( false ) + @loginator.decorate = false else #:auto # Retain what was set in `setup()` above based on platform end diff --git a/lib/ceedling/loginator.rb b/lib/ceedling/loginator.rb index 7f3f1660..328f1f4b 100644 --- a/lib/ceedling/loginator.rb +++ b/lib/ceedling/loginator.rb @@ -12,11 +12,12 @@ class Loginator attr_reader :project_logging + attr_writer :decorate constructor :verbosinator, :stream_wrapper, :file_wrapper, :system_wrapper def setup() - $decorate = false if $decorate.nil? + @decorate = false @replace = { # Problematic characters pattern => Simple characters @@ -90,15 +91,10 @@ def out(string, verbosity=Verbosity::NORMAL, label=LogLabels::AUTO, stream=nil) return if !(@verbosinator.should_output?( verbosity )) # Add labels and fun characters - console_str = format( string, verbosity, label, $decorate ) + console_str = format( string, verbosity, label, @decorate ) # Write to output stream after optionally removing any problematic characters - stream.print( sanitize( console_str, $decorate ) ) - end - - - def decorate(d) - $decorate = d + stream.print( sanitize( console_str, @decorate ) ) end ### Private ###